Data update
This commit is contained in:
parent
29a5eea0d4
commit
5c1bb7bfa9
2011 changed files with 35081 additions and 3229 deletions
60
Task/Flipping-bits-game/Quackery/flipping-bits-game.quackery
Normal file
60
Task/Flipping-bits-game/Quackery/flipping-bits-game.quackery
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
[ [] over times
|
||||
[ over [] swap times
|
||||
[ 2 random join ]
|
||||
nested join ]
|
||||
nip ] is makeboard ( n --> [ )
|
||||
|
||||
[ [] swap witheach [ not join ] ] is invert ( [ --> [ )
|
||||
|
||||
[ 2dup peek invert unrot poke ] is fliprow ( [ n --> [ )
|
||||
|
||||
[ dip transpose fliprow transpose ] is flipcolumn ( [ n --> [ )
|
||||
|
||||
[ dup
|
||||
[ dup size dup * times
|
||||
[ dup size random
|
||||
2 random iff
|
||||
fliprow
|
||||
else flipcolumn ]
|
||||
2dup != until ]
|
||||
nip ] is mix ( [ --> [ )
|
||||
|
||||
[ say " "
|
||||
dup size times
|
||||
[ sp i^ char a + emit ]
|
||||
witheach
|
||||
[ cr sp i^ echo say ":"
|
||||
witheach
|
||||
[ sp echo ] ] ] is display ( [ --> )
|
||||
|
||||
[ cr $ "a..., or 0...: "
|
||||
input $ "." join
|
||||
trim 0 peek lower
|
||||
2dup char a rot over +
|
||||
within iff
|
||||
[ nip char a -
|
||||
' flipcolumn ]
|
||||
done
|
||||
2dup char 0 rot over +
|
||||
within iff
|
||||
[ nip char 0 -
|
||||
' fliprow ]
|
||||
done
|
||||
drop again ] is getmove ( n --> n x )
|
||||
|
||||
[ 0 temp put
|
||||
makeboard
|
||||
dup mix
|
||||
[ say "Moves: "
|
||||
temp share echo cr
|
||||
1 temp tally
|
||||
2dup swap
|
||||
say "Target" cr
|
||||
display cr cr
|
||||
say "Current" cr
|
||||
display cr
|
||||
dup size getmove do cr
|
||||
2dup = until ]
|
||||
2drop
|
||||
temp take
|
||||
say "Moves taken: " echo ] is flipbits ( n --> )
|
||||
19
Task/Flipping-bits-game/Uiua/flipping-bits-game.uiua
Normal file
19
Task/Flipping-bits-game/Uiua/flipping-bits-game.uiua
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
S ← 9
|
||||
Fr ← ⊙◌⍜⊡¬⊙.
|
||||
Fc ← ⊙◌⍉Fr⊙(⍉.)
|
||||
Shuffle ← ⍥(⟨Fr|Fc⟩<0.5⚂ ⌊×S⚂)×3S
|
||||
T ← Shuffle ↯S_S 0 # Target setup. Omit `Shuffle` for plain grid.
|
||||
D ← /+/+⌵-T
|
||||
|
||||
# Could use A*, but this is easily solved without it.
|
||||
# ◌astar(⊂⊃(≡Fr|≡Fc)⇡S¤|÷S D|=0D)
|
||||
⟜[∘] Shuffle T # Shuffle and keep a copy for the output.
|
||||
◌⍢(
|
||||
|
||||
⊂⊃(≡Fr|≡Fc)⇡S¤ # All neighbours.
|
||||
⊚=/↧.≡D. # Find min dist, get indices that give that.
|
||||
⊡⊢ # Pick first one. ⊡(⊡⌊×⚂⧻.) to pick at random.
|
||||
⊙⊂. # Save a copy of the new state.
|
||||
| ≠0D
|
||||
)
|
||||
⟜($"_ steps."-1⧻)⇌
|
||||
Loading…
Add table
Add a link
Reference in a new issue