This file contains hidden or 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
E = { | |
"A": [], | |
"B": ["A", "E"], | |
"C": ["D", "H"], | |
"D": ["B"], | |
"E": ["F"], | |
"F": [], | |
"G": ["A"], | |
"H": ["B", "G"], | |
} |
This file contains hidden or 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
E = { | |
"A": [], | |
"B": ["A", "E"], | |
"C": ["D", "H"], | |
"D": ["B"], | |
"E": ["F"], | |
"F": [], | |
"G": ["A"], | |
"H": ["B", "G"], | |
} |
This file contains hidden or 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
E = { "A": ["E"], | |
"B": ["A", "C", "G"], | |
"C": ["A"], | |
"D": ["B", "G"], | |
"E": ["F"], | |
"F": [], | |
"G": ["A", "F"], | |
} | |
This file contains hidden or 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
N = 8 | |
def neighbors(board): | |
occupied = set(board) | |
for r in range(N): | |
for c in range(N): | |
if (r, c) not in occupied: | |
yield board + ((r, c),) | |
def solve_8q_one(): |
This file contains hidden or 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 | |
import numpy as np | |
def simulate_T(n): | |
if n <= 1: | |
return 0 | |
# the pivot may end up randomly anywhere from 0 to n-1 | |
pivot_index = random.randint(0, n - 1) | |
first_half = simulate_T(pivot_index) |
This file contains hidden or 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 | |
# roll out of a particular game, start at position n, and roll a coin of some prob to move up or down. | |
# if it reaches 0, you lose | |
def simulate_game_log_space(start_n, coin_prob): | |
trajectory = [] | |
n = start_n | |
for i in range(1000): | |
trajectory.append(n) |
This file contains hidden or 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 | |
import json | |
import cv2 | |
import math | |
# open the ./data_train.json | |
GRID = 64 | |
IMG_W = GRID * 20 |
This file contains hidden or 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 self play version of 20 quetsions with gpt playing against itself | |
from langchain.llms import OpenAI | |
# from langchain.chat_models import ChatOpenAI | |
llm = OpenAI(model_name="gpt-3.5-turbo-0301") | |
# an oracle | |
def get_oracle(concept): | |
def give_answer(question): | |
prompt = f"For a {concept}, \ | |
{question}. Answer with a single word [YES, NO]" |
This file contains hidden or 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
# get all possible next states | |
def get_next_state(tuple_state): | |
ret = [] | |
# for all index of tuple_state, subtract any number of stones 1 through maximum possible | |
for i in range(len(tuple_state)): | |
for j in range(1, tuple_state[i]+1): | |
# create new state | |
new_state = list(tuple_state) | |
new_state[i] -= j |
This file contains hidden or 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 rectangle import is_inside, is_correct, inside, outside, W | |
import random | |
import string | |
# for the purpose of showing this is a "language model", all programs here are | |
# written as STRINGS, you need to call eval(prog) on them to get the actual program | |
def writer1(): | |
return ''.join(random.choice(string.printable) for i in range(9)) |
NewerOlder