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 asyncio | |
import contextlib | |
import io | |
import sys | |
import threading | |
from functools import wraps | |
from typing import Any, Callable, TypeVar, Union, AsyncIterator | |
T = TypeVar('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
# heinous zen koan: solve problem with as few indents as possible | |
import sys | |
import numpy as np | |
import itertools | |
def solve(puzzle): | |
other_sides = [set(puzzle[(i+1)%4] + puzzle[(i+2)%4] + puzzle[(i+3)%4]) for i in range(4)] | |
letter_neighbors = {letter: other_sides[index] for (index, side_string) in enumerate(puzzle) for letter in side_string} | |
constructible = lambda word: len(word) >= 3 and all([(first in letter_neighbors) and (second in letter_neighbors[first]) for (first, second) in zip(word, word[1:])]) | |
constructible_words = set(filter(constructible, map(lambda x: x.rstrip(), open('dictionary.txt', 'r')))) |
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 | |
from outlaw_environment import OutlawEnvironment | |
from stable_baselines3 import PPO | |
from stable_baselines3 import DQN | |
from stable_baselines3.common.callbacks import BaseCallback | |
from stable_baselines3.common.env_checker import check_env | |
from stable_baselines3.common.evaluation import evaluate_policy | |
env = OutlawEnvironment() | |
check_env(env, warn=True) |
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
paste into bottom of auto run code in details | |
Details.SpellsToIgnore[328351] = true; -- spear | |
Details.SpellsToIgnore[344421] = true; -- anima exhaust from kyrian goliath | |
Details.SpellsToIgnore[328128] = true; -- hammer | |
Details.SpellsToIgnore[328406] = true; -- Discharged Anima orb |
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 sys | |
# Should return a set() of all words in the scrabble dictionary passed in at the given file path. | |
# You should implement this file loader. | |
def LoadWords(scrabble_dictionary_path): | |
pass | |
# Return a set() of ALL valid words from the input set `all_words` that differ by exactly one letter from `word` | |
# Hint: you may want to try using regular expressions here. | |
def FindAllNeighbors(word, all_words): |
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 random | |
class HashFamily: | |
def __init__(self): | |
self.memomask = {} | |
def hash_fn(self, n): | |
mask = self.memomask.get(n) | |
if mask is None: | |
random.seed(n) | |
mask = self.memomask[n] = random.getrandbits(64) |
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
#include "stdio.h" | |
#include "stdlib.h" | |
#include "string.h" | |
#define MAX_DICTIONARY_SIZE 300000 | |
#define MAX_WORD_LENGTH 15 | |
// We should guarantee room for a newline and null byte in our buffer. | |
#define BUFFER_SIZE (MAX_WORD_LENGTH + 2) | |
int populate_dictionary(char *filepath, char dictionary[][BUFFER_SIZE]) { |
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
#include "stdio.h" | |
#include "string.h" | |
// 6. (Implementation) | |
void memory_copy(void* to, const void* from, int n) { | |
// Need to cast from void to char so that pointer arithmetic works here. | |
const char* src = (const char *) from; | |
char* dest = (char *) to; | |
for (int i = 0; i < n; i++) { |
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
; nasm -f elf64 -g -F dwarf repeat_hello.asm && gcc -g -no-pie repeat_hello.o -o repeat_hello && ./repeat_hello 5 | |
; Intended for use on linux x86-864 machines; to run on OS X you'd have to change the syscalls. | |
extern atoi | |
global main | |
section .data | |
message: db "Hello, world!", 0x0A | |
length: equ 14 | |
err_msg: db "Wrong!", 0x0A |
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 | |
import requests | |
# Rough bounding box for San Clemente, CA | |
southwest = [33.351665, -117.779208] | |
northeast = [33.566387, -117.537489] | |
bbox_string = "%s,%s,%s,%s" % tuple(southwest[::-1]+northeast[::-1]) | |
stops = [] | |
routes = [] |
NewerOlder