-
Notifications
You must be signed in to change notification settings - Fork 0
/
lambdaman19.rs
51 lines (43 loc) · 1.61 KB
/
lambdaman19.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
use icfp::expr::*;
pub fn main() -> anyhow::Result<()> {
//oblique square fractal thing
// f(n):
// if n = 0 then return
// let g s :=
// walk n in direction (take 1 s)
// f(n/2)
// walk n in direction (drop 1 s)
// concat(g("UD"),
// concat(g("DU"),
// concat(g("LR"), g("RL"))))
let walk =
rec("f",
lam("n",
cond(
equ(vuse("n"), litnum(0)),
litstr(""),
let1(
"g",
lam("s",
concat(
sapp_spine(
repeat_of(take(litnum(1), vuse("s"))),
vec![vuse("n")]),
concat(
sapp(vuse("f"),
div(vuse("n"), litnum(2))),
sapp_spine(
repeat_of(drop(litnum(1), vuse("s"))),
vec![vuse("n")])))),
concat(
sapp(vuse("g"), litstr("UD")),
concat(
sapp(vuse("g"), litstr("DU")),
concat(
sapp(vuse("g"), litstr("LR")),
sapp(vuse("g"), litstr("RL")))))))));
let e = concat(litstr("solve lambdaman19 "),
sapp(walk, litnum(64)));
println!("{e}");
Ok(())
}