Skip to main content

Challenge

Here at PPCG, we sure do like our sequences, so here's a fun another one.

Let's define a(n) as being the smallest non-negative integer X such that is not equal to any a(k) is not X with (0 < k < n), and a(n-1) and X do not share any decimal digits. a(0) = 0

Given an input n > 0, output such a(n).

For example, for input n = 13, we have a(13) = 20, since a(12) = 11 and 20 is the smallest non-negative integer we haven't seen yet that doesn't share any decimal digits with 11.

Sequence

Here are the first 20 terms to get you started. This is sequence A067581 on OEIS.

0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 22, 11, 20, 13, 24, 15, 23, 14, 25 

Rules

  • The input and output can be assumed to fit in your language's native integer type.
  • The input and output can be given in any convenient format.
  • You can choose to either 0-index, as I am here in my examples, or 1-index for your submission. Please state which you're doing.
  • Either a full program or a function are acceptable. If a function, you can return the output rather than printing it.
  • If possible, please include a link to an online testing environment so other people can try out your code!
  • Standard loopholes are forbidden.
  • This is so all usual golfing rules apply, and the shortest code (in bytes) wins.

Challenge

Here at PPCG, we sure do like our sequences, so here's a fun another one.

Let's define a(n) as being the smallest non-negative integer X such that a(k) is not X with 0 < k < n, and a(n-1) and X do not share any decimal digits. a(0) = 0

Given an input n > 0, output such a(n).

For example, for input n = 13, we have a(13) = 20, since a(12) = 11 and 20 is the smallest non-negative integer we haven't seen yet that doesn't share any decimal digits with 11.

Sequence

Here are the first 20 terms to get you started. This is sequence A067581 on OEIS.

0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 22, 11, 20, 13, 24, 15, 23, 14, 25 

Rules

  • The input and output can be assumed to fit in your language's native integer type.
  • The input and output can be given in any convenient format.
  • You can choose to either 0-index, as I am here in my examples, or 1-index for your submission. Please state which you're doing.
  • Either a full program or a function are acceptable. If a function, you can return the output rather than printing it.
  • If possible, please include a link to an online testing environment so other people can try out your code!
  • Standard loopholes are forbidden.
  • This is so all usual golfing rules apply, and the shortest code (in bytes) wins.

Challenge

Here at PPCG, we sure do like our sequences, so here's a fun another one.

Let's define a(n) as being the smallest non-negative integer X that is not equal to any a(k) (0 < k < n), and a(n-1) and X do not share any decimal digits. a(0) = 0

Given an input n > 0, output such a(n).

For example, for input n = 13, we have a(13) = 20, since a(12) = 11 and 20 is the smallest non-negative integer we haven't seen yet that doesn't share any decimal digits with 11.

Sequence

Here are the first 20 terms to get you started. This is sequence A067581 on OEIS.

0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 22, 11, 20, 13, 24, 15, 23, 14, 25 

Rules

  • The input and output can be assumed to fit in your language's native integer type.
  • The input and output can be given in any convenient format.
  • You can choose to either 0-index, as I am here in my examples, or 1-index for your submission. Please state which you're doing.
  • Either a full program or a function are acceptable. If a function, you can return the output rather than printing it.
  • If possible, please include a link to an online testing environment so other people can try out your code!
  • Standard loopholes are forbidden.
  • This is so all usual golfing rules apply, and the shortest code (in bytes) wins.
Tweeted twitter.com/StackCodeGolf/status/895885696673632256
edited tags
Link
DanTheMan
  • 4.1k
  • 17
  • 41
Added 1-indexing allowance
Source Link
AdmBorkBork
  • 43.7k
  • 5
  • 107
  • 288

Challenge

Here at PPCG, we sure do like our sequences, so here's a fun another one.

Let's define a(n) as being the smallest non-negative integer X such that a(k) is not X with 0 < k < n, and a(n-1) and X do not share any decimal digits. a(0) = 0

Given an input n > 0, output such a(n).

For example, for input n = 13, we have a(13) = 20, since a(12) = 11 and 20 is the smallest non-negative integer we haven't seen yet that doesn't share any decimal digits with 11.

Sequence

Here are the first 20 terms to get you started. This is sequence A067581 on OEIS.

0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 22, 11, 20, 13, 24, 15, 23, 14, 25 

Rules

  • The input and output can be assumed to fit in your language's native integer type.
  • The input and output can be given in any convenient format.
  • You can choose to either 0-index, as I am here in my examples, or 1-index for your submission. Please state which you're doing.
  • Either a full program or a function are acceptable. If a function, you can return the output rather than printing it.
  • If possible, please include a link to an online testing environment so other people can try out your code!
  • Standard loopholes are forbidden.
  • This is so all usual golfing rules apply, and the shortest code (in bytes) wins.

Challenge

Here at PPCG, we sure do like our sequences, so here's a fun another one.

Let's define a(n) as being the smallest non-negative integer X such that a(k) is not X with 0 < k < n, and a(n-1) and X do not share any decimal digits. a(0) = 0

Given an input n > 0, output such a(n).

For example, for input n = 13, we have a(13) = 20, since a(12) = 11 and 20 is the smallest non-negative integer we haven't seen yet that doesn't share any decimal digits with 11.

Sequence

Here are the first 20 terms to get you started. This is sequence A067581 on OEIS.

0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 22, 11, 20, 13, 24, 15, 23, 14, 25 

Rules

  • The input and output can be assumed to fit in your language's native integer type.
  • The input and output can be given in any convenient format.
  • Either a full program or a function are acceptable. If a function, you can return the output rather than printing it.
  • If possible, please include a link to an online testing environment so other people can try out your code!
  • Standard loopholes are forbidden.
  • This is so all usual golfing rules apply, and the shortest code (in bytes) wins.

Challenge

Here at PPCG, we sure do like our sequences, so here's a fun another one.

Let's define a(n) as being the smallest non-negative integer X such that a(k) is not X with 0 < k < n, and a(n-1) and X do not share any decimal digits. a(0) = 0

Given an input n > 0, output such a(n).

For example, for input n = 13, we have a(13) = 20, since a(12) = 11 and 20 is the smallest non-negative integer we haven't seen yet that doesn't share any decimal digits with 11.

Sequence

Here are the first 20 terms to get you started. This is sequence A067581 on OEIS.

0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 22, 11, 20, 13, 24, 15, 23, 14, 25 

Rules

  • The input and output can be assumed to fit in your language's native integer type.
  • The input and output can be given in any convenient format.
  • You can choose to either 0-index, as I am here in my examples, or 1-index for your submission. Please state which you're doing.
  • Either a full program or a function are acceptable. If a function, you can return the output rather than printing it.
  • If possible, please include a link to an online testing environment so other people can try out your code!
  • Standard loopholes are forbidden.
  • This is so all usual golfing rules apply, and the shortest code (in bytes) wins.
Source Link
AdmBorkBork
  • 43.7k
  • 5
  • 107
  • 288
Loading