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
label_0: | |
push 0 | |
jmp label_1 | |
label_1: | |
# read input | |
push 1 | |
add | |
dup | |
dup | |
readc |
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
### 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 |
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
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) | |
``` |
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 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) |