Skip to main content
1 of 2
cnamejj
  • 2.8k
  • 10
  • 11

Ly, 46 bytes

<"false">ia>ia[sp<l=![<&o;]pp>]<[<&o;]"true"&o

Try it online!

Input expected is two lines, one word per line.

I didn't see a Ly entry and I'm trying to learn that language better, so why not? :)

First, store "false" in a stack, since we need it twice, then switch back to the default stack.

<"false">

Then read each line into it's own stack, as codepoints, and sort them.

>ia>ia

The loop compares the top of stack of each of those two stacks using the "backup cell" to facilitate the cross-stack comparisons.

[sp<l=![<&o;]pp>]

The sp<l=! bit stores the current top stack, deletes it, switches stacks, loads the value we stored, them compares it to what was the top of the stack. And since we only care if they are different it logically negates the results to make the [ conditional kick in.

So that bit [<&o;] switched to the stack where we stashed "false", prints it, and exits the program.

All the loop has to do after that is clean-up the stack and switch back to the one driving the comparisons with pp>.

Once all the characters on the first word stack have been compared to the second word stack, the code has to make sure the second work stack wasn't shorter.

<[<&o;]

That works by switching to the stack that wasn't driving the loop < and running the code in the [ block if it's not empty. If that code is invoked, it switches to the "false" string stack, prints it and exits the program.

If we survived both those conditional exits, the strings are the same length and have the same characters. So we just print "true" and exit.

"true"&o
cnamejj
  • 2.8k
  • 10
  • 11