Closed weichenlin closed 8 years ago
The problem asks to print the number of new lines, specifically \n
's so it would be the same as wc
, so with you're input it should also be 1. Is there a problem?
yes there is problem. if the correct answer is 1, then the solution in learnyouphp/exercises/my-first-io/solution is wrong. because explode "line1\nline2" by newline will return an array contains 2 element.
when running "learnyouphp verify", the generated text file has no new line at end, so the solution always expected a wrong line number.
sorry, please ignore the "newline at end" part. if there are newline at end like "line1\nline2\n", explode will return a 3 elements array. it's still wrong.
Indeed it looks incorrect - would you mind submitting a PR?
Sent from my iPhone
On 28 Aug 2016, at 02:09, weichenlin notifications@github.com<mailto:notifications@github.com> wrote:
yes there is problem. if the correct answer is 1, then the solution in learnyouphp/exercises/my-first-io/solution is wrong. because explode "line1\nline2" by newline will return an array contains 2 element.
when running "learnyouphp verify", the generated text file has no new line at end, so the solution always expected a wrong line number.
You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/php-school/learn-you-php/issues/63#issuecomment-242947997, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ACr76pDOGsFTp3FWVShEq1FLAEdVSICjks5qkNGsgaJpZM4Jux8A.
here is my PR: #64
Fixed with #64
the exercise ask for the number of newlines, but what is the correct answer for strings that without a newline at end? for example, "line1\nline2" should be count as 2 lines, but it actually has only 1 newline char. and the funny part is "wc -l" also show "1" for this case.