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

60%
+1 −0
Challenges Calculate the Z-array

Japt, 11 bytes £ígUsY)ô²ÎÊ Try it £ígUsY)ô²ÎÊ :Implicit input of array U £ :Map each element at 0-based index Y í : Interleave U with UsY : U...

posted 5mo ago by Shaggy‭  ·  edited 5mo ago by Shaggy‭

Answer
#2: Post edited by user avatar Shaggy‭ · 2026-04-14T08:21:20Z (5 months ago)
  • # [Japt](https://github.com/ETHproductions/japt), 11 [bytes](https://en.wikipedia.org/wiki/ISO/IEC_8859-1)
  • £ígUsY)ô²ÎÊ
  • [Try it](https://petershaggynoble.github.io/Japt-Interpreter/?v=1.4.6&code=o%2b1nVXNZKfSyzso&input=WzEsMiwyLDEsMSwyLDEsMiwyLDEsMiwxXQ)
  • No idea how to measure time complexity.
  • # [Japt](https://github.com/ETHproductions/japt), 11 [bytes](https://en.wikipedia.org/wiki/ISO/IEC_8859-1)
  • £ígUsY)ô²ÎÊ
  • [Try it](https://petershaggynoble.github.io/Japt-Interpreter/?v=1.4.6&code=o%2b1nVXNZKfSyzso&input=WzEsMiwyLDEsMSwyLDEsMiwyLDEsMiwxXQ)
  • £ígUsY)ô²ÎÊ :Implicit input of array U
  • £ :Map each element at 0-based index Y
  • í : Interleave U with
  • UsY : U sliced to index Y
  • g : Reducing each pair by the sign of its difference
  • ) : End interlave
  • ô : Split on elements that return truthy* (not 0) when
  • ² : Squared
  • Î : First element
  • Ê : Length
  • *The `ô` method is _supposed_ to split arrays on elements that return a falsey value but, for some reason, some methods have the opposite effect, such as the exponentiation used here.
  • No idea how to measure time complexity.
#1: Initial revision by user avatar Shaggy‭ · 2026-04-12T13:02:22Z (5 months ago)
# [Japt](https://github.com/ETHproductions/japt), 11 [bytes](https://en.wikipedia.org/wiki/ISO/IEC_8859-1)

    £ígUsY)ô²ÎÊ

[Try it](https://petershaggynoble.github.io/Japt-Interpreter/?v=1.4.6&code=o%2b1nVXNZKfSyzso&input=WzEsMiwyLDEsMSwyLDEsMiwyLDEsMiwxXQ)

No idea how to measure time complexity.