Skip to content

Instantly share code, notes, and snippets.

@jpark9013
jpark9013 / output.cpp
Last active March 6, 2022 18:56
sample output from cpp-data-classes program
class DataTable {
std::int64_t rows;
std::vector<std::string> names;
std::vector<std::pair<double, double>> locations;
std::string table_name;
public:
DataTable() {
import random
class Board:
_DIGITS = 4
def __init__(self, height=4, width=4):
self.h = height
self.w = width
@jpark9013
jpark9013 / generate.py
Created May 2, 2021 01:17
generate psuedo random numbers from 1 to n that add up to n
import math
import random
def recur(n, lst, chance):
if n == 1:
lst.append(1)
return
r = random.uniform(0, 1)
if r <= chance:
lst.append(n)
@jpark9013
jpark9013 / test.py
Last active April 25, 2021 22:07
thing
import math
import statistics
import random
import pyspiel
game = pyspiel.load_game("breakthrough")
trials = int(1e4)
white_wins = 0
black_wins = 0
lst = []
@jpark9013
jpark9013 / Hello.java
Created July 5, 2020 22:42
guessing game 1-100
import java.util.*;
public class Hello {
public static void main(String[] args) {
Random rand = new Random();
int tries = 1;
int num = rand.nextInt(99) + 1;
Scanner sc = new Scanner(System.in);
System.out.println("Guess a number between 1 and 100");
int plr = Integer.parseInt(sc.nextLine());
@jpark9013
jpark9013 / frogs.py
Created July 1, 2020 03:33
Proving the TED riddle frogs video
# Frogs problem on TED
import random
def run():
bothFrogs = 0
oneFrog = 0
# Doing 100000 trials, bothfrogs probability printed top, one below
@jpark9013
jpark9013 / montyhall.py
Last active July 1, 2020 03:35
Run monty hall on python
# Monty hall problem
import random
def run():
stay = 0
dif = 0
for i in range(100000):
# doing different door
car = random.randint(0, 2)