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 Revisions

2 of 3
added 315 characters in body
Jonathan Allan
  • 115.4k
  • 8
  • 68
  • 293

Jelly, 7 bytes

rAẇ@5ドルS

TryItOnline!

Input: Start, End, ToFind

How?

rAẇ@5ドルS - Main link: Start, End, ToFind
r - range: [Start, ..., End]
 A - absolute values
 5 - third input: ToFind
 ẇ@€ - sublist exists in with reversed @rguments for €ach
 S - sum

The default casting of an integer to an iterable for the sublist existence check casts to a decimal list (not a character list), so negative numbers have a leading negative value (e.g. -122->[-1,2,2] which won't find a sublist of [1,2]) so taking the absolute value first seems like the golfiest solution.

Jonathan Allan
  • 115.4k
  • 8
  • 68
  • 293

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