16
4
Given 2 inputs (m=minimum starting id, n=number of ids), generate a sequential list of ids, starting at >=m, made up of the digits 0-9 where no 2 contiguous numbers are the same, e.g. 1232 is ok, 1233 is not (contains 2 '3's next to each other).
Example
for m=985, n=6, below shows what ids would be generated/skipped
...
985 - ok, 1st
986 - ok, 2nd
987 - ok, 3rd
# skip 0988 (contains '88')
989 - ok, 4th
# Skip 099x (contains '99')
# Skip 100x (contains '00')
1010 - ok, 5th
# Skip 1011 (contains '11')
1012 - ok, 6th
...
Output
Each ID should be printed on a new line, as for the above sequence:
985
986
987
989
1010
1012
Rules
Standard code-golf rules, lowest byte count wins
14Welcome to PPCG! Each ID should be printed on a new line I highly discourage explicitly restricting the output to a particular format. – Erik the Outgolfer – 2018-02-28T15:51:04.243
1Test case: an input where
m
has consecutive identical digits. It shouldn't cause anybody to trip up but it'll be nice to have for people to consider. Say,m=988
,n=3
. – Giuseppe – 2018-02-28T15:55:45.6373Is it okay to return a list of IDs (i.e. a 1-D array of integers), instead of printing to stdout? – JungHwan Min – 2018-02-28T15:56:21.407
Wait a minute... don't immediately answer challenges that has something that should/may/can be fixed (in this case, the strict output format) – user202729 – 2018-02-28T15:59:29.207
As, if the rules are kept they're bad, and if they're changed existing answers are invalidated (suboptimal). – user202729 – 2018-02-28T16:00:36.897
4@user202729 The answers won't be invalidated in this case. – Erik the Outgolfer – 2018-02-28T16:07:31.027
@EriktheOutgolfer But suboptimal. Doing more than what the challenge requires is invalid. – user202729 – 2018-02-28T16:21:47.440
2@user202729 That doesn't make answers invalid... If anything, the answers will either get fixed or they're just following the old rules. – totallyhuman – 2018-02-28T16:27:22.843
1@EriktheOutgolfer - First time on here, why is specifying the output format discouraged? Many of the code golf questions I've looked at are specifically about outputting information in a certain format (e.g. output as a square / christmas tree etc.) – beirtipol – 2018-02-28T17:11:33.753
2
@beirtipol Outputting in a very specific format is discouraged for challenges whose main point is not the output. [tag:ascii-art] challenges are all about outputting things, that's why they are allowed to do it. But requiring us to join the results by newlines adds nothing to the challenge, but rather adds unnecessary bytes to the submissions. See Things to avoid when writing challenges.
– Mr. Xcoder – 2018-02-28T17:16:38.343Aha, understood. Will note it for next time. Looking at some of the answers below, I think that changing the question to remove this would be unfair? – beirtipol – 2018-02-28T17:19:57.603
3For the ones written in golfing languages changing the rule to allow more output formats wouldn't affect them. For the rest you can just leave a comment saying the output format isn't restricted anymore. – Brad Gilbert b2gills – 2018-02-28T17:42:46.993
Can
n
be0
? – Ton Hospel – 2018-02-28T20:06:54.427@beirtipol So is the output restricted or not? Can I print the numbers as strings enclosed in quotes (
"989"
...)? – Asone Tuhid – 2018-02-28T20:20:44.187I'll leave output restricted as is. Don't think I should change the rules now after submission – beirtipol – 2018-03-01T11:46:35.840
@TonHospel - yes, n could be 0 – beirtipol – 2018-03-01T11:46:59.547