Jump to content

Find first missing positive: Difference between revisions

(→‎{{header|Quackery}}: added method.)
Line 969:
witheach [ task echo sp ]
</syntaxhighlight>
 
{{out}}
 
<pre>3 2 1</pre>
 
===Brute force===
 
Search for each integer. The largest the missing integer can be is one more than the number of items in the nest.
 
<syntaxhighlight lang="Quackery"> [ dup size
dup 1+ unrot
times
[ i^ 1+
over find
over found not if
[ dip
[ drop i^ 1+ ]
conclude ] ]
drop ] is task ( [ --> n )
 
' [ [ 1 2 0 ] [ 3 4 -1 1 ] [ 7 8 9 11 12 ] ]
 
witheach [ task echo sp ]</syntaxhighlight>
 
{{out}}
1,462

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.