Ly, 4646 29 bytes
<"false">ia>ia[sp<l=iayr>iay&s<l[0I=![<&o;]pp>]<[<&o;]"true"&o[0u;]pprp]1u
Input expected is two lines, one word per line.Try it online!
I didn't see aknow Ly
entry and I'm trying to learn that language better, so why not? now. :)
First, store "false"
in At a stackhigh level, since we need it twicethis code constructs two stacks, then switch back to the default stack.
<"false">
Then read each line into it's own stack, as codepointswith a sorted (by codepoint) list of characters in the associated input string, and sort them.
>ia>ia
The loop compareswith the top of stack of eachlength of those two stacks using the "backup cell" to facilitatestring included as another entry on the cross-stack comparisonslist.
[sp<l=![<&o;]pp>]
The sp<l=!
bit stores the current topOne stack, deletes it, switches stacks, loads is reversed and then the value we storedtwo are concatenated. Once that setup is done, them compares it to what was the code loops comparing the top and bottom of the stack. And since we only care if they are different it logically negates The first time the results to makecodepoints aren't the [
conditional kick in.
So that bitsame, the code write out a [<&o;]0
switched to the stack where we stashed "false", prints it, and exits the program.
All If 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 toexhausts 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 runningstrings are anagrams so the code in thewrites out a [1
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 areIt's still nowhere near the same length and haveshortest, but the same characters. So we just print "true" and exit.way it works might be interesting to people?
"true"&o # parse the first string
i - read in one line
a - sort by codepoint value
y - push the stack length
r - reverse the stack
# parse the second string
> - switch to a new stack
i - read in one line
a - sort by coidepoint
y - push the stack length
&s - stash the entire stack
# setup for processing
< - back to stack with string 1
l - append the parsed second string
# compare pairs of codepoints while stack isn't empty
[ ] - loop, process one char per iteration
0I - copy bottom of stack
=! - compare top two negate
[ ]p - if/then, if they don't match
0u; - print "0" and exit
prp - delete pair we just checked
# if lengths and all the codepoints matched...
1u - success! print "1"