Jumping Numbers
$begingroup$
A jumping number is defined as a positive number n which all pairs of consecutive decimal digits differ by 1. Also, all single digit numbers are considered jumping numbers. eg. 3, 45676, 212 are jumping numbers but 414 and 13 are not. The difference between 9 and 0 is not considered as 1
The challenge
Create a program that output one of the following results:
- Given an input
n
output the firstn
jumping numbers. - Given an input
n
output then
th term of the sequence.
Note
- Any valid I/O format is allowed
- 1-index or 0-index is allowed (please specify)
Here are some jumping numbers:
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 21, 23, 32, 34, 43, 45, 54, 56, 65, 67, 76, 78, 87, 89, 98, 101, 121, 123, 210, 212, 232, 234, 321, 323, 343, 345, 432, 434, 454, 456, 543, 545, 565, 567, 654, 656, 676, 678, 765, 767, 787, 789, 876, ...
This is also A033075
code-golf number sequence
$endgroup$
add a comment |
$begingroup$
A jumping number is defined as a positive number n which all pairs of consecutive decimal digits differ by 1. Also, all single digit numbers are considered jumping numbers. eg. 3, 45676, 212 are jumping numbers but 414 and 13 are not. The difference between 9 and 0 is not considered as 1
The challenge
Create a program that output one of the following results:
- Given an input
n
output the firstn
jumping numbers. - Given an input
n
output then
th term of the sequence.
Note
- Any valid I/O format is allowed
- 1-index or 0-index is allowed (please specify)
Here are some jumping numbers:
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 21, 23, 32, 34, 43, 45, 54, 56, 65, 67, 76, 78, 87, 89, 98, 101, 121, 123, 210, 212, 232, 234, 321, 323, 343, 345, 432, 434, 454, 456, 543, 545, 565, 567, 654, 656, 676, 678, 765, 767, 787, 789, 876, ...
This is also A033075
code-golf number sequence
$endgroup$
$begingroup$
Is this 0 or 1 Indexed?
$endgroup$
– Taylor Scott
13 hours ago
1
$begingroup$
@TaylorScott The sequence consists in only positive numbers. If you mean the inputn
then it is up to you.
$endgroup$
– Luis felipe De jesus Munoz
13 hours ago
$begingroup$
I'm guessing "Any valid I/O format is allowed" includes outputting the numbers as lists of decimal digits, but just wanted to confirm - ?
$endgroup$
– Jonathan Allan
12 hours ago
$begingroup$
Yes @JonathanAllan
$endgroup$
– Luis felipe De jesus Munoz
12 hours ago
add a comment |
$begingroup$
A jumping number is defined as a positive number n which all pairs of consecutive decimal digits differ by 1. Also, all single digit numbers are considered jumping numbers. eg. 3, 45676, 212 are jumping numbers but 414 and 13 are not. The difference between 9 and 0 is not considered as 1
The challenge
Create a program that output one of the following results:
- Given an input
n
output the firstn
jumping numbers. - Given an input
n
output then
th term of the sequence.
Note
- Any valid I/O format is allowed
- 1-index or 0-index is allowed (please specify)
Here are some jumping numbers:
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 21, 23, 32, 34, 43, 45, 54, 56, 65, 67, 76, 78, 87, 89, 98, 101, 121, 123, 210, 212, 232, 234, 321, 323, 343, 345, 432, 434, 454, 456, 543, 545, 565, 567, 654, 656, 676, 678, 765, 767, 787, 789, 876, ...
This is also A033075
code-golf number sequence
$endgroup$
A jumping number is defined as a positive number n which all pairs of consecutive decimal digits differ by 1. Also, all single digit numbers are considered jumping numbers. eg. 3, 45676, 212 are jumping numbers but 414 and 13 are not. The difference between 9 and 0 is not considered as 1
The challenge
Create a program that output one of the following results:
- Given an input
n
output the firstn
jumping numbers. - Given an input
n
output then
th term of the sequence.
Note
- Any valid I/O format is allowed
- 1-index or 0-index is allowed (please specify)
Here are some jumping numbers:
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 21, 23, 32, 34, 43, 45, 54, 56, 65, 67, 76, 78, 87, 89, 98, 101, 121, 123, 210, 212, 232, 234, 321, 323, 343, 345, 432, 434, 454, 456, 543, 545, 565, 567, 654, 656, 676, 678, 765, 767, 787, 789, 876, ...
This is also A033075
code-golf number sequence
code-golf number sequence
edited 6 hours ago
DLosc
19.3k33889
19.3k33889
asked 13 hours ago
Luis felipe De jesus MunozLuis felipe De jesus Munoz
5,37221669
5,37221669
$begingroup$
Is this 0 or 1 Indexed?
$endgroup$
– Taylor Scott
13 hours ago
1
$begingroup$
@TaylorScott The sequence consists in only positive numbers. If you mean the inputn
then it is up to you.
$endgroup$
– Luis felipe De jesus Munoz
13 hours ago
$begingroup$
I'm guessing "Any valid I/O format is allowed" includes outputting the numbers as lists of decimal digits, but just wanted to confirm - ?
$endgroup$
– Jonathan Allan
12 hours ago
$begingroup$
Yes @JonathanAllan
$endgroup$
– Luis felipe De jesus Munoz
12 hours ago
add a comment |
$begingroup$
Is this 0 or 1 Indexed?
$endgroup$
– Taylor Scott
13 hours ago
1
$begingroup$
@TaylorScott The sequence consists in only positive numbers. If you mean the inputn
then it is up to you.
$endgroup$
– Luis felipe De jesus Munoz
13 hours ago
$begingroup$
I'm guessing "Any valid I/O format is allowed" includes outputting the numbers as lists of decimal digits, but just wanted to confirm - ?
$endgroup$
– Jonathan Allan
12 hours ago
$begingroup$
Yes @JonathanAllan
$endgroup$
– Luis felipe De jesus Munoz
12 hours ago
$begingroup$
Is this 0 or 1 Indexed?
$endgroup$
– Taylor Scott
13 hours ago
$begingroup$
Is this 0 or 1 Indexed?
$endgroup$
– Taylor Scott
13 hours ago
1
1
$begingroup$
@TaylorScott The sequence consists in only positive numbers. If you mean the input
n
then it is up to you.$endgroup$
– Luis felipe De jesus Munoz
13 hours ago
$begingroup$
@TaylorScott The sequence consists in only positive numbers. If you mean the input
n
then it is up to you.$endgroup$
– Luis felipe De jesus Munoz
13 hours ago
$begingroup$
I'm guessing "Any valid I/O format is allowed" includes outputting the numbers as lists of decimal digits, but just wanted to confirm - ?
$endgroup$
– Jonathan Allan
12 hours ago
$begingroup$
I'm guessing "Any valid I/O format is allowed" includes outputting the numbers as lists of decimal digits, but just wanted to confirm - ?
$endgroup$
– Jonathan Allan
12 hours ago
$begingroup$
Yes @JonathanAllan
$endgroup$
– Luis felipe De jesus Munoz
12 hours ago
$begingroup$
Yes @JonathanAllan
$endgroup$
– Luis felipe De jesus Munoz
12 hours ago
add a comment |
15 Answers
15
active
oldest
votes
$begingroup$
Jelly, 8 bytes
1DI*`ƑƊ#
A full program accepting an integer, n
, from STDIN which prints a list of the first n
positive jumping numbers.
Try it online!
How?
Acceptable incremental differences between digits are 1
and -1
while others from [-9,-2]+[2,9]
are not. This lines up with integers which are invariant when raised to themselves. i.e. $x^x=x$ since:
$$0^0=1$$
$$1^1=1$$
$$2^2=4$$
$$cdots$$
$$-1^{-1}=-1$$
$$-2^{-2}=-frac{1}{4}$$
$$cdots$$
1DI*`ƑƊ# - Main Link: no arguments (accepts a line of input from STDIN)
# - count up keeping the first (input) n matches...
1 - ...start with n equal to: 1
Ɗ - ...match function: last three links as a monad: e.g. 245 777 7656
D - convert to a list of decimal digits [2,4,5] [7,7,7] [7,6,5,6]
I - incremental differences [2,1] [0,0] [-1,-1,1]
Ƒ - invariant under?:
` - using left argument as both inputs of:
* - exponentiation (vectorises) [4,1] [1,1] [-1,-1,1]
- --so we: discard discard keep
- implicitly print the list of collected values of n
$endgroup$
add a comment |
$begingroup$
Haskell, 57 bytes
(l!!)
l=[1..9]++[x*10+t|x<-l,t<-[0..9],(mod x 10-t)^2==1]
Try it online!
$endgroup$
add a comment |
$begingroup$
05AB1E (legacy), 5 bytes
The input is 1-indexed.
Code:
µN¥ÄP
Uses the 05AB1E encoding. Try it online!
Explanation
µ # Get the nth number, starting from 0, such that...
Ä # The absolute values
N¥ # Of the delta's of N
P # Are all 1 (product function, basically acts as a reduce by AND)
$endgroup$
$begingroup$
Right tool for the job.
$endgroup$
– lirtosiast
4 hours ago
add a comment |
$begingroup$
C (gcc), 90 bytes
f(n,K,b,k){for(K=0;n;b&&printf("%d,",K,n--))for(b=k=++K;k/10;)b*=abs(k%10-(k/=10)%10)==1;}
Try it online!
$endgroup$
add a comment |
$begingroup$
Japt, 14 bytes
Outputs the first n
th term, 1-indexed.
_ì äa dÉ ªU´}f
Try it
(I know, I know, I'm supposed to be taking a break but I'm in golf withdrawal!)
$endgroup$
$begingroup$
Haha, maybe go learn a new golfing language to cure your withdrawal. :P
$endgroup$
– Quintec
10 hours ago
add a comment |
$begingroup$
Python 2, 88 87 bytes
f=lambda n,i=2:n and f(n-g(i),i+1)or~-i
g=lambda i:i<10or abs(i/10%10-i%10)==1==g(i/10)
Try it online!
Returns the 0-indexed jumping number (i.e., f(0) => 1, etc).
$endgroup$
$begingroup$
@lirtosiast : That's OK, please donate your answer to your favorite charity :). It's sufficiently different to merit a separate response (as well as being cross-language appropriate).
$endgroup$
– Chas Brown
3 hours ago
add a comment |
$begingroup$
Haskell, 71 bytes
- Thanks to Joseph Sible for enforcing the challenge rules and saving three bytes.
(filter(all((==1).abs).(zipWith(-)<*>tail).map(read.pure).show)[1..]!!)
Try it online!
$endgroup$
1
$begingroup$
This appears to answer the question "is this a jumping number?" for a given input number, which isn't what the challenge asked for.
$endgroup$
– Joseph Sible
11 hours ago
$begingroup$
@JosephSible You are correct. Thank you for noting.
$endgroup$
– Jonathan Frech
7 hours ago
$begingroup$
Also, now that that's fixed, you can makeg
3 bytes shorter by rewriting it to be pointfree, then using<*>
:g=all((==1).abs).(zipWith(-)<*>tail).map(read.pure).show
$endgroup$
– Joseph Sible
2 hours ago
$begingroup$
@JosephSible Thank you.
$endgroup$
– Jonathan Frech
2 hours ago
$begingroup$
Go back tomap fromEnum
.
$endgroup$
– nimi
4 mins ago
add a comment |
$begingroup$
Python 2, 79 75 bytes
-4 bytes by xnor
f=lambda n,i=1:n and-~f(n-g(i),i+1)
g=lambda i:i<10or i%100%11%9==g(i/10)>0
Try it online!
Derived from Chas Brown's answer. The helper function g(i)
returns whether i
is a jumping number. Iff the last two digits of a number n
have absolute difference 1, then n%100%11
will be either 1 or 10, so n%100%11%9
will be 1.
$endgroup$
$begingroup$
Nice trick with the%11
. You can dof=lambda n,i=1:n and-~f(n-g(i),i+1)
if you switch to one-indexing.
$endgroup$
– xnor
1 hour ago
add a comment |
$begingroup$
JavaScript (ES7), 60 bytes
Returns the $n$th term of the sequence (1-indexed).
f=(n,k)=>[...k+''].some(p=x=>(p-(p=x))**2-1)||n--?f(n,-~k):k
Try it online!
$endgroup$
add a comment |
$begingroup$
Jelly, 9 bytes
-1 by Jonathan Allan
1DạƝ=1ẠƲ#
Try it online!
1-indexed.
$endgroup$
$begingroup$
9 bytes by reading STDIN
$endgroup$
– Jonathan Allan
12 hours ago
add a comment |
$begingroup$
Swift, 228 bytes
func j(n:Int){
var r:[Int]=
for x in 0...n{
if x<=10{r.append(x)}else{
let t=String(x).compactMap{Int(String($0))}
var b=true
for i in 1...t.count-1{if abs(t[i-1]-t[i]) != 1{b=false}}
if b{r.append(x)}
}
}
print(r)
}
j(n:1000)
Try it online!
$endgroup$
add a comment |
$begingroup$
Python 3, 122 121 bytes
g=lambda s:len(s)==1or 1==abs(ord(s[0])-ord(s[1]))and g(s[1:])
def f(n,i=1):
while n:
if g(str(i)):n-=1;yield i
i+=1
Try it online!
-1 byte by changing f
from printing, to a generator function.
g
is a recursive helper function which determines if a string s
is a "jumping string" (this works since the character codes for 0 to 9 are in order and contiguous).
f
is a generator function that takes in n
and yields the first n
jumping numbers.
$endgroup$
add a comment |
$begingroup$
R, 85 bytes
i=scan();j=0;while(i)if((j=j+1)<10|all(abs(diff(j%/%10^(0:log10(j))%%10))==1))i=i-1;j
Try it online!
Suspect this can be golfed more. Reads the number using scan()
and outputs the appropriate jumping number.
$endgroup$
add a comment |
$begingroup$
Perl 5, 56 bytes
map{1while++$n=~s|.(?=(.))|abs$&-$1!=1|ger>9}1..<>;say$n
Try it online!
1-indexed, outputs the nth jumping number
$endgroup$
add a comment |
$begingroup$
Wolfram Language (Mathematica), 85 bytes
If[#<10,#,t=n=1;While[t<=#,{-1,1}~SubsetQ~Differences@IntegerDigits@n++~If~t++];n-1]&
Try it online!
returns the n-th number
$endgroup$
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
return StackExchange.using("mathjaxEditing", function () {
StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["\$", "\$"]]);
});
});
}, "mathjax-editing");
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "200"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f180693%2fjumping-numbers%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
15 Answers
15
active
oldest
votes
15 Answers
15
active
oldest
votes
active
oldest
votes
active
oldest
votes
$begingroup$
Jelly, 8 bytes
1DI*`ƑƊ#
A full program accepting an integer, n
, from STDIN which prints a list of the first n
positive jumping numbers.
Try it online!
How?
Acceptable incremental differences between digits are 1
and -1
while others from [-9,-2]+[2,9]
are not. This lines up with integers which are invariant when raised to themselves. i.e. $x^x=x$ since:
$$0^0=1$$
$$1^1=1$$
$$2^2=4$$
$$cdots$$
$$-1^{-1}=-1$$
$$-2^{-2}=-frac{1}{4}$$
$$cdots$$
1DI*`ƑƊ# - Main Link: no arguments (accepts a line of input from STDIN)
# - count up keeping the first (input) n matches...
1 - ...start with n equal to: 1
Ɗ - ...match function: last three links as a monad: e.g. 245 777 7656
D - convert to a list of decimal digits [2,4,5] [7,7,7] [7,6,5,6]
I - incremental differences [2,1] [0,0] [-1,-1,1]
Ƒ - invariant under?:
` - using left argument as both inputs of:
* - exponentiation (vectorises) [4,1] [1,1] [-1,-1,1]
- --so we: discard discard keep
- implicitly print the list of collected values of n
$endgroup$
add a comment |
$begingroup$
Jelly, 8 bytes
1DI*`ƑƊ#
A full program accepting an integer, n
, from STDIN which prints a list of the first n
positive jumping numbers.
Try it online!
How?
Acceptable incremental differences between digits are 1
and -1
while others from [-9,-2]+[2,9]
are not. This lines up with integers which are invariant when raised to themselves. i.e. $x^x=x$ since:
$$0^0=1$$
$$1^1=1$$
$$2^2=4$$
$$cdots$$
$$-1^{-1}=-1$$
$$-2^{-2}=-frac{1}{4}$$
$$cdots$$
1DI*`ƑƊ# - Main Link: no arguments (accepts a line of input from STDIN)
# - count up keeping the first (input) n matches...
1 - ...start with n equal to: 1
Ɗ - ...match function: last three links as a monad: e.g. 245 777 7656
D - convert to a list of decimal digits [2,4,5] [7,7,7] [7,6,5,6]
I - incremental differences [2,1] [0,0] [-1,-1,1]
Ƒ - invariant under?:
` - using left argument as both inputs of:
* - exponentiation (vectorises) [4,1] [1,1] [-1,-1,1]
- --so we: discard discard keep
- implicitly print the list of collected values of n
$endgroup$
add a comment |
$begingroup$
Jelly, 8 bytes
1DI*`ƑƊ#
A full program accepting an integer, n
, from STDIN which prints a list of the first n
positive jumping numbers.
Try it online!
How?
Acceptable incremental differences between digits are 1
and -1
while others from [-9,-2]+[2,9]
are not. This lines up with integers which are invariant when raised to themselves. i.e. $x^x=x$ since:
$$0^0=1$$
$$1^1=1$$
$$2^2=4$$
$$cdots$$
$$-1^{-1}=-1$$
$$-2^{-2}=-frac{1}{4}$$
$$cdots$$
1DI*`ƑƊ# - Main Link: no arguments (accepts a line of input from STDIN)
# - count up keeping the first (input) n matches...
1 - ...start with n equal to: 1
Ɗ - ...match function: last three links as a monad: e.g. 245 777 7656
D - convert to a list of decimal digits [2,4,5] [7,7,7] [7,6,5,6]
I - incremental differences [2,1] [0,0] [-1,-1,1]
Ƒ - invariant under?:
` - using left argument as both inputs of:
* - exponentiation (vectorises) [4,1] [1,1] [-1,-1,1]
- --so we: discard discard keep
- implicitly print the list of collected values of n
$endgroup$
Jelly, 8 bytes
1DI*`ƑƊ#
A full program accepting an integer, n
, from STDIN which prints a list of the first n
positive jumping numbers.
Try it online!
How?
Acceptable incremental differences between digits are 1
and -1
while others from [-9,-2]+[2,9]
are not. This lines up with integers which are invariant when raised to themselves. i.e. $x^x=x$ since:
$$0^0=1$$
$$1^1=1$$
$$2^2=4$$
$$cdots$$
$$-1^{-1}=-1$$
$$-2^{-2}=-frac{1}{4}$$
$$cdots$$
1DI*`ƑƊ# - Main Link: no arguments (accepts a line of input from STDIN)
# - count up keeping the first (input) n matches...
1 - ...start with n equal to: 1
Ɗ - ...match function: last three links as a monad: e.g. 245 777 7656
D - convert to a list of decimal digits [2,4,5] [7,7,7] [7,6,5,6]
I - incremental differences [2,1] [0,0] [-1,-1,1]
Ƒ - invariant under?:
` - using left argument as both inputs of:
* - exponentiation (vectorises) [4,1] [1,1] [-1,-1,1]
- --so we: discard discard keep
- implicitly print the list of collected values of n
edited 11 hours ago
answered 12 hours ago
Jonathan AllanJonathan Allan
52.3k535170
52.3k535170
add a comment |
add a comment |
$begingroup$
Haskell, 57 bytes
(l!!)
l=[1..9]++[x*10+t|x<-l,t<-[0..9],(mod x 10-t)^2==1]
Try it online!
$endgroup$
add a comment |
$begingroup$
Haskell, 57 bytes
(l!!)
l=[1..9]++[x*10+t|x<-l,t<-[0..9],(mod x 10-t)^2==1]
Try it online!
$endgroup$
add a comment |
$begingroup$
Haskell, 57 bytes
(l!!)
l=[1..9]++[x*10+t|x<-l,t<-[0..9],(mod x 10-t)^2==1]
Try it online!
$endgroup$
Haskell, 57 bytes
(l!!)
l=[1..9]++[x*10+t|x<-l,t<-[0..9],(mod x 10-t)^2==1]
Try it online!
edited 6 hours ago
answered 6 hours ago
xnorxnor
91.5k18187443
91.5k18187443
add a comment |
add a comment |
$begingroup$
05AB1E (legacy), 5 bytes
The input is 1-indexed.
Code:
µN¥ÄP
Uses the 05AB1E encoding. Try it online!
Explanation
µ # Get the nth number, starting from 0, such that...
Ä # The absolute values
N¥ # Of the delta's of N
P # Are all 1 (product function, basically acts as a reduce by AND)
$endgroup$
$begingroup$
Right tool for the job.
$endgroup$
– lirtosiast
4 hours ago
add a comment |
$begingroup$
05AB1E (legacy), 5 bytes
The input is 1-indexed.
Code:
µN¥ÄP
Uses the 05AB1E encoding. Try it online!
Explanation
µ # Get the nth number, starting from 0, such that...
Ä # The absolute values
N¥ # Of the delta's of N
P # Are all 1 (product function, basically acts as a reduce by AND)
$endgroup$
$begingroup$
Right tool for the job.
$endgroup$
– lirtosiast
4 hours ago
add a comment |
$begingroup$
05AB1E (legacy), 5 bytes
The input is 1-indexed.
Code:
µN¥ÄP
Uses the 05AB1E encoding. Try it online!
Explanation
µ # Get the nth number, starting from 0, such that...
Ä # The absolute values
N¥ # Of the delta's of N
P # Are all 1 (product function, basically acts as a reduce by AND)
$endgroup$
05AB1E (legacy), 5 bytes
The input is 1-indexed.
Code:
µN¥ÄP
Uses the 05AB1E encoding. Try it online!
Explanation
µ # Get the nth number, starting from 0, such that...
Ä # The absolute values
N¥ # Of the delta's of N
P # Are all 1 (product function, basically acts as a reduce by AND)
edited 10 hours ago
answered 10 hours ago
AdnanAdnan
35.5k562225
35.5k562225
$begingroup$
Right tool for the job.
$endgroup$
– lirtosiast
4 hours ago
add a comment |
$begingroup$
Right tool for the job.
$endgroup$
– lirtosiast
4 hours ago
$begingroup$
Right tool for the job.
$endgroup$
– lirtosiast
4 hours ago
$begingroup$
Right tool for the job.
$endgroup$
– lirtosiast
4 hours ago
add a comment |
$begingroup$
C (gcc), 90 bytes
f(n,K,b,k){for(K=0;n;b&&printf("%d,",K,n--))for(b=k=++K;k/10;)b*=abs(k%10-(k/=10)%10)==1;}
Try it online!
$endgroup$
add a comment |
$begingroup$
C (gcc), 90 bytes
f(n,K,b,k){for(K=0;n;b&&printf("%d,",K,n--))for(b=k=++K;k/10;)b*=abs(k%10-(k/=10)%10)==1;}
Try it online!
$endgroup$
add a comment |
$begingroup$
C (gcc), 90 bytes
f(n,K,b,k){for(K=0;n;b&&printf("%d,",K,n--))for(b=k=++K;k/10;)b*=abs(k%10-(k/=10)%10)==1;}
Try it online!
$endgroup$
C (gcc), 90 bytes
f(n,K,b,k){for(K=0;n;b&&printf("%d,",K,n--))for(b=k=++K;k/10;)b*=abs(k%10-(k/=10)%10)==1;}
Try it online!
answered 12 hours ago
Jonathan FrechJonathan Frech
6,35311040
6,35311040
add a comment |
add a comment |
$begingroup$
Japt, 14 bytes
Outputs the first n
th term, 1-indexed.
_ì äa dÉ ªU´}f
Try it
(I know, I know, I'm supposed to be taking a break but I'm in golf withdrawal!)
$endgroup$
$begingroup$
Haha, maybe go learn a new golfing language to cure your withdrawal. :P
$endgroup$
– Quintec
10 hours ago
add a comment |
$begingroup$
Japt, 14 bytes
Outputs the first n
th term, 1-indexed.
_ì äa dÉ ªU´}f
Try it
(I know, I know, I'm supposed to be taking a break but I'm in golf withdrawal!)
$endgroup$
$begingroup$
Haha, maybe go learn a new golfing language to cure your withdrawal. :P
$endgroup$
– Quintec
10 hours ago
add a comment |
$begingroup$
Japt, 14 bytes
Outputs the first n
th term, 1-indexed.
_ì äa dÉ ªU´}f
Try it
(I know, I know, I'm supposed to be taking a break but I'm in golf withdrawal!)
$endgroup$
Japt, 14 bytes
Outputs the first n
th term, 1-indexed.
_ì äa dÉ ªU´}f
Try it
(I know, I know, I'm supposed to be taking a break but I'm in golf withdrawal!)
edited 10 hours ago
answered 12 hours ago
ShaggyShaggy
19.5k21667
19.5k21667
$begingroup$
Haha, maybe go learn a new golfing language to cure your withdrawal. :P
$endgroup$
– Quintec
10 hours ago
add a comment |
$begingroup$
Haha, maybe go learn a new golfing language to cure your withdrawal. :P
$endgroup$
– Quintec
10 hours ago
$begingroup$
Haha, maybe go learn a new golfing language to cure your withdrawal. :P
$endgroup$
– Quintec
10 hours ago
$begingroup$
Haha, maybe go learn a new golfing language to cure your withdrawal. :P
$endgroup$
– Quintec
10 hours ago
add a comment |
$begingroup$
Python 2, 88 87 bytes
f=lambda n,i=2:n and f(n-g(i),i+1)or~-i
g=lambda i:i<10or abs(i/10%10-i%10)==1==g(i/10)
Try it online!
Returns the 0-indexed jumping number (i.e., f(0) => 1, etc).
$endgroup$
$begingroup$
@lirtosiast : That's OK, please donate your answer to your favorite charity :). It's sufficiently different to merit a separate response (as well as being cross-language appropriate).
$endgroup$
– Chas Brown
3 hours ago
add a comment |
$begingroup$
Python 2, 88 87 bytes
f=lambda n,i=2:n and f(n-g(i),i+1)or~-i
g=lambda i:i<10or abs(i/10%10-i%10)==1==g(i/10)
Try it online!
Returns the 0-indexed jumping number (i.e., f(0) => 1, etc).
$endgroup$
$begingroup$
@lirtosiast : That's OK, please donate your answer to your favorite charity :). It's sufficiently different to merit a separate response (as well as being cross-language appropriate).
$endgroup$
– Chas Brown
3 hours ago
add a comment |
$begingroup$
Python 2, 88 87 bytes
f=lambda n,i=2:n and f(n-g(i),i+1)or~-i
g=lambda i:i<10or abs(i/10%10-i%10)==1==g(i/10)
Try it online!
Returns the 0-indexed jumping number (i.e., f(0) => 1, etc).
$endgroup$
Python 2, 88 87 bytes
f=lambda n,i=2:n and f(n-g(i),i+1)or~-i
g=lambda i:i<10or abs(i/10%10-i%10)==1==g(i/10)
Try it online!
Returns the 0-indexed jumping number (i.e., f(0) => 1, etc).
edited 8 hours ago
answered 9 hours ago
Chas BrownChas Brown
4,9841523
4,9841523
$begingroup$
@lirtosiast : That's OK, please donate your answer to your favorite charity :). It's sufficiently different to merit a separate response (as well as being cross-language appropriate).
$endgroup$
– Chas Brown
3 hours ago
add a comment |
$begingroup$
@lirtosiast : That's OK, please donate your answer to your favorite charity :). It's sufficiently different to merit a separate response (as well as being cross-language appropriate).
$endgroup$
– Chas Brown
3 hours ago
$begingroup$
@lirtosiast : That's OK, please donate your answer to your favorite charity :). It's sufficiently different to merit a separate response (as well as being cross-language appropriate).
$endgroup$
– Chas Brown
3 hours ago
$begingroup$
@lirtosiast : That's OK, please donate your answer to your favorite charity :). It's sufficiently different to merit a separate response (as well as being cross-language appropriate).
$endgroup$
– Chas Brown
3 hours ago
add a comment |
$begingroup$
Haskell, 71 bytes
- Thanks to Joseph Sible for enforcing the challenge rules and saving three bytes.
(filter(all((==1).abs).(zipWith(-)<*>tail).map(read.pure).show)[1..]!!)
Try it online!
$endgroup$
1
$begingroup$
This appears to answer the question "is this a jumping number?" for a given input number, which isn't what the challenge asked for.
$endgroup$
– Joseph Sible
11 hours ago
$begingroup$
@JosephSible You are correct. Thank you for noting.
$endgroup$
– Jonathan Frech
7 hours ago
$begingroup$
Also, now that that's fixed, you can makeg
3 bytes shorter by rewriting it to be pointfree, then using<*>
:g=all((==1).abs).(zipWith(-)<*>tail).map(read.pure).show
$endgroup$
– Joseph Sible
2 hours ago
$begingroup$
@JosephSible Thank you.
$endgroup$
– Jonathan Frech
2 hours ago
$begingroup$
Go back tomap fromEnum
.
$endgroup$
– nimi
4 mins ago
add a comment |
$begingroup$
Haskell, 71 bytes
- Thanks to Joseph Sible for enforcing the challenge rules and saving three bytes.
(filter(all((==1).abs).(zipWith(-)<*>tail).map(read.pure).show)[1..]!!)
Try it online!
$endgroup$
1
$begingroup$
This appears to answer the question "is this a jumping number?" for a given input number, which isn't what the challenge asked for.
$endgroup$
– Joseph Sible
11 hours ago
$begingroup$
@JosephSible You are correct. Thank you for noting.
$endgroup$
– Jonathan Frech
7 hours ago
$begingroup$
Also, now that that's fixed, you can makeg
3 bytes shorter by rewriting it to be pointfree, then using<*>
:g=all((==1).abs).(zipWith(-)<*>tail).map(read.pure).show
$endgroup$
– Joseph Sible
2 hours ago
$begingroup$
@JosephSible Thank you.
$endgroup$
– Jonathan Frech
2 hours ago
$begingroup$
Go back tomap fromEnum
.
$endgroup$
– nimi
4 mins ago
add a comment |
$begingroup$
Haskell, 71 bytes
- Thanks to Joseph Sible for enforcing the challenge rules and saving three bytes.
(filter(all((==1).abs).(zipWith(-)<*>tail).map(read.pure).show)[1..]!!)
Try it online!
$endgroup$
Haskell, 71 bytes
- Thanks to Joseph Sible for enforcing the challenge rules and saving three bytes.
(filter(all((==1).abs).(zipWith(-)<*>tail).map(read.pure).show)[1..]!!)
Try it online!
edited 2 hours ago
answered 12 hours ago
Jonathan FrechJonathan Frech
6,35311040
6,35311040
1
$begingroup$
This appears to answer the question "is this a jumping number?" for a given input number, which isn't what the challenge asked for.
$endgroup$
– Joseph Sible
11 hours ago
$begingroup$
@JosephSible You are correct. Thank you for noting.
$endgroup$
– Jonathan Frech
7 hours ago
$begingroup$
Also, now that that's fixed, you can makeg
3 bytes shorter by rewriting it to be pointfree, then using<*>
:g=all((==1).abs).(zipWith(-)<*>tail).map(read.pure).show
$endgroup$
– Joseph Sible
2 hours ago
$begingroup$
@JosephSible Thank you.
$endgroup$
– Jonathan Frech
2 hours ago
$begingroup$
Go back tomap fromEnum
.
$endgroup$
– nimi
4 mins ago
add a comment |
1
$begingroup$
This appears to answer the question "is this a jumping number?" for a given input number, which isn't what the challenge asked for.
$endgroup$
– Joseph Sible
11 hours ago
$begingroup$
@JosephSible You are correct. Thank you for noting.
$endgroup$
– Jonathan Frech
7 hours ago
$begingroup$
Also, now that that's fixed, you can makeg
3 bytes shorter by rewriting it to be pointfree, then using<*>
:g=all((==1).abs).(zipWith(-)<*>tail).map(read.pure).show
$endgroup$
– Joseph Sible
2 hours ago
$begingroup$
@JosephSible Thank you.
$endgroup$
– Jonathan Frech
2 hours ago
$begingroup$
Go back tomap fromEnum
.
$endgroup$
– nimi
4 mins ago
1
1
$begingroup$
This appears to answer the question "is this a jumping number?" for a given input number, which isn't what the challenge asked for.
$endgroup$
– Joseph Sible
11 hours ago
$begingroup$
This appears to answer the question "is this a jumping number?" for a given input number, which isn't what the challenge asked for.
$endgroup$
– Joseph Sible
11 hours ago
$begingroup$
@JosephSible You are correct. Thank you for noting.
$endgroup$
– Jonathan Frech
7 hours ago
$begingroup$
@JosephSible You are correct. Thank you for noting.
$endgroup$
– Jonathan Frech
7 hours ago
$begingroup$
Also, now that that's fixed, you can make
g
3 bytes shorter by rewriting it to be pointfree, then using <*>
: g=all((==1).abs).(zipWith(-)<*>tail).map(read.pure).show
$endgroup$
– Joseph Sible
2 hours ago
$begingroup$
Also, now that that's fixed, you can make
g
3 bytes shorter by rewriting it to be pointfree, then using <*>
: g=all((==1).abs).(zipWith(-)<*>tail).map(read.pure).show
$endgroup$
– Joseph Sible
2 hours ago
$begingroup$
@JosephSible Thank you.
$endgroup$
– Jonathan Frech
2 hours ago
$begingroup$
@JosephSible Thank you.
$endgroup$
– Jonathan Frech
2 hours ago
$begingroup$
Go back to
map fromEnum
.$endgroup$
– nimi
4 mins ago
$begingroup$
Go back to
map fromEnum
.$endgroup$
– nimi
4 mins ago
add a comment |
$begingroup$
Python 2, 79 75 bytes
-4 bytes by xnor
f=lambda n,i=1:n and-~f(n-g(i),i+1)
g=lambda i:i<10or i%100%11%9==g(i/10)>0
Try it online!
Derived from Chas Brown's answer. The helper function g(i)
returns whether i
is a jumping number. Iff the last two digits of a number n
have absolute difference 1, then n%100%11
will be either 1 or 10, so n%100%11%9
will be 1.
$endgroup$
$begingroup$
Nice trick with the%11
. You can dof=lambda n,i=1:n and-~f(n-g(i),i+1)
if you switch to one-indexing.
$endgroup$
– xnor
1 hour ago
add a comment |
$begingroup$
Python 2, 79 75 bytes
-4 bytes by xnor
f=lambda n,i=1:n and-~f(n-g(i),i+1)
g=lambda i:i<10or i%100%11%9==g(i/10)>0
Try it online!
Derived from Chas Brown's answer. The helper function g(i)
returns whether i
is a jumping number. Iff the last two digits of a number n
have absolute difference 1, then n%100%11
will be either 1 or 10, so n%100%11%9
will be 1.
$endgroup$
$begingroup$
Nice trick with the%11
. You can dof=lambda n,i=1:n and-~f(n-g(i),i+1)
if you switch to one-indexing.
$endgroup$
– xnor
1 hour ago
add a comment |
$begingroup$
Python 2, 79 75 bytes
-4 bytes by xnor
f=lambda n,i=1:n and-~f(n-g(i),i+1)
g=lambda i:i<10or i%100%11%9==g(i/10)>0
Try it online!
Derived from Chas Brown's answer. The helper function g(i)
returns whether i
is a jumping number. Iff the last two digits of a number n
have absolute difference 1, then n%100%11
will be either 1 or 10, so n%100%11%9
will be 1.
$endgroup$
Python 2, 79 75 bytes
-4 bytes by xnor
f=lambda n,i=1:n and-~f(n-g(i),i+1)
g=lambda i:i<10or i%100%11%9==g(i/10)>0
Try it online!
Derived from Chas Brown's answer. The helper function g(i)
returns whether i
is a jumping number. Iff the last two digits of a number n
have absolute difference 1, then n%100%11
will be either 1 or 10, so n%100%11%9
will be 1.
edited 50 mins ago
answered 3 hours ago
lirtosiastlirtosiast
18.1k437109
18.1k437109
$begingroup$
Nice trick with the%11
. You can dof=lambda n,i=1:n and-~f(n-g(i),i+1)
if you switch to one-indexing.
$endgroup$
– xnor
1 hour ago
add a comment |
$begingroup$
Nice trick with the%11
. You can dof=lambda n,i=1:n and-~f(n-g(i),i+1)
if you switch to one-indexing.
$endgroup$
– xnor
1 hour ago
$begingroup$
Nice trick with the
%11
. You can do f=lambda n,i=1:n and-~f(n-g(i),i+1)
if you switch to one-indexing.$endgroup$
– xnor
1 hour ago
$begingroup$
Nice trick with the
%11
. You can do f=lambda n,i=1:n and-~f(n-g(i),i+1)
if you switch to one-indexing.$endgroup$
– xnor
1 hour ago
add a comment |
$begingroup$
JavaScript (ES7), 60 bytes
Returns the $n$th term of the sequence (1-indexed).
f=(n,k)=>[...k+''].some(p=x=>(p-(p=x))**2-1)||n--?f(n,-~k):k
Try it online!
$endgroup$
add a comment |
$begingroup$
JavaScript (ES7), 60 bytes
Returns the $n$th term of the sequence (1-indexed).
f=(n,k)=>[...k+''].some(p=x=>(p-(p=x))**2-1)||n--?f(n,-~k):k
Try it online!
$endgroup$
add a comment |
$begingroup$
JavaScript (ES7), 60 bytes
Returns the $n$th term of the sequence (1-indexed).
f=(n,k)=>[...k+''].some(p=x=>(p-(p=x))**2-1)||n--?f(n,-~k):k
Try it online!
$endgroup$
JavaScript (ES7), 60 bytes
Returns the $n$th term of the sequence (1-indexed).
f=(n,k)=>[...k+''].some(p=x=>(p-(p=x))**2-1)||n--?f(n,-~k):k
Try it online!
answered 12 hours ago
ArnauldArnauld
77.5k694325
77.5k694325
add a comment |
add a comment |
$begingroup$
Jelly, 9 bytes
-1 by Jonathan Allan
1DạƝ=1ẠƲ#
Try it online!
1-indexed.
$endgroup$
$begingroup$
9 bytes by reading STDIN
$endgroup$
– Jonathan Allan
12 hours ago
add a comment |
$begingroup$
Jelly, 9 bytes
-1 by Jonathan Allan
1DạƝ=1ẠƲ#
Try it online!
1-indexed.
$endgroup$
$begingroup$
9 bytes by reading STDIN
$endgroup$
– Jonathan Allan
12 hours ago
add a comment |
$begingroup$
Jelly, 9 bytes
-1 by Jonathan Allan
1DạƝ=1ẠƲ#
Try it online!
1-indexed.
$endgroup$
Jelly, 9 bytes
-1 by Jonathan Allan
1DạƝ=1ẠƲ#
Try it online!
1-indexed.
edited 10 hours ago
answered 12 hours ago
lirtosiastlirtosiast
18.1k437109
18.1k437109
$begingroup$
9 bytes by reading STDIN
$endgroup$
– Jonathan Allan
12 hours ago
add a comment |
$begingroup$
9 bytes by reading STDIN
$endgroup$
– Jonathan Allan
12 hours ago
$begingroup$
9 bytes by reading STDIN
$endgroup$
– Jonathan Allan
12 hours ago
$begingroup$
9 bytes by reading STDIN
$endgroup$
– Jonathan Allan
12 hours ago
add a comment |
$begingroup$
Swift, 228 bytes
func j(n:Int){
var r:[Int]=
for x in 0...n{
if x<=10{r.append(x)}else{
let t=String(x).compactMap{Int(String($0))}
var b=true
for i in 1...t.count-1{if abs(t[i-1]-t[i]) != 1{b=false}}
if b{r.append(x)}
}
}
print(r)
}
j(n:1000)
Try it online!
$endgroup$
add a comment |
$begingroup$
Swift, 228 bytes
func j(n:Int){
var r:[Int]=
for x in 0...n{
if x<=10{r.append(x)}else{
let t=String(x).compactMap{Int(String($0))}
var b=true
for i in 1...t.count-1{if abs(t[i-1]-t[i]) != 1{b=false}}
if b{r.append(x)}
}
}
print(r)
}
j(n:1000)
Try it online!
$endgroup$
add a comment |
$begingroup$
Swift, 228 bytes
func j(n:Int){
var r:[Int]=
for x in 0...n{
if x<=10{r.append(x)}else{
let t=String(x).compactMap{Int(String($0))}
var b=true
for i in 1...t.count-1{if abs(t[i-1]-t[i]) != 1{b=false}}
if b{r.append(x)}
}
}
print(r)
}
j(n:1000)
Try it online!
$endgroup$
Swift, 228 bytes
func j(n:Int){
var r:[Int]=
for x in 0...n{
if x<=10{r.append(x)}else{
let t=String(x).compactMap{Int(String($0))}
var b=true
for i in 1...t.count-1{if abs(t[i-1]-t[i]) != 1{b=false}}
if b{r.append(x)}
}
}
print(r)
}
j(n:1000)
Try it online!
edited 11 hours ago
Shaggy
19.5k21667
19.5k21667
answered 11 hours ago
onnowebonnoweb
1212
1212
add a comment |
add a comment |
$begingroup$
Python 3, 122 121 bytes
g=lambda s:len(s)==1or 1==abs(ord(s[0])-ord(s[1]))and g(s[1:])
def f(n,i=1):
while n:
if g(str(i)):n-=1;yield i
i+=1
Try it online!
-1 byte by changing f
from printing, to a generator function.
g
is a recursive helper function which determines if a string s
is a "jumping string" (this works since the character codes for 0 to 9 are in order and contiguous).
f
is a generator function that takes in n
and yields the first n
jumping numbers.
$endgroup$
add a comment |
$begingroup$
Python 3, 122 121 bytes
g=lambda s:len(s)==1or 1==abs(ord(s[0])-ord(s[1]))and g(s[1:])
def f(n,i=1):
while n:
if g(str(i)):n-=1;yield i
i+=1
Try it online!
-1 byte by changing f
from printing, to a generator function.
g
is a recursive helper function which determines if a string s
is a "jumping string" (this works since the character codes for 0 to 9 are in order and contiguous).
f
is a generator function that takes in n
and yields the first n
jumping numbers.
$endgroup$
add a comment |
$begingroup$
Python 3, 122 121 bytes
g=lambda s:len(s)==1or 1==abs(ord(s[0])-ord(s[1]))and g(s[1:])
def f(n,i=1):
while n:
if g(str(i)):n-=1;yield i
i+=1
Try it online!
-1 byte by changing f
from printing, to a generator function.
g
is a recursive helper function which determines if a string s
is a "jumping string" (this works since the character codes for 0 to 9 are in order and contiguous).
f
is a generator function that takes in n
and yields the first n
jumping numbers.
$endgroup$
Python 3, 122 121 bytes
g=lambda s:len(s)==1or 1==abs(ord(s[0])-ord(s[1]))and g(s[1:])
def f(n,i=1):
while n:
if g(str(i)):n-=1;yield i
i+=1
Try it online!
-1 byte by changing f
from printing, to a generator function.
g
is a recursive helper function which determines if a string s
is a "jumping string" (this works since the character codes for 0 to 9 are in order and contiguous).
f
is a generator function that takes in n
and yields the first n
jumping numbers.
answered 10 hours ago
pizzapants184pizzapants184
2,714716
2,714716
add a comment |
add a comment |
$begingroup$
R, 85 bytes
i=scan();j=0;while(i)if((j=j+1)<10|all(abs(diff(j%/%10^(0:log10(j))%%10))==1))i=i-1;j
Try it online!
Suspect this can be golfed more. Reads the number using scan()
and outputs the appropriate jumping number.
$endgroup$
add a comment |
$begingroup$
R, 85 bytes
i=scan();j=0;while(i)if((j=j+1)<10|all(abs(diff(j%/%10^(0:log10(j))%%10))==1))i=i-1;j
Try it online!
Suspect this can be golfed more. Reads the number using scan()
and outputs the appropriate jumping number.
$endgroup$
add a comment |
$begingroup$
R, 85 bytes
i=scan();j=0;while(i)if((j=j+1)<10|all(abs(diff(j%/%10^(0:log10(j))%%10))==1))i=i-1;j
Try it online!
Suspect this can be golfed more. Reads the number using scan()
and outputs the appropriate jumping number.
$endgroup$
R, 85 bytes
i=scan();j=0;while(i)if((j=j+1)<10|all(abs(diff(j%/%10^(0:log10(j))%%10))==1))i=i-1;j
Try it online!
Suspect this can be golfed more. Reads the number using scan()
and outputs the appropriate jumping number.
answered 10 hours ago
Nick KennedyNick Kennedy
26115
26115
add a comment |
add a comment |
$begingroup$
Perl 5, 56 bytes
map{1while++$n=~s|.(?=(.))|abs$&-$1!=1|ger>9}1..<>;say$n
Try it online!
1-indexed, outputs the nth jumping number
$endgroup$
add a comment |
$begingroup$
Perl 5, 56 bytes
map{1while++$n=~s|.(?=(.))|abs$&-$1!=1|ger>9}1..<>;say$n
Try it online!
1-indexed, outputs the nth jumping number
$endgroup$
add a comment |
$begingroup$
Perl 5, 56 bytes
map{1while++$n=~s|.(?=(.))|abs$&-$1!=1|ger>9}1..<>;say$n
Try it online!
1-indexed, outputs the nth jumping number
$endgroup$
Perl 5, 56 bytes
map{1while++$n=~s|.(?=(.))|abs$&-$1!=1|ger>9}1..<>;say$n
Try it online!
1-indexed, outputs the nth jumping number
answered 7 hours ago
XcaliXcali
5,385520
5,385520
add a comment |
add a comment |
$begingroup$
Wolfram Language (Mathematica), 85 bytes
If[#<10,#,t=n=1;While[t<=#,{-1,1}~SubsetQ~Differences@IntegerDigits@n++~If~t++];n-1]&
Try it online!
returns the n-th number
$endgroup$
add a comment |
$begingroup$
Wolfram Language (Mathematica), 85 bytes
If[#<10,#,t=n=1;While[t<=#,{-1,1}~SubsetQ~Differences@IntegerDigits@n++~If~t++];n-1]&
Try it online!
returns the n-th number
$endgroup$
add a comment |
$begingroup$
Wolfram Language (Mathematica), 85 bytes
If[#<10,#,t=n=1;While[t<=#,{-1,1}~SubsetQ~Differences@IntegerDigits@n++~If~t++];n-1]&
Try it online!
returns the n-th number
$endgroup$
Wolfram Language (Mathematica), 85 bytes
If[#<10,#,t=n=1;While[t<=#,{-1,1}~SubsetQ~Differences@IntegerDigits@n++~If~t++];n-1]&
Try it online!
returns the n-th number
edited 5 hours ago
answered 5 hours ago
J42161217J42161217
13.1k21150
13.1k21150
add a comment |
add a comment |
If this is an answer to a challenge…
…Be sure to follow the challenge specification. However, please refrain from exploiting obvious loopholes. Answers abusing any of the standard loopholes are considered invalid. If you think a specification is unclear or underspecified, comment on the question instead.
…Try to optimize your score. For instance, answers to code-golf challenges should attempt to be as short as possible. You can always include a readable version of the code in addition to the competitive one.
Explanations of your answer make it more interesting to read and are very much encouraged.…Include a short header which indicates the language(s) of your code and its score, as defined by the challenge.
More generally…
…Please make sure to answer the question and provide sufficient detail.
…Avoid asking for help, clarification or responding to other answers (use comments instead).
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f180693%2fjumping-numbers%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
$begingroup$
Is this 0 or 1 Indexed?
$endgroup$
– Taylor Scott
13 hours ago
1
$begingroup$
@TaylorScott The sequence consists in only positive numbers. If you mean the input
n
then it is up to you.$endgroup$
– Luis felipe De jesus Munoz
13 hours ago
$begingroup$
I'm guessing "Any valid I/O format is allowed" includes outputting the numbers as lists of decimal digits, but just wanted to confirm - ?
$endgroup$
– Jonathan Allan
12 hours ago
$begingroup$
Yes @JonathanAllan
$endgroup$
– Luis felipe De jesus Munoz
12 hours ago