Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,8 @@
|
|||
tri:=File("triangle.txt").pump(List,fcn(s){ s.strip().split(" ").apply("toInt") }).copy();
|
||||
while(tri.len()>1){
|
||||
t0:=tri.pop();
|
||||
t1:=tri.pop();
|
||||
tri.append( [[(it); t1.enumerate();
|
||||
'wrap([(i,t)]){ t + t0[i].max(t0[i+1]) }]])
|
||||
}
|
||||
tri[0][0].println();
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
data:=File("triangle.txt").pump(List,fcn(s){ s.strip().split(" ").apply("toInt") });
|
||||
fcn f(x,y,z){ x + y.max(z) }
|
||||
fcn g(xs,ys){ Utils.zipWith(f,ys,xs,xs[1,*]); }
|
||||
data.reverse().reduce(g)[0].println();
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
lines:=File("triangle.txt").pump(List,fcn(s){ s.strip().split(" ").apply("toInt") });
|
||||
d:=lines[-1].copy();
|
||||
foreach row in ([lines.len()-2..0,-1]){
|
||||
d1:=d[1,*];
|
||||
l :=d[0];
|
||||
foreach i,u in (lines[row].enumerate()){
|
||||
d[i] = u + l.max(r:=d1[i]);
|
||||
l = r;
|
||||
}
|
||||
}
|
||||
println(d[0]);
|
||||
Loading…
Add table
Add a link
Reference in a new issue