Created
March 19, 2014 17:54
-
-
Save threeifbywhiskey/9647454 to your computer and use it in GitHub Desktop.
This is a solution to /r/dailyprogrammer's Intermediate challenge #154 written using the Church gem.
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
require 'church' | |
include Church | |
GORELLIAN = -> n, alphabet, words { | |
alphabet = MAP[CHARS[alphabet], &-> a { ORD[a] | 32 }] | |
EACH[SORT_BY[words, &-> w {MAP[CHARS[w], | |
&-> c { INDEX[alphabet, ORD[c] | 32] }] }], &PUTS] | |
} | |
GORELLIAN[8, 'UVWXYZNOPQRSTHIJKLMABCDEFG', | |
['ANTLER', 'ANY', 'COW', 'HILL', 'HOW', 'HOWEVER', 'WHATEVER', 'ZONE']] | |
PUTS[''] | |
GORELLIAN[5, 'ZYXWVuTSRQpONMLkJIHGFEDCBa', | |
['go', 'aLL', 'ACM', 'teamS', 'Go']] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment