Last active
October 2, 2016 07:10
-
-
Save dikarel/043b7a80bf5908db3f2833fdddbd69fa to your computer and use it in GitHub Desktop.
Helper classes for HackerRank
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
# Reads lines from stdin and run specified function | |
main = (done) -> | |
lines = [] | |
readline = require 'readline' | |
readline.createInterface input: process.stdin | |
.on 'line', (line) -> lines.push line | |
.on 'close', -> done lines | |
# Minified one-liner | |
main=(d)->l=[];require('readline').createInterface(input:process.stdin).on('line',(i)->l.push i).on('close',->d l) | |
# Example | |
main (lines) -> | |
console.log 'My lines are', lines |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment