Created
November 27, 2010 01:29
-
-
Save samueltardieu/717457 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
USING: hash-sets kernel locals math sequences sets ; | |
IN: acm | |
:: add ( set n -- newset ) | |
HS{ } clone :> newset | |
set members [ n [ + ] [ - ] 2bi [ newset adjoin ] bi@ ] each newset ; | |
:: least ( n -- x ) | |
HS{ 0 } 1 [ [ add n over in? ] keep swap ] [ 1 + ] until nip ; | |
( scratchpad ) 12 least . | |
7 | |
( scratchpad ) 21 least . | |
6 | |
( scratchpad ) 100000 least . | |
447 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment