day 8 ivy part 2 i think this actually works
parent
a635d3f5db
commit
2888e82c6b
|
@ -39,22 +39,20 @@ i slice -d
|
||||||
|
|
||||||
op empty v = 0 == rho v
|
op empty v = 0 == rho v
|
||||||
|
|
||||||
# takes from v while v[i] is less than v[0]
|
# takes from v while v[i] is less than x
|
||||||
op shorter v =
|
op x shorter v =
|
||||||
empty v: v
|
empty v: v
|
||||||
x = v[1]
|
|
||||||
v = 1 flip v
|
|
||||||
(and\ x > v) sel v
|
(and\ x > v) sel v
|
||||||
|
|
||||||
# returns 1 if any v[i] blocks v
|
# returns 1 if any v[i] blocks x
|
||||||
op blocked v =
|
op x blocked v =
|
||||||
empty v: 0
|
empty v: 0
|
||||||
or/ v[1] <= 1 drop v
|
or/ x <= v
|
||||||
|
|
||||||
v = 5 1 2 3 4 3 2 5 6 1 2 3
|
v = 1 2 3 4 3 2 5 6 1 2 3
|
||||||
|
|
||||||
shorter v
|
5 shorter v
|
||||||
shorter 1 2 3
|
0 shorter 1 2 3
|
||||||
|
|
||||||
# takes from v while v[i] is less than v[0]
|
# takes from v while v[i] is less than v[0]
|
||||||
op shorter2 v =
|
op shorter2 v =
|
||||||
|
@ -69,7 +67,8 @@ op shorter2 v =
|
||||||
sample
|
sample
|
||||||
"-"
|
"-"
|
||||||
|
|
||||||
op viewDistance v = (blocked v) + rho shorter v
|
op x viewDistance v = (x blocked v) + rho x shorter v
|
||||||
|
op viewDistance v = v[1] viewDistance 1 drop v
|
||||||
|
|
||||||
viewDistance 1 2 3
|
viewDistance 1 2 3
|
||||||
viewDistance 5 1 2 3
|
viewDistance 5 1 2 3
|
||||||
|
@ -82,10 +81,10 @@ op p score A =
|
||||||
row = A[y]
|
row = A[y]
|
||||||
col = A[;x]
|
col = A[;x]
|
||||||
n = 1
|
n = 1
|
||||||
n = n * viewDistance flip x take row
|
n = n * e viewDistance flip (x-1) take row
|
||||||
n = n * viewDistance e, x drop row
|
n = n * e viewDistance x drop row
|
||||||
n = n * viewDistance flip y take col
|
n = n * e viewDistance flip (y-1) take col
|
||||||
n = n * viewDistance e, y drop col
|
n = n * e viewDistance y drop col
|
||||||
n
|
n
|
||||||
|
|
||||||
op i loopY A =
|
op i loopY A =
|
||||||
|
@ -96,13 +95,14 @@ op i loopX A =
|
||||||
i[1] > (rho A)[1]: 0
|
i[1] > (rho A)[1]: 0
|
||||||
(i loopY A) max (i + 1 0) loopX A
|
(i loopY A) max (i + 1 0) loopX A
|
||||||
|
|
||||||
op solve A = 5 5 loopY A
|
op solve A = 1 1 loopX A
|
||||||
|
|
||||||
|
|
||||||
1 1 score sample
|
1 1 score sample
|
||||||
2 2 score sample
|
2 2 score sample
|
||||||
3 4 score sample
|
3 4 score sample
|
||||||
#solve sample
|
solve sample
|
||||||
|
|
||||||
#1 1 score sample; 1 2 score sample; 1 3 score sample; 1 4 score sample; 1 5 score sample
|
1 1 score sample; 1 2 score sample; 1 3 score sample; 1 4 score sample; 1 5 score sample
|
||||||
#2 1 score sample; 2 2 score sample; 2 3 score sample; 2 4 score sample; 2 5 score sample
|
2 1 score sample; 2 2 score sample; 2 3 score sample; 2 4 score sample; 2 5 score sample
|
||||||
|
solve input
|
||||||
|
|
Loading…
Reference in New Issue