Skip to content

Instantly share code, notes, and snippets.

@autotaker
Created December 22, 2015 07:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save autotaker/764a6d75741e2f807bc5 to your computer and use it in GitHub Desktop.
Save autotaker/764a6d75741e2f807bc5 to your computer and use it in GitHub Desktop.
let rec read_ints acc =
let r = try Some (read_int()) with
End_of_file -> None in
match r with
Some(v) -> read_ints (v::acc)
| None -> List.rev acc
let output_ints = List.iter (fun v ->
print_int v;
print_newline())
let main _ =
let ps = read_ints [] in
let start_t = Sys.time() in
Printf.fprintf stderr "length: %d\n" (List.length ps);
let qs = List.sort compare ps in
let end_t = Sys.time() in
Printf.fprintf stderr "Sorting: %.5fs\n" (end_t -. start_t);
output_ints qs;;
main();;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment