Generate random numbers without repeating a value: Difference between revisions

Added XPL0 example.
m (→‎{{header|R}}: Syntax highlighting.)
(Added XPL0 example.)
Line 722:
16 15 5 10 1 13 17 6 8 9 20 3 14 11 18 2 19 12 4 7
17 6 10 13 20 5 3 11 18 12 16 2 14 15 19 9 8 1 4 7
</pre>
 
=={{header|XPL0}}==
<lang XPL0>int Set, R;
[Set:= 0;
repeat R:= Ran(20);
if (Set & 1<<R) = 0 then
[Set:= Set ! 1<<R;
IntOut(0, R+1); ChOut(0, ^ )];
until Set = $F_FFFF;
]</lang>
 
{{out}}
Example outputs:
<pre>
14 5 1 20 18 16 2 3 19 6 4 13 7 11 17 10 8 12 15 9
18 19 8 11 9 6 5 4 12 2 3 1 16 15 14 7 20 13 10 17
5 11 17 19 2 14 20 18 9 16 1 15 4 8 12 10 13 6 7 3
17 11 13 20 3 7 8 9 19 5 4 18 15 14 16 12 1 2 6 10
</pre>
772

edits