blob: ba46db8640432de98c7b5615f0207995fa010fe6 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
r:*0:"day09"
/ strictly speaking, you need
/ g:{a:s[x;"("];b:s[*|a;")"];c:.:'s[*b;"x"]; $[#*b;((*a),(*/c)#*c#*|b;(*c)_*|b);(x;"")] }
s:{{(x;1_y)}.(0,*&x=y)_x}
g:{a:s[x;"("];b:s[*|a;")"];c:.:'s[*b;"x"]; ((*a),(*/c)#*c#*|b;(*c)_*|b) }
#*{#*|x}{(*x;""),'g[*|x]}/("";r)
/ 110346
g2:{a:s[x;"("];b:s[*|a;")"];c:.:'s[*b;"x"]; $[#*b;((#*a)+*|c*f2[(*c)#*|b];(*c)_(*|b));(#x;"")] }
f2:{*{#*|x}{v:g2[*|x];((*x)+*v;*|v)}/(0;x)}
n:f2[r]
,/$(_10000000!n%10000000;10000000!n) / ewwww
/ 10774309173
|