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
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]) |
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
""" | |
Character-based language model in TensorFlow | |
============================================ | |
A character-based language model written in TensorFlow and trained on | |
the Penn Treebank dataset. The model can either be trained using TFs | |
model.fit() method (auto) or using a custom training loop | |
(manual). Results should not differ. | |
Usage: | |
char_lm_tf.py [options] ( manual | auto ) |
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 observations import ptb | |
from time import sleep, time | |
from torch.nn import * | |
from torch.optim import * | |
from torch.utils.data import DataLoader | |
from torch.utils.data.distributed import DistributedSampler | |
from torch_xla.core.xla_model import (get_ordinal, | |
is_master_ordinal, | |
master_print, | |
xla_device, |
OlderNewer