Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Challenges

Post History

75%
+4 −0
Challenges Length of a Sumac Sequence

Raku, 19 bytes {(|@_,*-*...0>*)-1} Try it online! { } # Anonymous code block ... # Create a sequence |@_ # Starting with the input ...

posted 3y ago by Jo King‭

Answer
#1: Initial revision by user avatar Jo King‭ · 2020-11-17T02:58:43Z (over 3 years ago)
# [Raku], 19 bytes

<!-- language-all: lang-perl6 -->

    {(|@_,*-*...0>*)-1}

[Try it online!][TIO-khldvh9f]

[Raku]: https://github.com/nxadm/rakudo-pkg
[TIO-khldvh9f]: https://tio.run/##TcpNCsIwEIbhvaeYlbSlGSY/te2ixXuEIIINCK2VZCFFPZk7LxbTiOAHs5iH9zq4cRemBbYWunDPHvtDWbACEakvcsafwR8XsBlqMiVqbnLoekAtDNjZwXi@DP79wtvsTj5AHBcEUHNIqzaJKL5KfEkmqihWqm0TqUSyqWMK/5WMx7hoEvGVmPj5OvoA "Perl 6 – Try It Online"

~~~
{                 }  # Anonymous code block
         ...         # Create a sequence
  |@_                # Starting with the input
     ,*-*            # With each element being the difference between the previous two
            0>*      # Until it is negative
 (             )-1   # And return the length of the list minus one
~~~