-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy patha9.tt
37 lines (34 loc) · 957 Bytes
/
a9.tt
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
templates max
@: $(1);
$(2..last)... -> #
$@ !
<$@~..>
@: $;
end max
processor Game
@: {head: 1"1", tail: 1"1", ring: [1..2*$ -> 0]};
templates play
when <?($ mod 23 <=0>)> do
def newHead: [email protected] - 7;
def score: $ + [email protected]($newHead);
@Game.ring($newHead): [email protected]($newHead + 1);
..|@Game: {head: $newHead, tail: [email protected]};
$score !
otherwise
@Game.ring([email protected]+2): $;
..|@Game: {head: [email protected] + 2, tail: [email protected] + 1};
0 !
end play
end Game
templates game&{players:}
def ring: $ -> Game;
@: [ 1..$players -> 0 ];
1..$ -> #
$@ -> max !
<>
def player: (($ - 1) mod $players) + 1;
@($player): $ -> ring::play -> $ + $@($player);
end game
7114400 -> game&{players: 424} -> !OUT::write