Commits

committed de20730

Added a fix to problem 90

probs.clj

` (def matrix (read-matrix "matrix.txt"))`
` `
` (def small-matrix`
`-     (131 673 234 103 18)`
`-     (201 96  342 965 150)`
`-     (630 803 746 422 111)`
`-     (537 699 497 121 956)`
`-     (805 732 524 37  331)`
`-)`
`+     '((131 673 234 103 18)`
`+       (201 96  342 965 150)`
`+       (630 803 746 422 111)`
`+       (537 699 497 121 956)`
`+       (805 732 524 37  331)))`
` `
` (defn get-row [matrix n]`
`   (nth matrix n))`
` ;; find the six-digit modal string.`
` `
` ;}}}`
`-;{{{ problem 85 -- number of rectangles **`
`+;{{{ problem 85 -- number of rectangles`
` `
` ;; By counting carefully it can be seen that a rectangular grid`
` ;; measuring 3 by 2 contains eighteen rectangles:`
` ;; What is the sum of all the minimal product-sum numbers for 2 <= k <= 12000?`
` `
` ;}}}`
`-;{{{ problem 89 -- roman numerals in minimal form **`
`+;{{{ problem 89 -- roman numerals in minimal form`
` `
` ;; The rules for writing Roman numerals allow for many ways of writing`
` ;; each number (see FAQ: Roman Numerals). However, there is always a`
` ;; 743`
` `
` ;}}}`
`-;{{{ problem 90 -- two cubes to make a square ***`
`+;{{{ problem 90 -- two cubes to make a square`
` `
` ;; Each of the six faces on a cube has a different digit (0 to 9)`
` ;; written on it; the same is done to a second cube. By placing the`
`   (cond (> (count cube) 6)`
`         nil`
`         (= (count cube) 6) ; Here I need to check for a six, and if so add one with a nine`
`-        (if (cube 6)`
`-          (list cube (set (cons 9 cube))) ;It's not actually the correct cube, but it's close enough`
`+        (if (and (cube 6)`
`+                 (not (cube 9)))`
`+            (list cube`
`+                  (set (filter #(not= % 6) (cons 9 cube)))) ; This seems like it should be much simpler than it is`
`           (list cube))`
`         :else`
`-        (apply concat (for [x (range 9) :when (not (cube x))]`
`+        (apply concat (for [x (range 10) :when (not (cube x))]`
`                   (expound-cube (set (cons x cube)))))))`
` `
` (defn expound-cubes [cubes]`
`   (pipeline`
`     :count`
`     :set`
`+    :map set`
`     :mapcat expound-cubes`
` ;;     :filter #(and (<= (count (first %)) 7)`
` ;;                   (<= (count (frest %)) 7))`
`     (generate-cubes must-create '(()) '(()))))`
` `
` ;; (time (num-cubes))`
`-;; "Elapsed time: 1478.547 msecs"`
`-;; 1066`
`+;; "Elapsed time: 693.771 msecs"`
`+;; 1217`
` `
` ;}}}`
` `
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.