-
-
Save domgetter/2939fd3f5c45fd082a25 to your computer and use it in GitHub Desktop.
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 words ["or" "line" "important" "may" "life" "mountain" "went" | |
"change" "along" "water" "through" "just" "look" "because" "than" "into" | |
"three" "after" "does" "stop" "get" "eye" "small" "world" "carry" "play" | |
"all" "really" "before" "don't" "family" "river" "enough" "another" "came" | |
"number" "why" "might" "write" "must" "other" "air" "something" "even" "own" | |
"children" "in" "keep" "saw" "kind" "see" "without" "country" "left" "night" | |
"story" "about" "but" "cut" "at" "few" "question" "began" "almost" "let" "put" | |
"again" "side" "good" "four" "always" "mile" "soon" "know" "man" "should" | |
"live" "begin" "more"]) | |
(defn rows [[full pending] word] | |
(if (> (apply + (count word) (map count pending)) 35) ; if the row would be more than 35 character total | |
[(conj full pending) [word]] ; put the word in a new row | |
[full (conj pending word)])) ; otherwise, tack it on the end of the current row | |
(apply conj (reduce rows [[] []] words)) | |
; [["or" "line" "important" "may" "life" "mountain" "went"] | |
; ["change" "along" "water" "through" "just" "look"] | |
; ["because" "than" "into" "three" "after" "does" "stop"] | |
; ["get" "eye" "small" "world" "carry" "play" "all" "really"] | |
; ["before" "don't" "family" "river" "enough" "another"] | |
; ["came" "number" "why" "might" "write" "must" "other" "air"] | |
; ["something" "even" "own" "children" "in" "keep" "saw"] | |
; ["kind" "see" "without" "country" "left" "night" "story"] | |
; ["about" "but" "cut" "at" "few" "question" "began" "almost"] | |
; ["let" "put" "again" "side" "good" "four" "always" "mile"] | |
; ["soon" "know" "man" "should" "live" "begin" "more"]] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment