Skip to content

Instantly share code, notes, and snippets.

@chase-lambert
Created November 4, 2024 22:01
Show Gist options
  • Save chase-lambert/5308ef35599fa68b085c9c3d53eea945 to your computer and use it in GitHub Desktop.
Save chase-lambert/5308ef35599fa68b085c9c3d53eea945 to your computer and use it in GitHub Desktop.
rendezvous with cassidoo challenge: 24.11.03
(ns group-anagrams
(:require [clojure.test :refer [deftest is]]))
(defn group-anagrams [words]
(vals (group-by set words)))
(deftest group-anagrams-test
(is (= (group-anagrams ["eat" "tea" "tan" "ate" "nat" "bat"])
[["eat" "tea" "ate"] ["tan" "nat"] ["bat"]]))
(is (= (group-anagrams ["vote" "please"])
[["vote"] ["please"]]))
(is (= (group-anagrams ["debitcard" "badcredit"])
[["debitcard" "badcredit"]])))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment