2
\$\begingroup\$

This question already has an answer here:

Skat

I'm a fan of anagrams, so given two strings s1 and s2 write a program or function that outputs a truthy value if s2 is an anagram of s1, and a falsey value otherwise (not accounting for spaces and capital letters).

For example:

Input: s1 = "Anagram"; s2 = "Nag a ram"

true

Input: s1 = "stack overflow"; s2 = "fewer kool cats"

false

Input: s1 = "apple rocks"; s2 = "paler spock"

true

Rules

  • Program and function allowed.
  • Shortest code in bytes wins.

Duck logo!

\$\endgroup\$

marked as duplicate by Rod, FryAmTheEggman code-golf Jun 23 '17 at 16:08

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

2
\$\begingroup\$

05AB1E, 8 bytes

lðδKJ€{Ë

Try it online!

\$\endgroup\$
  • \$\begingroup\$ Wow, your answer and mine are literal polar opposites at the same cost; you remove spaces, I add them. Yours is definitely more efficient though. I'm removing mine, this was so much better lol. \$\endgroup\$ – Magic Octopus Urn Jun 23 '17 at 16:11
  • \$\begingroup\$ If you sort first you can just remove the trailing newlines and dont have to join afterwards. tl;dr: l€{ðδÛË should also work (1 byte saving yay) \$\endgroup\$ – Datboi Jun 24 '17 at 22:23
  • \$\begingroup\$ @Datboi Hmm, well, I'll rather answer the original challenge with that. \$\endgroup\$ – Erik the Outgolfer Jun 25 '17 at 5:43
0
\$\begingroup\$

Jelly, 8 bytes

ŒlḟṢ¥€⁶E

Try it online!

\$\endgroup\$
0
\$\begingroup\$

Python 3, 74 bytes

def f(a,b):print(g(a)==g(b))
g=lambda a:sorted(a.upper().replace(" ", ""))

Try it online!

\$\endgroup\$
  • \$\begingroup\$ You can change def f(a,b):print(g(a)==g(b)) for lambda a,b:g(a)==g(b) \$\endgroup\$ – Cyoce Jun 23 '17 at 16:09
  • \$\begingroup\$ You missed an extra space after .replace()'s comma. \$\endgroup\$ – manatwork Jun 23 '17 at 16:12
0
\$\begingroup\$

Japt, 13 bytes

v rS á øVv rS

Test it

\$\endgroup\$

Not the answer you're looking for? Browse other questions tagged or ask your own question.