Skip to main content
added 264 characters in body
Source Link
Jonathan Allan
  • 110.1k
  • 7
  • 65
  • 282

Jelly, 7 7  6 bytes

-1 thanks to caird coinheringaahing! (Use w and filtering to avoiding @.)

rAẇ@€⁵SrAwƇ⁵L

TryItOnline!TryItOnline!

Input: Start, End, ToFind

How?

rAẇ@€⁵SrAwƇ⁵L - Main link: Start, End, ToFind
r       - range: [Start, ..., End]
 A      - absolute values
     ⁵  - third input: ToFind
  ẇ@€ Ƈ   - sublistfilter existskeep inthose with(absolute reversedvalues, @rgumentsa) for €achwhich:
  w    S-   first index of sublist (implicit digits of ToFind) in (implicit digits of a)
     L - sumlength

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.

Jelly, 7 bytes

rAẇ@€⁵S

TryItOnline!

Input: Start, End, ToFind

How?

rAẇ@€⁵S - Main link: Start, End, ToFind
r       - range: [Start, ..., End]
 A      - absolute values
     ⁵  - 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.

Jelly,  7  6 bytes

-1 thanks to caird coinheringaahing! (Use w and filtering to avoiding @.)

rAwƇ⁵L

TryItOnline!

Input: Start, End, ToFind

How?

rAwƇ⁵L - Main link: Start, End, ToFind
r      - range: [Start, ..., End]
 A     - absolute values
    ⁵  - third input: ToFind
   Ƈ   - filter keep those (absolute values, a) for which:
  w    -   first index of sublist (implicit digits of ToFind) in (implicit digits of a)
     L - length

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.

added 315 characters in body
Source Link
Jonathan Allan
  • 110.1k
  • 7
  • 65
  • 282

Jelly, 7 bytes

rAẇ@€⁵S

TryItOnline!

Input: Start, End, ToFind

How?

rAẇ@€⁵S - Main link: Start, End, ToFind
r       - range: [Start, ..., End]
 A      - absolute values
     ⁵  - 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.

Jelly, 7 bytes

rAẇ@€⁵S

TryItOnline!

Input: Start, End, ToFind

How?

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

Jelly, 7 bytes

rAẇ@€⁵S

TryItOnline!

Input: Start, End, ToFind

How?

rAẇ@€⁵S - Main link: Start, End, ToFind
r       - range: [Start, ..., End]
 A      - absolute values
     ⁵  - 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.

Source Link
Jonathan Allan
  • 110.1k
  • 7
  • 65
  • 282

Jelly, 7 bytes

rAẇ@€⁵S

TryItOnline!

Input: Start, End, ToFind

How?

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