Comments on Length of a Sumac Sequence
Parent
Length of a Sumac Sequence
Heavily based on this closed challenge from SE.
Description
A Sumac sequence starts with two non-zero integers
The next term,
More generally,
The sequence ends when
Challenge
Given two integers
If there is a negative number in the input, remove everything after it, and compute the length.
You may take the input in any way (Array, two numbers, etc.)
Test Cases
(Sequence is included for clarification)
[t1,t2] Sequence n
------------------------------
[120,71] [120,71,49,22,27] 5
[101,42] [101,42,59] 3
[500,499] [500,499,1,498] 4
[387,1] [387,1,386] 3
[3,-128] [3] 1
[-2,3] [] 0
[3,2] [3,2,1,1] 4
Scoring
This is code-golf. Shortest answer in each language wins.
[Raku], 19 bytes {( …
4y ago
[Python 3], 49 47 44 35 bytes …
4y ago
[C (gcc)], 32 bytes …
4y ago
Japt `-N`, 9 bytes ¨T©Ò …
4y ago
[JavaScript (Node.js)], 27 25 …
4y ago
[Scala], 83 bytes x …
4y ago
BQN, 15 bytesSBCS ``` {𝕨(1 …
4y ago
[Jelly], 9 bytes Rȧ@Rп …
4y ago
[JavaScript (Node.js)], 31 byt …
4y ago
1 comment thread