Skip to main content
deleted 1249 characters in body
Source Link
pxeger
  • 24.6k
  • 27
  • 34

Fill in the next numbers

Given a list of integers, output a list where the \$ i \$th element of the list equals the first number in the input list which is \$ \ge i \$, until there are no such numbers.

For example, if the input is:

2 3 5 7 11

then we "expand" the sequence out to show where the gaps are:

_ 2 3 _ 5 _ 7 _ _ __ 11     # input
1     4   6   8 9 10        # gaps

Now we fill in the blanks with the next number that is in the sequence in each case:

2 2 3 5 5 7 7 11 11 11 11
1     4   6    8  9 10

This is the output.

Test cases

[1]               -> [1]
[3]               -> [3, 3, 3]
[1, 2, 3]         -> [1, 2, 3]
[1, 3, 4, 9]      -> [1, 3, 3, 4, 9, 9, 9, 9, 9]
[2, 3, 5, 7, 11]  -> [2, 2, 3, 5, 5, 7, 7, 11, 11, 11, 11]

Rules


MetaFill in the next numbers

  • Better title?
  • Is this a duplicate?
    • Probably
  • Is this clear enough?
  • Any other feedback?

Fill in the next numbers

Given a list of integers, output a list where the \$ i \$th element of the list equals the first number in the input list which is \$ \ge i \$, until there are no such numbers.

For example, if the input is:

2 3 5 7 11

then we "expand" the sequence out to show where the gaps are:

_ 2 3 _ 5 _ 7 _ _ __ 11     # input
1     4   6   8 9 10        # gaps

Now we fill in the blanks with the next number that is in the sequence in each case:

2 2 3 5 5 7 7 11 11 11 11
1     4   6    8  9 10

This is the output.

Test cases

[1]               -> [1]
[3]               -> [3, 3, 3]
[1, 2, 3]         -> [1, 2, 3]
[1, 3, 4, 9]      -> [1, 3, 3, 4, 9, 9, 9, 9, 9]
[2, 3, 5, 7, 11]  -> [2, 2, 3, 5, 5, 7, 7, 11, 11, 11, 11]

Rules


Meta

  • Better title?
  • Is this a duplicate?
    • Probably
  • Is this clear enough?
  • Any other feedback?
deleted 27 characters in body
Source Link
pxeger
  • 24.6k
  • 27
  • 34

Fill in the next numbers

Given a list of integers, output a list where the \$ i \$th element of the list equals the first number in the input list which is \$ \ge i \$, until there are no such numbers.

For example, if the input is the first 5 prime numbers:

2 3 5 7 11

then we "expand" the sequence out to show where the gaps are:

_ 2 3 _ 5 _ 7 _ _ __ 11     # primesinput
1     4   6   8 9 10        # gaps

Now we fill in the blanks with the next number that is in the sequence in each case:

2 2 3 5 5 7 7 11 11 11 11
1     4   6    8  9 10

This is the output.

Test cases

[1]               -> [1]
[3]               -> [3, 3, 3]
[1, 2, 3]         -> [1, 2, 3]
[1, 3, 4, 9]      -> [1, 3, 3, 4, 9, 9, 9, 9, 9]
[2, 3, 5, 7, 11]  -> [2, 2, 3, 5, 5, 7, 7, 11, 11, 11, 11]

Rules


Meta

  • Better title?
  • Is this a duplicate?
    • Probably
  • Is this clear enough?
  • Any other feedback?

Fill in the next numbers

Given a list of integers, output a list where the \$ i \$th element of the list equals the first number in the input list which is \$ \ge i \$, until there are no such numbers.

For example, if the input is the first 5 prime numbers:

2 3 5 7 11

then we "expand" the sequence out to show where the gaps are:

_ 2 3 _ 5 _ 7 _ _ __ 11     # primes
1     4   6   8 9 10        # gaps

Now we fill in the blanks with the next number that is in the sequence in each case:

2 2 3 5 5 7 7 11 11 11 11
1     4   6    8  9 10

This is the output.

Test cases

[1]               -> [1]
[3]               -> [3, 3, 3]
[1, 2, 3]         -> [1, 2, 3]
[1, 3, 4, 9]      -> [1, 3, 3, 4, 9, 9, 9, 9, 9]
[2, 3, 5, 7, 11]  -> [2, 2, 3, 5, 5, 7, 7, 11, 11, 11, 11]

Rules


Meta

  • Better title?
  • Is this a duplicate?
    • Probably
  • Is this clear enough?
  • Any other feedback?

Fill in the next numbers

