40
6
Given a string as input, output a number of whitespace characters (0x0A and 0x20) equal to the length of the string.
For example, given the string Hello, World!
your code would need to output exactly 13 whitespace characters and nothing else. These can be any mix of spaces and newlines.
Your code should not output any additional trailing newlines or spaces.
Testcases:
Input -> Amount of whitespace to output
"Hello, World!" -> 13
"Hi" -> 2
" Don't
Forget about
Existing
Whitespace! " -> 45
"" -> 0
" " -> 13
"
" -> 1
Scoring:
This is code-golf so fewest bytes wins!
1I don't get what you mean with that “0x0A”. Where should that be output? Should that be kept, so “a␠b␊c” becomes “␠␠␠␊␠”? – manatwork – 2017-05-25T12:56:14.727
1@manatwork
0x0A
and0x20
are the hexadecimal values for the Newline and Space characters respectively – Skidsdev – 2017-05-25T12:58:45.4371“output a number of whitespace characters (0x0A and 0x20)” – Where in the output should those newline characters be? – manatwork – 2017-05-25T13:00:40.333
3
These can be any mix of spaces and newlines
Your output can be any mix of spaces and newlines, you can just output spaces if you want, like everyone else, or you can just output newlines. It's up to you – Skidsdev – 2017-05-25T13:05:50.8601Got it. Thanks. – manatwork – 2017-05-25T13:06:56.037
1Can we assume the input will only have printable characters? – Luis Mendo – 2017-05-25T13:30:55.200
@LuisMendo yes you can. – Skidsdev – 2017-05-25T13:51:11.660
Related – alephalpha – 2017-05-25T14:21:08.010
Can we replace existing line breaks with spaces or do we need to retain line breaks? – Thomas Ward – 2017-05-27T18:55:07.367
@ThomasWard you don't need to retain anything but the length of the input string – Skidsdev – 2017-05-28T14:33:21.463
If we print the correct number of spaces, is a trailing newline acceptable (as this is how the language outputs) – FlipTack – 2017-10-27T15:38:43.237