Number reversal game: Difference between revisions
Add APL
Not a robot (talk | contribs) (Add 8080 assembly) |
Not a robot (talk | contribs) (Add APL) |
||
Line 300:
</lang>
=={{header|APL}}==
{{works with|Dyalog APL}}
<lang APL>∇numrev;list;in;swaps
list←{9?9}⍣{⍺≢⍳9}⊢⍬
swaps←0
read:
swaps+←1
in←{⍞←⍵⋄(≢⍵)↓⍞}(⍕list),': swap how many? '
list←⌽@(⍳⍎in)⊢list
→(list≢⍳9)/read
⎕←(⍕list),': Congratulations!'
⎕←'Swaps:',swaps
∇</lang>
{{out}}
<pre>8 7 2 6 5 3 1 9 4: swap how many? 8
9 1 3 5 6 2 7 8 4: swap how many? 9
4 8 7 2 6 5 3 1 9: swap how many? 3
7 8 4 2 6 5 3 1 9: swap how many? 2
8 7 4 2 6 5 3 1 9: swap how many? 8
1 3 5 6 2 4 7 8 9: swap how many? 4
6 5 3 1 2 4 7 8 9: swap how many? 6
4 2 1 3 5 6 7 8 9: swap how many? 4
3 1 2 4 5 6 7 8 9: swap how many? 3
2 1 3 4 5 6 7 8 9: swap how many? 2
1 2 3 4 5 6 7 8 9: Congratulations!
Swaps: 10</pre>
=={{header|Arturo}}==
|