Skip to content

Instantly share code, notes, and snippets.

@AndreasHassing
Created April 28, 2019 06:58
Show Gist options
  • Select an option

  • Save AndreasHassing/62b3fd51d5e4f7a16c6e5b410355673c to your computer and use it in GitHub Desktop.

Select an option

Save AndreasHassing/62b3fd51d5e4f7a16c6e5b410355673c to your computer and use it in GitHub Desktop.
Solve HackerRank problems with F# (FSharp)
/// Read all lines from stdin into an array of lines.
let lines = stdin.ReadToEnd().Split('\n')
// Now, all(?) problems on HackerRank can be solved using the `lines` binding.
// If you perform `stdin.ReadLine()` before the call to `stdin.ReadToEnd()` (to get a N or X variable, for instance),
// it will not be picked up by `stdin.ReadToEnd()`, yielding the expected behavior.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment