Skip to content

Instantly share code, notes, and snippets.

@d4hines
Created August 4, 2018 18:23
Show Gist options
  • Save d4hines/57d8266bc5f8a1022260414eb612876d to your computer and use it in GitHub Desktop.
Save d4hines/57d8266bc5f8a1022260414eb612876d to your computer and use it in GitHub Desktop.
Anagram Confusion

function anagrams

  • given an anagram key ak, an initial set of partial angrams pas

    e.g ak = "adeor", pas = #{"a", "are", "dare" ...}

    • For each partial anagram pa in pas,
      • Let key-diff be the multiset difference between pa and ak

        e.g pa = "a", key-diff = "deaor"

        • If pas contains key-diff, then [pa key-diff] is a solution, and we can move on to the next iteration of pa
        • Else, pa may be a solution, but we have to check by calling anagrams recursively with the leftovers, that is, the partial anagrams we can make from the multiset difference between pa and key-diff
          • This is where I start to get lost... How do I conver this to a recursive function?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment