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 8 characters in body
Source Link
Dada
  • 8.5k
  • 1
  • 18
  • 44

Perl 5, 46 bytes

43 bytes of code + 3 bytes for -p flag.

s~~$\|=grep!($`%$_|$'%$_),2..$`if$`*$'~ge}{

Try it online! or try this modified version allowing multiple inputs.
You probably don't want to try this on the largest input, as it might take a (very long) while.

Explanations:
We iterate through each position in the word with s~~~g, with $<backquote>$` containing the numbers before and $' the numbers after. If $<backquote>*$'$`*$' is true (it means that none is empty, and none is 0), then we check if a number between 2 and $<backquote>$` divides both of them (with the grep!(...),2..$<backquote>$`). If so, $\|=.. will set $\ to a non-zero value, which is implicitly printed at the end thanks to -p flag.

Perl 5, 46 bytes

43 bytes of code + 3 bytes for -p flag.

s~~$\|=grep!($`%$_|$'%$_),2..$`if$`*$'~ge}{

Try it online! or try this modified version allowing multiple inputs.
You probably don't want to try this on the largest input, as it might take a (very long) while.

Explanations:
We iterate through each position in the word with s~~~g, with $<backquote> containing the numbers before and $' the numbers after. If $<backquote>*$' is true (it means that none is empty, and none is 0), then we check if a number between 2 and $<backquote> divides both of them (with the grep!(...),2..$<backquote>). If so, $\|=.. will set $\ to a non-zero value, which is implicitly printed at the end thanks to -p flag.

Perl 5, 46 bytes

43 bytes of code + 3 bytes for -p flag.

s~~$\|=grep!($`%$_|$'%$_),2..$`if$`*$'~ge}{

Try it online! or try this modified version allowing multiple inputs.
You probably don't want to try this on the largest input, as it might take a (very long) while.

Explanations:
We iterate through each position in the word with s~~~g, with $` containing the numbers before and $' the numbers after. If $`*$' is true (it means that none is empty, and none is 0), then we check if a number between 2 and $` divides both of them (with the grep!(...),2..$`). If so, $\|=.. will set $\ to a non-zero value, which is implicitly printed at the end thanks to -p flag.

Source Link
Dada
  • 8.5k
  • 1
  • 18
  • 44

Perl 5, 46 bytes

43 bytes of code + 3 bytes for -p flag.

s~~$\|=grep!($`%$_|$'%$_),2..$`if$`*$'~ge}{

Try it online! or try this modified version allowing multiple inputs.
You probably don't want to try this on the largest input, as it might take a (very long) while.

Explanations:
We iterate through each position in the word with s~~~g, with $<backquote> containing the numbers before and $' the numbers after. If $<backquote>*$' is true (it means that none is empty, and none is 0), then we check if a number between 2 and $<backquote> divides both of them (with the grep!(...),2..$<backquote>). If so, $\|=.. will set $\ to a non-zero value, which is implicitly printed at the end thanks to -p flag.

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