Skip to main content
deleted 1090 characters in body
Source Link
badatgolf
  • 1.5k
  • 3
  • 7

Make the list Fibonacci-likeMake the list Fibonacci-like


Challenge

A list of integer \$a\$1, \$a\$2, \$a\$3, ..., \$a\$n (\$ n ≥ 1 \$) is Fibonacci-like if \$a\$i \$=\$ \$a\$i - 1 \$+\$ \$a\$i - 2 for every \$i ≥ 2\$. Note that every list that contains only 1 or 2 integers are Fibonacci-like.

For example, \$[1]\$, \$[6, 9]\$, \$[6, -4, 2, -2, 0, -2, -2, -4, -6, 10]\$, \$[7, -1, 6, 5, 11, 16, 27]\$ are Fibonacci-like lists.

Your task is, given a list, to determine the minimum amount of numbers that you have to remove from the list to make it Fibonacci-like.

For example, in \$[9, 7, -1, 6, 5, 2, 11, 16, 27]\$, you have to remove 2 numbers at minimun (\$9\$ and \$2\$) to transform the list into \$[7, -1, 6, 5, 11, 16, 27]\$, which is a Fibonacci-like list.

Input/Output

Input/Output can be taken in any resonable format, taking a list of numbers and returns the minimun number to complete the task.

Testcase:

[1, 2] -> 0
[5, 4, 9, 2] -> 1
[9, 7, -1, 6, 5, 2, 11, 16, 27] -> 2

more in progress...

This is , so shortest answer (in bytes) wins!

Make the list Fibonacci-like


Challenge

A list of integer \$a\$1, \$a\$2, \$a\$3, ..., \$a\$n (\$ n ≥ 1 \$) is Fibonacci-like if \$a\$i \$=\$ \$a\$i - 1 \$+\$ \$a\$i - 2 for every \$i ≥ 2\$. Note that every list that contains only 1 or 2 integers are Fibonacci-like.

For example, \$[1]\$, \$[6, 9]\$, \$[6, -4, 2, -2, 0, -2, -2, -4, -6, 10]\$, \$[7, -1, 6, 5, 11, 16, 27]\$ are Fibonacci-like lists.

Your task is, given a list, to determine the minimum amount of numbers that you have to remove from the list to make it Fibonacci-like.

For example, in \$[9, 7, -1, 6, 5, 2, 11, 16, 27]\$, you have to remove 2 numbers at minimun (\$9\$ and \$2\$) to transform the list into \$[7, -1, 6, 5, 11, 16, 27]\$, which is a Fibonacci-like list.

Input/Output

Input/Output can be taken in any resonable format, taking a list of numbers and returns the minimun number to complete the task.

Testcase:

[1, 2] -> 0
[5, 4, 9, 2] -> 1
[9, 7, -1, 6, 5, 2, 11, 16, 27] -> 2

more in progress...

This is , so shortest answer (in bytes) wins!

Source Link
badatgolf
  • 1.5k
  • 3
  • 7

Make the list Fibonacci-like


Challenge

A list of integer \$a\$1, \$a\$2, \$a\$3, ..., \$a\$n (\$ n ≥ 1 \$) is Fibonacci-like if \$a\$i \$=\$ \$a\$i - 1 \$+\$ \$a\$i - 2 for every \$i ≥ 2\$. Note that every list that contains only 1 or 2 integers are Fibonacci-like.

For example, \$[1]\$, \$[6, 9]\$, \$[6, -4, 2, -2, 0, -2, -2, -4, -6, 10]\$, \$[7, -1, 6, 5, 11, 16, 27]\$ are Fibonacci-like lists.

Your task is, given a list, to determine the minimum amount of numbers that you have to remove from the list to make it Fibonacci-like.

For example, in \$[9, 7, -1, 6, 5, 2, 11, 16, 27]\$, you have to remove 2 numbers at minimun (\$9\$ and \$2\$) to transform the list into \$[7, -1, 6, 5, 11, 16, 27]\$, which is a Fibonacci-like list.

Input/Output

Input/Output can be taken in any resonable format, taking a list of numbers and returns the minimun number to complete the task.

Testcase:

[1, 2] -> 0
[5, 4, 9, 2] -> 1
[9, 7, -1, 6, 5, 2, 11, 16, 27] -> 2

more in progress...

This is , so shortest answer (in bytes) wins!