programgames/lights-out/lights-out.xtl

source · imports lo: games/lights-out/Lamps.xtl

P : Int

value · line 8
P ← ˡᵒp̲resses @

s : Int

value · line 13
s ← ˡᵒn̲ew 0

x : Int

value · line 19
x ← ˡᵒs̲olve ˡᵒl̲ights s

q : Int

value · line 26
q ← 2 25 r̲eshape 0 1 1 1 0 1 0 1 0 1 1 1 0 1 1 1 0 1 0 1 0 1 1 1 0 1 0 1 0 1 1 0 1 0 1 0 0 0 0 0 1 0 1 0 1 1 0 1 0 1

t : Int

value · line 30
t ← s ˡᵒc̲lick 500 67.0

ᵘp̲ressAll : Int -> Int -> Int

function · line 32
ᵘp̲ressAll ← { s ks → 0 = t̲ally ks ? s◆ (s ˡᵒp̲ress f̲irst ks) ᵘp̲ressAll 1 d̲rop ks }

done : Int

value · line 33
done ← s ᵘp̲ressAll w̲here x

pic : Char

value · line 35
pic ← ⎕S̲HOW ˡᵒd̲raw done

ok : Unit

value · line 38
ok ← "0 = '+ r_/ (lo:l_ights s) lo:a_fter x" a̲ssert< "the solution turns every light off"
a̲ssert< expands to
({ @ → (0 = '+ r̲/ (ˡᵒl̲ights s) ˡᵒa̲fter x) ? @◆ ⎕E̲RR "assertion failed: 0 = '+ r_/ (lo:l_ights s) lo:a_fter x (the solution turns every light off) [games/lights-out/lights-out.xtl:38]"◆ @ } @)

ok : Unit

value · line 39
ok ← "1 = lo:s_tatus done" a̲ssert< "pressing the solution wins"
a̲ssert< expands to
({ @ → (1 = ˡᵒs̲tatus done) ? @◆ ⎕E̲RR "assertion failed: 1 = lo:s_tatus done (pressing the solution wins) [games/lights-out/lights-out.xtl:39]"◆ @ } @)

ok : Unit

value · line 40
ok ← "0 = '+ r_/ r_avel (q '+ '* i_nner lo:p_resses @) m_od 2" a̲ssert< "the quiet patterns change nothing"
a̲ssert< expands to
({ @ → (0 = '+ r̲/ r̲avel (q '+ '× i̲nner ˡᵒp̲resses @) m̲od 2) ? @◆ ⎕E̲RR "assertion failed: 0 = '+ r_/ r_avel (q '+ '* i_nner lo:p_resses @) m_od 2 (the quiet patterns change nothing) [games/lights-out/lights-out.xtl:40]"◆ @ } @)