Eric likes to play with numbers. He has made this overview of numbers and Belgian flags. What series replaces the question marks?
Belgian numbers play a key role in the above puzzle. A number $$n \in \mathbb{N}$$ is a Belgian $$k$$-number ($$k \in \mathbb{N}$$) if it occurs in the infinite number sequence that begins with $$k$$ and whose differences between two consecutive numbers repeatedly equal the consecutive digits of $$n$$. The number $$k$$ is called the seed of the number sequence.
Suppose that $$k = 7$$. To check whether $$n = 152$$ is a Belgian 7-number, we construct the number sequence that begins with 7 and whose differences between consecutive numbers are equal to the repeated sequence +1, +5, +2, +1, +5, +2, +1, … (the consecutive digits of the number 152). This yields the number sequence
7, 8, 13, 15, 16, 21, 23, 24, 29, 31, …
If 152 occurs in this number sequence then it is a Belgian 7-number, which is indeed the case here. The number 108 is a Belgian 0-number, as follows from the number sequence
0, 1, 1, 9, 10, 10, 18, 19, 19, 27, …, 90, 91, 91, 99, 100, 100, 108, 109, 109, …
A number $$n \in \mathbb{N}$$ is a Flemish number if it is a Belgian $$k$$-number, with $$k$$ the first digit of $$n$$. As such, the number 179 is a Flemish number because it is a Belgian 1-number, as follows from the number sequence
1, 2, 9, 18, 19, 26, 35, 36, 43, 52, …, 154, 155, 162, 171, 172, 179, 188, 189, …
A number $$n \in \mathbb{N}$$ is a West Flemish number if it is a Flemish number whose number sequence starts with the digits of $$n$$, in the same order. As such, the number 8161 is a West Flemish number because it is a Belgian 8-number with number sequence
8, 16, 17, 23, 24, 32, 33, 39, 40, …, 8145, 8151, 8152, 8160, 8161, 8167, 8168, …
Your task:
Write a function sequence with a parameter n that takes a number $$n \in \mathbb{N}$$ (int). The function also has a second optional parameter k that may take a number $$k \in \mathbb{N}$$ (int, default value 0). The function also has a third optional parameter count that may take a natural number (int). If a value $$c$$ is explicitly passed to the parameter count, the function must return a list (list) containing the first $$c$$ numbers (int) from the number sequence that corresponds to $$n$$ and begins with $$k$$. If no value is explicitly passed to the parameter count, the function must return a list (list) containing the numbers (int) from the number sequence that corresponds to $$n$$ and begins with $$k$$, where the sequence ends with the first number that is greater than or equal to $$n$$.
Write a function isbelgian with a parameter n that takes a number $$n \in \mathbb{N}$$ (int). The function also has a second optional parameter k that may take a number $$k \in \mathbb{N}$$ (int, default value 0). The function must return a Boolean value (bool) that indicates whether $$n$$ is a Belgian $$k$$-number.
Write a function seeds with a parameter n that takes a number $$n \in \mathbb{N}$$ (int). The function must return an increasing list (list) containing all $$k \in \mathbb{N}$$ (int) for which $$n$$ is a Belgian $$k$$-number.
Write a function isflemish with a parameter n that takes a number $$n \in \mathbb{N}$$ (int). The function must return a Boolean value (bool) that indicates whether $$n$$ is a Flemish number.
Write a function iswestflemish with a parameter n that takes a number $$n \in \mathbb{N}$$ (int). The function must return a Boolean value (bool) that indicates whether $$n$$ is a West Flemish number.
>>> sequence(108)
[0, 1, 1, 9, 10, 10, 18, 19, 19, 27, 28, 28, 36, 37, 37, 45, 46, 46, 54, 55, 55, 63, 64, 64, 72, 73, 73, 81, 82, 82, 90, 91, 91, 99, 100, 100, 108]
>>> sequence(123, count=10)
[0, 1, 3, 6, 7, 9, 12, 13, 15, 18]
>>> sequence(n=81, k=1)
[1, 9, 10, 18, 19, 27, 28, 36, 37, 45, 46, 54, 55, 63, 64, 72, 73, 81]
>>> sequence(n=61, k=6)
[6, 12, 13, 19, 20, 26, 27, 33, 34, 40, 41, 47, 48, 54, 55, 61]
>>> isbelgian(81)
True
>>> isbelgian(108)
True
>>> isbelgian(n=81, k=1)
True
>>> isbelgian(n=108, k=1)
False
>>> seeds(108)
[0, 8, 9, 17, 18, 26, 27, 35, 36, 44, 45, 53, 54, 62, 63, 71, 72, 80, 81, 89, 90, 98, 99, 107, 108]
>>> seeds(81)
[0, 1, 9, 10, 18, 19, 27, 28, 36, 37, 45, 46, 54, 55, 63, 64, 72, 73, 81]
>>> isflemish(108)
False
>>> isflemish(81)
False
>>> isflemish(61)
True
>>> isflemish(68)
True
>>> iswestflemish(108)
False
>>> iswestflemish(81)
False
>>> iswestflemish(61)
True
>>> iswestflemish(68)
False
The Eric in the puzzle is a reference to the Belgian amateur mathematician Éric Angelini, who invented the Belgian numbers around 2005. He first called them Eric numbers, but later changed their name by analogy with Roman1, Arabic2 and Catalan3 numbers.
The names for the Flemish and West Flemish numbers have been invented for this assignment. There official names are self-Belgian numbers of the first and second kind.