Skip to content

Commit

Permalink
Merge pull request #193 from workshopper/fix/lines-problem
Browse files Browse the repository at this point in the history
refactor(problems): update LINES problem definition
  • Loading branch information
kalinchernev authored Apr 5, 2017
2 parents f11c997 + cd7541f commit b72ac0d
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions problems/lines/problem.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@ Your program should output:
three
FOUR

You can use the `split` module to split input by newlines. For example:
Even though it's not obligatory, you can use the `split` module
to split input by newlines. For example:

var split = require('split');
var through2 = require('through2');
process.stdin
.pipe(split())
.pipe(through2(function (line, _, next) {
Expand All @@ -26,17 +28,22 @@ You can use the `split` module to split input by newlines. For example:
}))
;

`split` will buffer chunks on newlines before you get them. In the previous
example, we will get separate events for each line even though all the data
`split` will buffer chunks on newlines before you get them. With example
above, we will get separate events for each line even though all the data
probably arrives on the same chunk:

$ echo -e 'one\ntwo\nthree' | node split.js
'one'
'two'
'three'

Your own program should use `split` in this way, but you should transform the
input and pipe the output through to `process.stdout`.
Your own program could use `split` in this way, and you should transform the
input and pipe the output through to `process.stdout`. Keep in mind that,
if you decide to use this technique, `split2` might be actually needed,
depending on the versions of the other dependencies.

You are free to solve the challenge without `split` module. In this case,
you would have to add a new line after each line to have a passing match.

Make sure to `npm install split through2` in the directory where your solution
file lives.

0 comments on commit b72ac0d

Please sign in to comment.