Created
March 11, 2023 12:45
-
-
Save rabestro/33ab571b868803fe011b405e179c9cb5 to your computer and use it in GitHub Desktop.
The solution for exercise 'Anagram': https://exercism.org/tracks/jq/exercises/anagram
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def word_key: ascii_downcase | explode | sort; | |
(.subject | length) as $size | | |
(.subject | ascii_downcase) as $subject | | |
(.subject | word_key) as $subject_key | | |
def is_candidate: length == $size and ascii_downcase != $subject; | |
def is_anagram: word_key == $subject_key; | |
[ | |
.candidates[] | | |
select(is_candidate) | | |
select(is_anagram) | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment