This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let move_bits dest_num dest_bits src_num src_bits = | |
let movable_bits = min dest_bits src_bits in | |
let bits_to_move = src_num lsr (src_bits - movable_bits) in | |
let dest_num = (dest_num lsl movable_bits) lor bits_to_move in | |
let src_num = src_num land ((1 lsl (src_bits - movable_bits)) - 1) in | |
(dest_num, dest_bits - movable_bits, src_num, src_bits - movable_bits) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open Core;; | |
let s = {|nop +0 | |
acc +1 | |
jmp +4 | |
acc +3 | |
jmp -3 | |
acc -99 | |
acc +1 | |
jmp -4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import csv | |
import itertools | |
l = list(csv.DictReader(open('Mailchimp_GeoTwitter.csv'))) | |
col_email = 'Email Address' | |
col_address = 'Your Mailing Address (where you receive your rock)' | |
col_shipping = 'Are you willing to ship internationally?' | |
col_first_name = 'First Name' | |
col_last_name = 'Last Name' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let string_of_chars chars = | |
let buf = Buffer.create 16 in | |
List.iter (Buffer.add_char buf) chars; | |
Buffer.contents buf | |
module type Integer = sig | |
type t | |
val of_string : string -> t | |
val to_string : t -> string | |
val subtract : t -> t -> t |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package server | |
import java.io.ObjectInputStream | |
import java.net.SocketAddress | |
import java.nio.ByteBuffer | |
import java.nio.channels.AsynchronousServerSocketChannel | |
import java.nio.channels.AsynchronousSocketChannel | |
import java.nio.channels.CompletionHandler | |
import java.nio.charset.Charset | |
import java.util.concurrent.locks.Lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Solution { | |
public: | |
double findMedianSortedArrays(vector<int> &nums1, vector<int> &nums2); | |
int find_at_index(size_t index, vector<int> &nums1, vector<int> &nums2); | |
}; | |
using namespace std; | |
void print_range(std::vector<int>::iterator begin, std::vector<int>::iterator end){ | |
for(; begin < end; begin++){ | |
std::cout << *begin << ","; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
G = [("A", "B"), ("B", "C"), ("C", "D")] | |
def render_digraph(G): | |
def g(): | |
for p, c in G: | |
yield '"{}" -> "{}"'.format(p, c) | |
lines = "\n".join(g()) | |
return """ | |
digraph {{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import itertools | |
s = """18:01 ! 6:042 | |
18:01 ! 18:03 | |
8:01 ! 8:02 | |
6:042 ! 6:046 | |
6:001; 6:002 ! 6:003 | |
6:004 ! 6:033 | |
18:01 ! 18:02 | |
6:046 ! 6:840 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
A simple sudoku puzzle solver. It uses the observation that an empty position | |
can only contain labels that are not in any other position on the same row, column or | |
square. | |
The solver uses a depth first strategy. When a candidate position is filled, that value is | |
removed from the list of possible value for all positions on the same row, column or squeare. | |
This reduces the search space considerably. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'vba excel macro script that aggregates data from multiple xlsx files. | |
'The path to the directory containing the files should be in a sheet called | |
'Control. And should be in Applescripts colon (:) separated format. | |
Option Explicit | |
Const max_rows As Integer = 200 | |
Sub ListFiles() |
NewerOlder