Challenge:
A Frog List is defined by certain rules:
- Each frog within a Frog List has an unique positive digit
[1-9]
as id (any0
in a list is basically an empty spot, which can mostly be ignored). - A Frog List will always have exactly one Lazy Frog. A Lazy Frog will remain at its position.
- Every other frog in a Frog List will jump at least once, and will always jump towards the right from its starting position.
- When a frog jumps, the distance of its jump is always the same.
- When a frog jumps, it will continue jumping until it's outside the list's right bound.
- 0-1 jumping frogs can stand on top of a Lazy Frog, as long as their summed ids is still a single digit. (Jumping frogs cannot stand on top of one another! Which implicitly also means there cannot be two jumping frogs on a Lazy Frog simultaneously.)
Note that the frog-ids within a Frog List describe how a frog has already jumped (past sense). Focusing on an individual frog-id within a Frog List shows how it has jumped, and at what positions within the Frog List it has landed, and jumped onward from - with the exception of the Lazy Frog, which hasn't moved.
Worked out explanation of the Frog List [1,2,1,0,8,2]
:
- The Lazy Frog has id \$\color{green}{7}\$ at position
~~~~7~
:
- The first jumping frog has id \$\color{red}{1}\$ at positions
1~1~1~
with jump distance 2:
- The second jumping frog has id \$\color{blue}{2}\$ at positions
~2~~~2
with jump distance 4:
All three frogs summed gives the Frog List [1,2,1,0,8,2]
, so [1,2,1,0,8,2]
would be truthy:
All Test cases including explanation:
Input Explanation:
Truthy:
[1,2,1,0,8,2] Lazy Frog 7 doesn't jump ~~~~7~
frog 1 jumps (with jumping distance 2) 1~1~1~
frog 2 jumps (with jumping distance 4) ~2~~~2
[1,0,0,0,0,1,2,7,2,2] Lazy Frog 5 doesn't jump ~~~~~~~5~~
frog 1 jumps (with jumping distance 5) 1~~~~1~~~~
frog 2 jumps (with jumping distance 1) ~~~~~~2222
[9,8,9,1] Lazy Frog 7 doesn't jump ~7~~
frog 1 jumps (with jumping distance 2) ~1~1
frog 9 jumps (with jumping distance 2) 9~9~
[1,0,1,3,3,3,1] Lazy Frog 2 doesn't jump ~~~~2~~
frog 1 jumps (with jumping distance 2) 1~1~1~1
frog 3 jumps (with jumping distance 2) ~~~3~3~
(Note that the 3 at ~~~~3~~ is Lazy Frog 2 and jumping frog 1 on top of one another,
and not jumping frog 3!)
[7] A single Lazy Frog 7
[7,0,0,0] A single Lazy Frog 7~~~
[8,1,1] Lazy Frog 8 doesn't jump 8~~
frog 1 jumps (with jumping distance 1) ~11
OR alternatively:
Lazy Frog 7 doesn't jump 7~~
frog 1 jumps (with jumping distance 1) 111
Falsey:
[1,2,3,0,2,1,3] (rule 2) there is no Lazy Frog: 1~~~~1~
~2~~2~~
~~3~~~3
[1,6,1,8,6,1] (rule 4) frog 1 jumps irregular 1~1~~1 / 1~11~1
~6~~6~ / ~6~~6~
~~~8~~ / ~~~7~~
[2,8,2,8,0,9] (rule 5) frog 2 stopped jumping 2~2~~~
~~~~~1
~8~8~8
[1,2,3,2,7] (rule 6) two jumping frogs at the last position with: 1~~~1
~2~2~
~~3~3
(Lazy)~~~~4
^
OR two jumping frogs at the third and last positions with: 1~1~1
~2222
(Lazy)~~~~4
^ ^
[2,1] (rule 2+3) There are two Lazy Frogs without jumping frogs: ~1
2~
OR (rule 1) The Lazy and jumping frog would both have id=1: 11
1~
Here are all Frog Lists (as integers) of 3 or less digits:
[1,2,3,4,5,6,7,8,9,10,13,14,15,16,17,18,19,20,23,25,26,27,28,29,30,31,32,34,35,37,38,39,40,41,43,45,46,47,49,50,51,52,53,54,56,57,58,59,60,61,62,64,65,67,68,69,70,71,72,73,74,75,76,78,79,80,81,82,83,85,86,87,89,90,91,92,93,94,95,96,97,98,100,103,104,105,106,107,108,109,113,114,115,116,117,118,119,121,122,131,133,141,144,151,155,161,166,171,177,181,188,191,199,200,203,205,206,207,208,209,211,212,223,225,226,227,228,229,232,233,242,244,252,255,262,266,272,277,282,288,292,299,300,301,302,304,305,307,308,309,311,313,322,323,334,335,337,338,339,343,344,353,355,363,366,373,377,383,388,393,399,400,401,403,405,406,407,409,411,414,422,424,433,434,445,446,447,449,454,455,464,466,474,477,484,488,494,499,500,501,502,503,504,506,507,508,509,511,515,522,525,533,535,544,545,556,557,558,559,565,566,575,577,585,588,595,599,600,601,602,604,605,607,608,609,611,616,622,626,633,636,644,646,655,656,667,668,669,676,677,686,688,696,699,700,701,702,703,704,705,706,708,709,711,717,722,727,733,737,744,747,755,757,766,767,778,779,787,788,797,799,800,801,802,803,805,806,807,809,811,818,822,828,833,838,844,848,855,858,866,868,877,878,889,898,899,900,901,902,903,904,905,906,907,908,911,919,922,929,933,939,944,949,955,959,966,969,977,979,988,989]
Challenge rules:
- The integers in the input-list are guaranteed to be \$0\leq n\leq9\$ (aka single digits).
- Any single-value inputs are Frog List, since they'll contain a single Lazy Frog and no jumping frogs.
- I/O is flexible. You may take the input as a list/array/stream of digits, an integer, a string, etc. You may output any two values or type of values (not necessarily distinct) to indicate truthy/falsey respectively.
- You can assume a Frog List will never start with a
0
(doesn't matter too much for list I/O, but can be for integer I/O).
General Rules:
- This is code-golf, so the shortest answer in bytes wins.
Don't let code-golf languages discourage you from posting answers with non-codegolfing languages. Try to come up with an as short as possible answer for 'any' programming language. - Standard rules apply for your answer with default I/O rules, so you are allowed to use STDIN/STDOUT, functions/method with the proper parameters and return-type, full programs. Your call.
- Default Loopholes are forbidden.
- If possible, please add a link with a test for your code (e.g. TIO).
- Also, adding an explanation for your answer is highly recommended.