Skip to content

Instantly share code, notes, and snippets.

@tttardigrado
Created January 27, 2023 10:53
Show Gist options
  • Save tttardigrado/9cc2cdd2b33ccb4453e6d14736371f72 to your computer and use it in GitHub Desktop.
Save tttardigrado/9cc2cdd2b33ccb4453e6d14736371f72 to your computer and use it in GitHub Desktop.

Is the word coprime?

Challeng link

Vyxal, 17 bytes

Cƛ96-;2↔ƛġ;:₌Π∆Ŀ=

How it works

C       # Convert the string into a list of ordinals
ƛ96-;   # subtract 96 from each (so that a->1 b->2 c->3 ...)
2↔      # Get a list of all pairs (combinations of size 2)
ƛġ;     # Get the GCD of each pair
:₌Π∆Ŀ   # Get the product and the LCM of the GCDs
=       # Check if they are equal
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment