32
1
Input:
A list of integers
Output:
Put each digit (and the minus sign) in its own lane, in the order -0123456789
, ignoring any duplicated digits.
Example:
Input: [1,729,4728510,-3832,748129321,89842,-938744,0,11111]
Output:
-0123456789 <- Added as clarification only, it's not part of the output
1
2 7 9
012 45 78
- 23 8
1234 789
2 4 89
- 34 789
0
1
Challenge rules:
- Any duplicated digits in the number are ignored.
- I/O can be in any reasonable format. Input can be as a list/array of strings or character-array. Output can be as a list of strings, characters, character-matrix, etc.
- Trailing spaces are optional.
- Any amount of leading or trailing new-lines are optional (but not in between lines).
- Input will always contain at least one integer
- You'll have to support an integer range of at least
-2,147,483,648
though2,147,483,647
(32-bit). - The input-list will never contain
-0
,00
(or more than two zeroes), or integers with leading zeroes (i.e.012
). - If you language uses a different symbol for negative numbers (like an upper
¯
), you are also allowed to use that instead, as long as it's consistent. - You are allowed to have a space delimiter between digits (so a line without 5 or 8 can be
- 0 1 2 3 4 6 7 9
instead of-01234 67 9
), as long as it's consistent (and therefore there should also be a space between-
and0
).
General rules:
- This is code-golf, so shortest answer in bytes wins.
Don't let code-golf languages discourage you from posting answers with non-codegolfing languages. Try to come up with an as short as possible answer for 'any' programming language. - Standard rules apply for your answer, so you are allowed to use STDIN/STDOUT, functions/method with the proper parameters and return-type, full programs. Your call.
- Default Loopholes are forbidden.
- If possible, please add a link with a test for your code.
- Also, please add an explanation if necessary.
Test cases:
Input: [1,729,4728510,-3832,748129321,89842,-938744,0,11111]
Output:
1
2 7 9
012 45 78
- 23 8
1234 789
2 4 89
- 34 789
0
1
Input: [4,534,4,4,53,26,71,835044,-3559534,-1027849356,-9,-99,-3459,-3459,-94593,-10234567859]
Output:
4
345
4
4
3 5
2 6
1 7
0 345 8
- 345 9
-0123456789
- 9
- 9
- 345 9
- 345 9
- 345 9
-0123456789
Input: [112,379,-3,409817,239087123,-96,0,895127308,-97140,923,-748]
Output:
12
3 7 9
- 3
01 4 789
0123 789
- 6 9
0
123 5 789
-01 4 7 9
23 9
- 4 78
Input: [-15,-14,-13,-12,-11,10,-9,-8,-7,-5,-4,-3,-1,0,9,100,101,102,1103,104,105,106,116,-12345690]
Output:
- 1 5
- 1 4
- 1 3
- 12
- 1
-01
- 9
- 8
- 7
- 5
- 4
- 3
- 1
0
9
01
01
012
01 3
01 4
01 5
01 6
1 6
-0123456 9
Input: [99,88,77,66,55,44,33,22,11,10,0,0,0,-941]
Output:
9
8
7
6
5
4
3
2
1
01
0
0
0
- 1 4 9
Would spaces between the digits be permitted in the output? – Shaggy – 2018-03-27T11:33:54.120
Can we use upper minus
¯
instead of-
? – Uriel – 2018-03-27T11:33:56.123The missing digits would still be replaced with spaces so, in your example, there would be 3 spaces between 4 & 6 and 7 & 9:
"-0 1 2 3 4 <space> 6 7 <space> 9"
(Multiple spaces get collapsed in comments, for some reason) – Shaggy – 2018-03-27T11:43:31.2501I was hoping to sneak that one past you! :D Well-spotted! – Shaggy – 2018-03-27T11:48:03.227
can I take the inputs as separate inputs and a count of the amount of them? – dzaima – 2018-03-27T13:54:54.030
@dzaima Sure, why not. – Kevin Cruijssen – 2018-03-27T13:58:30.073
Words in their lanes? - Another decent challenge spin-off idea. Even letters in their lanes would be cool. – Magic Octopus Urn – 2018-03-27T22:42:14.420
May we place negative signs on the far right? Especially relevant if using a Unicode symbol which comes after
9
. – Adám – 2018-03-28T11:05:30.410@Adám Sorry but no, the
-
(or any other character representing-
) must be on the left. – Kevin Cruijssen – 2018-03-28T11:07:16.6171related – streetster – 2018-03-28T18:29:58.850
@streetster Ah, I remember that challenge. It's indeed pretty similar. Btw, why did you link to your answer instead of the challenge itself? ;) – Kevin Cruijssen – 2018-03-28T18:32:45.307
Oops, was browsing through my answers to find the challenge, wasn't paying enough attention to the actual url! – streetster – 2018-03-28T21:01:48.893
@Adám Well, the minus goes to the left, doesn't it? :P – Erik the Outgolfer – 2018-03-30T12:41:35.410