Challenge Solution Incomplete (require 'clojure.string) ;; 5/21/21 ;; https://www.hackerrank.com/challenges/crossword-puzzle/problem?h_l=interview&playlist_slugs%5B%5D=interview-preparation-kit&playlist_slugs%5B%5D=recursion-backtracking (defn crossword-puzzle [crossword words] (letfn [(empty-indices [arr] (map (fn [row] (keep-indexed #(if (= %2 \-) %1) row)) arr)) (start-and-range [ei] (map (fn [indices] [(first indices) (inc (- (last indices) (first indices)))]) ei))] (let [crossword-seq (map #(seq %) crossword) crossword-seq-trans (apply mapv vector crossword-seq) #_#_#_#_horizontal-empty-ranges (-> (empty-indices crossword-seq) start-and-range) vertical-empty-ranges (-> (empty-indices crossword-seq-trans) start-and-range) ] #_[horizontal-empty-ranges vertical-empty-ranges] (start-and-range (empty-indices crossword-seq-trans)) ))) (crossword-puzzle ["+-++++++++" "+-++++++++" "+-++++++++" "+-----++++" "+-+++-++++" "+-+++-++++" "+++++-++++" "++------++" "+++++-++++" "+++++-++++"] ["LONDON", "DELHI", "ICELAND", "ANKARA"])
Hackerrank crossword puzzle
Hackerrank crossword puzzle
Hackerrank crossword puzzle
Challenge Solution Incomplete (require 'clojure.string) ;; 5/21/21 ;; https://www.hackerrank.com/challenges/crossword-puzzle/problem?h_l=interview&playlist_slugs%5B%5D=interview-preparation-kit&playlist_slugs%5B%5D=recursion-backtracking (defn crossword-puzzle [crossword words] (letfn [(empty-indices [arr] (map (fn [row] (keep-indexed #(if (= %2 \-) %1) row)) arr)) (start-and-range [ei] (map (fn [indices] [(first indices) (inc (- (last indices) (first indices)))]) ei))] (let [crossword-seq (map #(seq %) crossword) crossword-seq-trans (apply mapv vector crossword-seq) #_#_#_#_horizontal-empty-ranges (-> (empty-indices crossword-seq) start-and-range) vertical-empty-ranges (-> (empty-indices crossword-seq-trans) start-and-range) ] #_[horizontal-empty-ranges vertical-empty-ranges] (start-and-range (empty-indices crossword-seq-trans)) ))) (crossword-puzzle ["+-++++++++" "+-++++++++" "+-++++++++" "+-----++++" "+-+++-++++" "+-+++-++++" "+++++-++++" "++------++" "+++++-++++" "+++++-++++"] ["LONDON", "DELHI", "ICELAND", "ANKARA"])