Skip to main content
5 of 6
deleted 31 characters in body
Maltysen
  • 25.8k
  • 4
  • 55
  • 127

#Pyth - 8 7 6

MqSGSH

Defines function with two args, the two words.

M       define function g with two args, G and H
 q       equals
  SQ     sorted first arg
  SH     sorted last arg

If that cheating golfscript program counts with hardcoded input, we can do that too with : qSS

And for just two more characters you can have it check an infinite number of words:

ql{mSdQ1

q    1       Equals 1
 l           Length
  {          Set constructor (eliminate all duplicates)
   m  Q      Map on evaluated input
    Sd       Sort each element
Maltysen
  • 25.8k
  • 4
  • 55
  • 127