44
4
Introduction
OEIS sequence A127421 is the sequence of numbers whose decimal expansion is a concatenation of 2 consecutive increasing non-negative numbers. Put simply, every number in the sequence is formed by putting together n with n+1 for some non-negative, integer value of n. The first several terms are:
1, 12, 23, 34, 45, 56, 67, 78, 89, 910, 1011, 1112, 1213, 1314, 1415, 1516, 1617, 1718, 1819, 1920, 2021, 2122, 2223, 2324, 2425, 2526, 2627, 2728, 2829, 2930, 3031, 3132, 3233, 3334, 3435, 3536, 3637, 3738, 3839, 3940, 4041, 4142, 4243, 4344, 4445, 4546, …
Challenge
Given a single positive integer n, print the first n entries of OEIS sequence A127421 in increasing order.
- Input and output can be in any acceptable format. Strings or numbers are fine for output.
- Leading zeroes are not permitted.
- Either a full program or function is permitted.
- For the purposes of this challenge, n will be positive and under 100.
- Standard loopholes are disallowed by default.
- This question is code golf, so lowest byte-count wins.
Here is some sample input and output:
1 => 1 2 => 1, 12 3 => 1, 12, 23 10 => 1, 12, 23, 34, 45, 56, 67, 78, 89, 910
If you have any questions, don't hesitate to ask. Good luck.
P.S this is my first challenge, so hopefully this all makes sense.
EDIT: Removed output restriction to allow numbers or strings.
1Can it be 0 indexed? – Jo King – 2018-07-04T01:09:26.330
1@Jo King No. 1 should refer to the first iteration of the sequence as per the challenge spec. – Amphibological – 2018-07-04T01:14:16.000
4No-one's said it yet, but welcome to PPCG! Nice first question, not too hard, yet not completely trivial either, and there's a number of different approaches – Jo King – 2018-07-04T01:40:56.073
@Jo King Thanks, I'm glad you liked it. – Amphibological – 2018-07-04T01:41:53.140
Do the outputs have to be in order? Can we mix strings and numbers? – xnor – 2018-07-04T02:56:57.490
Can the output be space-separated? – xnor – 2018-07-04T03:07:02.083
@xnor, yes, they have to be in order. You can mix strings and numbers freely, and space separated is fine. – Amphibological – 2018-07-04T03:20:00.973
3After 7 days, I will accept the shortest answer which meets all these criteria. Why is there a need for the challenge to end? – Erik the Outgolfer – 2018-07-04T09:13:26.097
2
Nowadays we tend to not accept an answer, because it discourages further posting of answers. I suppose you take old challenges as a model (which is also discouraged) See things-to-avoid-when-writing-challenges
– user202729 – 2018-07-04T09:21:50.910Ok, @user202729, do you think I should just remove that criterion? – Amphibological – 2018-07-04T13:10:48.957
1@Amphibological It's a personal choice; some of us still accept answers. There's no need to specify a date though, and I wouldn't accept while the challenge is still getting more answers. – Dennis – 2018-07-04T13:20:22.473
2@Dennis Ok, i'll remove the date from the challenge; maybe I'll accept when no more new answers are coming. – Amphibological – 2018-07-04T13:41:29.520
1Is
01
an acceptable output for the first member of the sequence? – Giuseppe – 2018-07-04T15:04:12.257@Guiseppe, No. There should be no leading zeroes. – Amphibological – 2018-07-04T15:13:01.197
@user202729 which other order? I'm not quite sure what you mean. – Amphibological – 2018-07-04T16:01:39.300
@user202729 No. The order should be the same as the sample output. – Amphibological – 2018-07-04T16:04:40.600