Mayube recently posted Garble that string. However, humans aren't too good at checking whether a string is actually garbled or not. (Actually, that's an understatement, we are really bad at it.) So, let's save some time making test cases, and see if a string is actually garbled.


Two strings, containing only lowercase, or only uppercase letters, your choice.


Truthy/falsey based on if the second string is a garbled version of the first one (or vice-versa, I believe).

A string is garbled if (same as original challenge):

  • No character is in it's original position
  • No character is adjacent to a character that it was originally adjacent to

Note that duplicate characters keep rules from all other copies of them.

Adjacency also wraps from one end to the other, so for abcd, a is considered adjacent to d.

Test Cases

I really hope these are right. Mostly copied from the other challenge.

mayube, euabmy truthy
aabcdeffghij, dbfhjfigaeca truthy
abcde, badce falsey
abcde, dbeca falsey
aaa, aaa falsey
stephen, nhseept falsey
stephens, nhseespt truthy
helowi, ioewlh falsey
  • \$\begingroup\$ don't forget to mention that adjacency wraps, meaning the 2 ss in stephens are adjacent \$\endgroup\$
    – Mayube
    Commented Jun 8, 2017 at 16:08
  • 4
    \$\begingroup\$ This is a borderline duplicate of the other challenge—the bulk of the code for that challenge implements this, so answers can be trivially modified and posted here by removing the "shuffle repeatedly" or "generate permutations and filter" part. \$\endgroup\$
    – Doorknob
    Commented Jun 8, 2017 at 16:25
  • \$\begingroup\$ @Doorknob that's very possible - the community can decide. Personally, I'd prefer that at least one answer came in so that it's there to validate the test cases for the other challenge, but it's not up to me. \$\endgroup\$
    – Stephen
    Commented Jun 8, 2017 at 16:27


Browse other questions tagged or ask your own question.