Given a list of integers, output a list where the \$ i \$th element of the list equals the first number in the input list which is \$ \ge i \$, until there are no such numbers.

For example, if the input is:

2 3 5 7 11

then we "expand" the sequence out to show where the gaps are:

_ 2 3 _ 5 _ 7 _ _ __ 11     # input
1     4   6   8 9 10        # gaps

Now we fill in the blanks with the next number that is in the sequence in each case:

2 2 3 5 5 7 7 11 11 11 11
1     4   6    8  9 10

This is the output.

Test cases

[1]               -> [1]
[3]               -> [3, 3, 3]
[1, 2, 3]         -> [1, 2, 3]
[1, 3, 4, 9]      -> [1, 3, 3, 4, 9, 9, 9, 9, 9]
[2, 3, 5, 7, 11]  -> [2, 2, 3, 5, 5, 7, 7, 11, 11, 11, 11]

Rules


Meta

  • Better title?
  • Is this a duplicate?
    • Probably
  • Is this clear enough?
  • Any other feedback?
edited body
Source Link
pxeger
  • 24.6k
  • 27
  • 34

Fill in the next numbers

Given a list of integers, output a list where the \$ i \$th element of the list equals the first number in the input list which is \$ \ge i \$, until there are no such numbers.

For example, if the input is the first 5 prime numbers:

2 3 5 7 11

then we "expand" the sequence out to show where the gaps are:

 _ 2 3  _ 5  _ 7     _ _ __ 11     # primes
1     4   6   8 9 10        # gaps

Now we fill in the blanks with the next number that is in the sequence in each case:

2 2 3 5 5 7 7 11 11 11 11
1     4   6    8  9 10

This is ourthe output.

Test cases

[1]               -> [1]
[3]               -> [3, 3, 3]
[1, 2, 3]         -> [1, 2, 3]
[1, 3, 4, 9]      -> [1, 3, 3, 4, 9, 9, 9, 9, 9]
[2, 3, 5, 7, 11]  -> [2, 2, 3, 5, 5, 7, 7, 11, 11, 11, 11]

Rules


Meta

  • Better title?
  • Is this a duplicate?
    • Probably
  • Is this clear enough?
  • Any other feedback?

Fill in the next numbers

Given a list of integers, output a list where the \$ i \$th element of the list equals the first number in the input list which is \$ \ge i \$, until there are no such numbers.

For example, if the input is the first 5 prime numbers:

2 3 5 7 11

then we "expand" the sequence out to show where the gaps are:

  2 3   5   7        11     # primes
1     4   6   8 9 10        # gaps

Now we fill in the blanks with the next number that is in the sequence in each case:

2 2 3 5 5 7 7 11 11 11 11
1     4   6    8  9 10

This is our output.

Test cases

[1]               -> [1]
[3]               -> [3, 3, 3]
[1, 2, 3]         -> [1, 2, 3]
[1, 3, 4, 9]      -> [1, 3, 3, 4, 9, 9, 9, 9, 9]
[2, 3, 5, 7, 11]  -> [2, 2, 3, 5, 5, 7, 7, 11, 11, 11, 11]

Rules


Meta

  • Better title?
  • Is this a duplicate?
    • Probably
  • Is this clear enough?
  • Any other feedback?

Fill in the next numbers

Given a list of integers, output a list where the \$ i \$th element of the list equals the first number in the input list which is \$ \ge i \$, until there are no such numbers.

For example, if the input is the first 5 prime numbers:

2 3 5 7 11

then we "expand" the sequence out to show where the gaps are:

_ 2 3 _ 5 _ 7 _ _ __ 11     # primes
1     4   6   8 9 10        # gaps

Now we fill in the blanks with the next number that is in the sequence in each case:

2 2 3 5 5 7 7 11 11 11 11
1     4   6    8  9 10

This is the output.

Test cases

[1]               -> [1]
[3]               -> [3, 3, 3]
[1, 2, 3]         -> [1, 2, 3]
[1, 3, 4, 9]      -> [1, 3, 3, 4, 9, 9, 9, 9, 9]
[2, 3, 5, 7, 11]  -> [2, 2, 3, 5, 5, 7, 7, 11, 11, 11, 11]

Rules


Meta

  • Better title?
  • Is this a duplicate?
    • Probably
  • Is this clear enough?
  • Any other feedback?
added 50 characters in body
Source Link
pxeger
  • 24.6k
  • 27
  • 34
Loading
edited body
Source Link
pxeger
  • 24.6k
  • 27
  • 34
Loading
Source Link
pxeger
  • 24.6k
  • 27
  • 34
Loading