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
from random import randint | |
from time import time | |
N_SOLS = 1 | |
def binary_search(min, max): | |
n_bins = 0 | |
while min <= max: | |
mid = (min + max) // 2 | |
n_bins += 1 | |
if mid < NUM: | |
min = mid + 1 |
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 json | |
txt = """{ | |
"version" : [0, 1, 0], | |
"list" : [ | |
{"hi" : 33, "l" : [2, 3, 0], "mo" : { "version" : 3 }}, | |
{"version": [3, 4, 5]} | |
], | |
"ad" : { "foo" : 123 } | |
}""" |
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
/* | |
Copyright (c) 2014, Cosmin Gorgovan <cosmin [at] linux-geek [dot] org> | |
All rights reserved. | |
Redistribution and use in source and binary forms, with or without modification, | |
are permitted provided that the following conditions are met: | |
1. Redistributions of source code must retain the above copyright notice, this | |
list of conditions and the following disclaimer. |
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
from __future__ import print_function | |
import httplib2 | |
import os | |
from apiclient import discovery | |
from apiclient.http import BatchHttpRequest | |
from datetime import datetime | |
from oauth2client import client | |
from oauth2client import tools | |
from oauth2client.file import Storage |
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
adj = {1 : {6, 8}, 2 : {7, 9}, 3 : {4, 8}, 4 : {3, 9, 0}, 6 : {1, 7, 0}, | |
7 : {2, 6}, 8 : {1, 3}, 9 : {4, 2}, 0 : {4, 6}} | |
memo = {} | |
def allpaths2(at, n, tot): | |
if (at, n) in memo: | |
tot[0] += memo[at, n] | |
return | |
prev = tot[0] | |
if n == 0: | |
tot[0] += 1 |
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 utils; | |
import java.io.*; | |
import java.nio.*; | |
import java.nio.channels.*; | |
import java.util.Random; | |
import static java.lang.System.out; | |
import static java.nio.channels.FileChannel.MapMode.READ_WRITE; | |
public class TestWrite { |
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
<?xml version='1.0' encoding='windows-1252'?> | |
<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi'> | |
<Product | |
Name='Emacs $(var.Arch)' | |
Id='*' | |
UpgradeCode='$(var.UpgradeCode)' | |
Language='1033' | |
Codepage='1252' | |
Version='$(var.ProductVersion)' | |
Manufacturer="Free Software Foundation"> |
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
rem in the emacs directory: | |
heat dir bin -sw 5150 -var var.MySource -cg bingroup -gg -dr INSTALLDIR -out bin.wxs | |
candle -out bin.wxsobj bin.wxs -dMySource="bin" | |
heat dir libexec -sw 5150 -var var.MySource -cg libexecgroup -gg -dr INSTALLDIR -out libexec.wxs | |
candle -out libexec.wxsobj libexec.wxs -dMySource="libexec" | |
heat dir share -sw 5150 -var var.MySource -cg sharegroup -gg -dr INSTALLDIR -out share.wxs | |
candle -out share.wxsobj share.wxs -dMySource="share" |
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 numpy as np | |
import matplotlib.pyplot as plt | |
from mpl_toolkits.mplot3d import Axes3D | |
class Body(): | |
""" | |
This class contains adjustable parameters as attributes. These | |
parameters include current and previous positions, velocities, and | |
accelerations. | |
""" |
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 numpy as np | |
def suffix_array(seq): | |
if not seq: | |
return [] | |
vocab = sorted(set(seq)) | |
ch2idx = {ch: i for i, ch in enumerate(vocab)} | |
cls = np.array([ch2idx[t] for t in seq] + [-1]) |
OlderNewer