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 575 characters in body
Source Link
naffetS
  • 13.1k
  • 2
  • 22
  • 54

Vyxal, 13 bytes

2lƛvh≈0ẋntc;∑

Try it Online or run all the test cases.

How?

2lƛvh≈0ẋntc;∑
2l # Get a list of overlapping pairs in the (implicit) first input
 ƛ # Map over them:
 vh # Get the first character of both
 ≈ # Are they equal?
 0 # Push the second input
 ẋ # Repeat (so if the first characters are not equal, empty string, else second input)
 n # Push the pair again
 t # Get the second item in the pair
 c # Does the other string contain this string?
 ; # Close map lambda
 ∑ # Summate

Vyxal, 13 bytes

2lƛvh≈0ẋntc;∑

Try it Online or run all the test cases.

Vyxal, 13 bytes

2lƛvh≈0ẋntc;∑

Try it Online or run all the test cases.

How?

2lƛvh≈0ẋntc;∑
2l # Get a list of overlapping pairs in the (implicit) first input
 ƛ # Map over them:
 vh # Get the first character of both
 ≈ # Are they equal?
 0 # Push the second input
 ẋ # Repeat (so if the first characters are not equal, empty string, else second input)
 n # Push the pair again
 t # Get the second item in the pair
 c # Does the other string contain this string?
 ; # Close map lambda
 ∑ # Summate
deleted 10 characters in body
Source Link
naffetS
  • 13.1k
  • 2
  • 22
  • 54

Vyxal, 1513 bytes

:ḢZṪƛvh≈0ẋntc;∑2lƛvh≈0ẋntc;∑

Try it Online Try it Online or run all the test cases.

Vyxal, 15 bytes

:ḢZṪƛvh≈0ẋntc;∑

Try it Online or run all the test cases.

Vyxal, 13 bytes

2lƛvh≈0ẋntc;∑

Try it Online or run all the test cases.

Source Link
naffetS
  • 13.1k
  • 2
  • 22
  • 54

Vyxal, 15 bytes

:ḢZṪƛvh≈0ẋntc;∑

Try it Online or run all the test cases.

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