Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

Return to Answer

added 311 characters in body
Source Link
Kevin Cruijssen
  • 136.2k
  • 14
  • 154
  • 394

05AB1E, 23(削除) 23 (削除ここまで) 22 bytes

>LÅfü2ε'+ý ̄Oú'=y¬g>ˆOJÌLÅfü3ε„+=.ιJ ̄Oú,yнg>ˆ

-1 byte after being inspired by @JonathanAllan's Jelly answer

Outputs the first \$n\$ lines.

Try it online. Try it online.

TheOr a minor 22 bytes alternative:

ÌLÅfDü3„+=δ.ιJs€g>.\ú»

Try it online.

And the infinite sequence would be 2322 bytes as well:

∞Åfü2vy'+ý ̄Oú'=y¬g>ˆOJ∞Åfü3vy„+=.ιJ ̄Oú,yнg>ˆ

Try it online. Try it online.

>Ì # Increase the (implicit) input-integer by 12
 L # Pop and push a list in the range [1,input+1]input+2]
 Åf # Get the 0-based n'th Fibonacci value for each of these
 ü2ü3 # Pop and push all overlapping pairstriplets of this list
 ε # Foreach over the pairstriplets:
 # (implicitly push the paircurrent triplet)
 '+ý  „+=.ι '# # Join theIntersperse pairit with "+" delimiterand "=" delimiters
 J # Join this list together to a string
  ̄ # Push the global_array (empty by default)
 O O # Sum it together
 ú ú # Pad the string with that many leading spaces
 '= , '# Push# a "="
Pop and output this line with trailing newline
  y # Push the pair again
 н ¬ # PushPop and push its first item (without popping the pair)
 g # Pop and push its length
 > # Increase it by 1
 ˆ # Pop and add it to the global_array
 O # Sum the pair
 J # Join the three values on the stack together
 , # Pop and output this line with trailing newline

05AB1E, 23 bytes

>LÅfü2ε'+ý ̄Oú'=y¬g>ˆOJ,

Outputs the first \$n\$ lines.

Try it online.

The infinite sequence would be 23 bytes as well:

∞Åfü2vy'+ý ̄Oú'=y¬g>ˆOJ,

Try it online.

> # Increase the (implicit) input-integer by 1
 L # Pop and push a list in the range [1,input+1]
 Åf # Get the 0-based n'th Fibonacci value for each of these
 ü2 # Pop and push all overlapping pairs of this list
 ε # Foreach over the pairs:
 # (implicitly push the pair)
 '+ý  '# Join the pair with "+" delimiter
 ̄ # Push the global_array (empty by default)
 O # Sum it together
 ú # Pad the string with that many leading spaces
 '= '# Push a "="
 y # Push the pair again
 ¬ # Push its first item (without popping the pair)
 g # Pop and push its length
 > # Increase it by 1
 ˆ # Pop and add it to the global_array
 O # Sum the pair
 J # Join the three values on the stack together
 , # Pop and output this line with trailing newline

05AB1E, (削除) 23 (削除ここまで) 22 bytes

ÌLÅfü3ε„+=.ιJ ̄Oú,yнg>ˆ

-1 byte after being inspired by @JonathanAllan's Jelly answer

Outputs the first \$n\$ lines.

Try it online.

Or a minor 22 bytes alternative:

ÌLÅfDü3„+=δ.ιJs€g>.\ú»

Try it online.

And the infinite sequence would be 22 bytes as well:

∞Åfü3vy„+=.ιJ ̄Oú,yнg>ˆ

Try it online.

Ì # Increase the (implicit) input-integer by 2
 L # Pop and push a list in the range [1,input+2]
 Åf # Get the 0-based n'th Fibonacci value for each of these
 ü3 # Pop and push all overlapping triplets of this list
 ε # Foreach over the triplets:
 # (implicitly push the current triplet)
 „+=.ι # Intersperse it with "+" and "=" delimiters
 J # Join this list together to a string
  ̄ # Push the global_array (empty by default)
 O # Sum it together
 ú # Pad the string with that many leading spaces
 , # Pop and output this line with trailing newline
  y # Push the pair again
 н # Pop and push its first item
 g # Pop and push its length
 > # Increase it by 1
 ˆ # Pop and add it to the global_array
Source Link
Kevin Cruijssen
  • 136.2k
  • 14
  • 154
  • 394

05AB1E, 23 bytes

>LÅfü2ε'+ý ̄Oú'=y¬g>ˆOJ,

Outputs the first \$n\$ lines.

Try it online.

The infinite sequence would be 23 bytes as well:

∞Åfü2vy'+ý ̄Oú'=y¬g>ˆOJ,

Try it online.

Explanation:

> # Increase the (implicit) input-integer by 1
 L # Pop and push a list in the range [1,input+1]
 Åf # Get the 0-based n'th Fibonacci value for each of these
 ü2 # Pop and push all overlapping pairs of this list
 ε # Foreach over the pairs:
 # (implicitly push the pair)
 '+ý '# Join the pair with "+" delimiter
 ̄ # Push the global_array (empty by default)
 O # Sum it together
 ú # Pad the string with that many leading spaces
 '= '# Push a "="
 y # Push the pair again
 ¬ # Push its first item (without popping the pair)
 g # Pop and push its length
 > # Increase it by 1
 ˆ # Pop and add it to the global_array
 O # Sum the pair
 J # Join the three values on the stack together
 , # Pop and output this line with trailing newline

AltStyle によって変換されたページ (->オリジナル) /