Version 2 by Olve Maudal
on Sep 04, 2009 13:47.

compared with
Current by Olve Maudal
on Sep 04, 2009 13:48.

Key
This line was removed.
This word was removed. This word was added.
This line was added.

Changes (4)

View Page History
The unsplice exercise is very simple. Your task is to write a function that removes all occurences of the two characters \ (backslash) and \n (newline) when they occur consecutively in an array of chars.

Example 1: Before: {{abc\\\ndef}} {{abc\\\ndef}} After: {{abcdef}}

The unsplice operation has removed one occurence of the backslash newline pair.

Example 2: Before: {{abc\\d\nef}} {{abc\\d\nef}} After: {{abc\\d\nef}} {{abc\\d\nef}}

The unspliced version is unchanged because the backslash and newline characters are not consecutive.

Example 3: Before: {{abc\n\\def}} {{abc\n\\def}} After: {{abc\n\\def}} {{abc\n\\def}}

The unspliced version is unchanged because the backslash and newline characters are in the wrong order.

Example 4: Before: {{abc\\\\\n\ndef}} After: {{abc\\\ndef}} {{abc\\\ndef}}

The unspliced operation has removed one occurence of the backslash newline pair. Note that another occurence of the backslash newline pair remains. This is because the unsplice operation is "one-pass only".