-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path21.bqn
57 lines (51 loc) · 1.46 KB
/
21.bqn
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
52
53
54
55
56
57
While ← {𝕩{𝔽⍟𝔾∘𝔽_𝕣_𝔾∘𝔽⍟𝔾𝕩}𝕨@}´
a‿b ← 1‿3 # positions
p‿q ← 0‿0 # scores
rolls ← 0
die ← 0
Roll ← {𝕊: rolls +↩ 1 ⋄ die ↩ 1+100|die}
Turn ← {𝕊 pos: 1+10|1-˜pos + (Roll @) + (Roll @) + (Roll @)}
Step ← {𝕊:
a Turn↩
p +↩ a
p < 1000 ? b Turn↩ ⋄ q +↩ b; @
}
While {𝕤 ⋄ 1000>p⌈q}‿{𝕤 ⋄ Step @}
•Show rolls×p⌊q
# star 2: completely different :D
state1 ← 1⌾⊑10‿31⥊0
win ← (10‿21⥊0)∾˘10‿10⥊1
MultiverseRoll ← {(¯1⌽𝕩)+(¯2⌽𝕩)+(¯3⌽𝕩)}
MultiverseStep ← {𝕊 st‿w:
st ↩ >{»⍟(𝕩+1) 𝕩⊏MultiverseRoll⍟3 st}¨↕10
w ∾↩ +´⥊win×st
(st׬win)‿w
}
TurnsToWin ← {1⊑MultiverseStep⍟11 ((1-𝕩)⌽state1)‿⟨⟩}
CountWins ← {𝕊 as‿bs:
a←b←i←0
p←1
While {𝕤 ⋄ i<11}‿{𝕤
a +↩ p × i⊑as
p ↩ (p×27)-i⊑bs
i +↩ 1
}
p↩1
i↩0
While {𝕤 ⋄ i<11}‿{𝕤
p ↩ (27×p) - i⊑as
b +↩ p × i⊑bs
i +↩ 1
}
a‿b
}
•Show ⌈´CountWins (TurnsToWin 1)‿(TurnsToWin 3)
# golfed star2
n←(10‿21⥊0)∾˘10‿10⥊1
R←{(¯1⌽𝕩)+(¯2⌽𝕩)+(¯3⌽𝕩)}
M←{𝕊s‿w:s↩>{»⍟(𝕩+1)𝕩⊏R⍟3 s}¨↕10⋄(s׬n)‿(w∾(+´⥊n×s))}
W←{1⊑M⍟11((1-𝕩)⌽1⌾⊑10‿31⥊0)‿⟨⟩}
C←{p𝕊⟨0⟩:0;𝕨∾((27×𝕨)-⊑𝕩)𝕊1↓𝕩}
T←{+´𝕨×1 C𝕩}
S←{((¯1⌽𝕩)T𝕨)⌈𝕨T𝕩}
S´W¨1‿3