Skip to content

Instantly share code, notes, and snippets.

View ryndvs96's full-sized avatar

Ryan Davis ryndvs96

  • Atlanta, GA
View GitHub Profile
@ryndvs96
ryndvs96 / day1.wsa
Created December 9, 2018 16:19
Whitespace assembly for advent of code day 1 !
label_0:
push 0
jmp label_1
label_1:
# read input
push 1
add
dup
dup
readc
@ryndvs96
ryndvs96 / test.py
Created September 6, 2018 16:54
Decision Tree with repeated attributes in different branches.
### Copy this data into a file test.csv in current directory
DATA = """
A,B,C,D,label
0,0,0,0,0
0,0,0,1,1
0,0,1,0,0
0,0,1,1,1
0,1,0,0,1
0,1,0,0,1
0,1,0,1,1
@ryndvs96
ryndvs96 / bfs.py
Last active September 4, 2018 15:28
Recursive BFS
info = """
This does recursion on each depth-level from the root
of the search tree. For instance if our graph looked like this:
```
(A=7) ------- (D=8)
/ \ |
(B=6) (C=1) -- (E=10)
\ / |
(F=3) ------- (G=5)
```
@ryndvs96
ryndvs96 / lands.py
Last active November 2, 2021 07:48
Return largest and second largest element in n + log2(n) - 2 comparisons
import itertools
def L_and_S(arr):
n = len(arr)
A = list(arr)
# base case
if n == 2:
if A[0] > A[1]:
return (0, 1)