hash.mlish (589B)
1 #lang s-exp "../../mlish.rkt" 2 (require "../rackunit-typechecking.rkt") 3 4 (define (main [argv : (Vector String)] -> Int) 5 (let* ([n (string->number (vector-ref argv 0))] 6 [hash 7 (for/hash ([i (in-range n)]) 8 (let ([j (add1 i)]) 9 (tup (number->string j 16) j)))]) 10 (for/sum ([i (in-range 1 (add1 n))] 11 #:when 12 (hash-has-key? hash (number->string i))) 13 1))) 14 15 (check-type (main (vector "2000")) : Int -> 799) 16 17 (check-type (main (vector "20000")) : Int -> 4999) 18 19 (check-type (main (vector "200000")) : Int -> 30999)