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 130 characters in body
Source Link
Business Cat
  • 9.2k
  • 1
  • 18
  • 37

CJam, (削除) 18 (削除ここまで) 15(削除) 15 (削除ここまで) 14 bytes

Saved 34 bytes thanks to Martin Ender

l~Afb2ew::l~Afb_1>.&:,:*

Try it online! Try it online!

Explanation

l~ e# Read and eval the input
 Afb e# Convert each number to a list of digits
 2ew_  e# GetDuplicate allthe consecutivearray
 pairs of lists 1> e# Slice it after the first element
 ::.& e# TakeVectorized set intersection; take the set intersection of eachcorresponding pair
 e# elements of the two arrays
 :, e# Get the length of each intersection
 :* e# Take the product of the whole array. 
 e# Will be 0 if any intersection was empty.

CJam, (削除) 18 (削除ここまで) 15 bytes

Saved 3 bytes thanks to Martin Ender

l~Afb2ew::&:,:*

Try it online!

Explanation

l~ e# Read and eval the input
 Afb e# Convert each number to a list of digits
 2ew e# Get all consecutive pairs of lists
 ::& e# Take the set intersection of each pair
 :, e# Get the length of each intersection
 :* e# Take the product of the whole array. 
 e# Will be 0 if any intersection was empty.

CJam, (削除) 18 (削除ここまで) (削除) 15 (削除ここまで) 14 bytes

Saved 4 bytes thanks to Martin Ender

l~Afb_1>.&:,:*

Try it online!

Explanation

l~ e# Read and eval the input
 Afb e# Convert each number to a list of digits
 _  e# Duplicate the array
  1> e# Slice it after the first element
 .& e# Vectorized set intersection; take the set intersection of corresponding 
 e# elements of the two arrays
 :, e# Get the length of each intersection
 :* e# Take the product of the whole array. 
 e# Will be 0 if any intersection was empty.
added 45 characters in body
Source Link
Business Cat
  • 9.2k
  • 1
  • 18
  • 37

CJam, 18(削除) 18 (削除ここまで) 15 bytes

Saved 3 bytes thanks to Martin Ender

l~Afb{_@&{;L}|}l~Afb2ew::&:,:*!!

Try it online! Try it online!

Explanation

l~ e# Read and eval the input
 Afb e# Convert each number to a list of digits
 2ew e# Get all consecutive pairs of lists
 ::& e# Take the set intersection of each pair
 :, e# Get the length of each intersection
 :* e# Take the product of the whole array. 
 e# Will be 0 if any intersection was empty.

CJam, 18 bytes

l~Afb{_@&{;L}|}*!!

Try it online!

CJam, (削除) 18 (削除ここまで) 15 bytes

Saved 3 bytes thanks to Martin Ender

l~Afb2ew::&:,:*

Try it online!

Explanation

l~ e# Read and eval the input
 Afb e# Convert each number to a list of digits
 2ew e# Get all consecutive pairs of lists
 ::& e# Take the set intersection of each pair
 :, e# Get the length of each intersection
 :* e# Take the product of the whole array. 
 e# Will be 0 if any intersection was empty.
Source Link
Business Cat
  • 9.2k
  • 1
  • 18
  • 37

CJam, 18 bytes

l~Afb{_@&{;L}|}*!!

Try it online!

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