4fd800b3a8 2011-02-23 kinaba: (**************************************************************************** 4fd800b3a8 2011-02-23 kinaba: * Written in 4fd800b3a8 2011-02-23 kinaba: * Alice 1.4 4fd800b3a8 2011-02-23 kinaba: * http://www.ps.uni-saarland.de/alice/ 4fd800b3a8 2011-02-23 kinaba: ****************************************************************************) 4fd800b3a8 2011-02-23 kinaba: 4fd800b3a8 2011-02-23 kinaba: fun solve (n : int, k : int) : bool = 4fd800b3a8 2011-02-23 kinaba: let 4fd800b3a8 2011-02-23 kinaba: open Word 4fd800b3a8 2011-02-23 kinaba: infix 5 << andb 4fd800b3a8 2011-02-23 kinaba: val mask = (0wx1 << fromInt n) - 0wx1 4fd800b3a8 2011-02-23 kinaba: in 4fd800b3a8 2011-02-23 kinaba: (fromInt k) andb mask = mask 4fd800b3a8 2011-02-23 kinaba: end 4fd800b3a8 2011-02-23 kinaba: 4fd800b3a8 2011-02-23 kinaba: fun main () = 4fd800b3a8 2011-02-23 kinaba: let 4fd800b3a8 2011-02-23 kinaba: fun readLine () = 4fd800b3a8 2011-02-23 kinaba: case TextIO.inputLine TextIO.stdIn of 4fd800b3a8 2011-02-23 kinaba: | NONE => [] 4fd800b3a8 2011-02-23 kinaba: | SOME(s) => map Int.fromString (String.tokens (fn x => x = #" ") s) 4fd800b3a8 2011-02-23 kinaba: 4fd800b3a8 2011-02-23 kinaba: fun parseOne c = 4fd800b3a8 2011-02-23 kinaba: case readLine() of 4fd800b3a8 2011-02-23 kinaba: | [SOME n, SOME k] => (c, (n, k)) 4fd800b3a8 2011-02-23 kinaba: | _ => assert false 4fd800b3a8 2011-02-23 kinaba: 4fd800b3a8 2011-02-23 kinaba: fun spawn solveOne (c, inp) = 4fd800b3a8 2011-02-23 kinaba: (c, solve inp) 4fd800b3a8 2011-02-23 kinaba: 4fd800b3a8 2011-02-23 kinaba: fun printOne (c, ans) = 4fd800b3a8 2011-02-23 kinaba: print ("Case #" ^ Int.toString (c+1) ^ ": " ^ (if ans then "ON" else "OFF") ^ "\n") 4fd800b3a8 2011-02-23 kinaba: in 4fd800b3a8 2011-02-23 kinaba: case readLine () of 4fd800b3a8 2011-02-23 kinaba: | [SOME t] => List.app printOne (List.map solveOne (List.tabulate (t, parseOne))) 4fd800b3a8 2011-02-23 kinaba: | _ => assert false 4fd800b3a8 2011-02-23 kinaba: end 4fd800b3a8 2011-02-23 kinaba: 4fd800b3a8 2011-02-23 kinaba: do main () 4fd800b3a8 2011-02-23 kinaba: do OS.Process.exit 0