Created
July 18, 2014 07:56
-
-
Save escherize/8d698aa9f41446760e74 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
(ns playground.apple | |
[:require [print.foo :refer :all]]) | |
(defn rent-finder [{:keys [room-dimensions total-sq-ft price] :as apt-info}] | |
(print-let [room-dimensions room-dimensions | |
total-sq-ft total-sq-ft | |
price price | |
room-sizes (for [[w h] room-dimensions] (* w h)) | |
cost-per-sq-foot (/ price total-sq-ft) | |
common-space (- total-sq-ft (apply + room-sizes)) | |
common-space-pp (/ common-space 5) | |
area-per-room [(+ (first room-sizes) (* 2 common-space-pp)) | |
(+ (second room-sizes) common-space-pp) | |
(+ (last room-sizes) common-space-pp)] | |
cost-per-room (map (partial * cost-per-sq-foot) area-per-room)] | |
(map #(format "%.02f" %) cost-per-room))) | |
(def room-dimensions [[15.25 11.25] [11.5 13.5] [12.5 9.75]]) | |
(def total-sq-ft 1267) | |
(def high-price 3635) | |
(def low-price 3382) | |
(rent-finder {:room-dimensions room-dimensions | |
:total-sq-ft total-sq-ft | |
:price high-price}) | |
;; room-dimensions [[15.25 11.25] [11.5 13.5] [12.5 9.75]] | |
;; total-sq-ft 1267 | |
;; price 3635 | |
;; room-sizes (171.5625 155.25 121.875) | |
;; cost-per-sq-foot 3635/1267 | |
;; common-space 818.3125 | |
;; common-space-pp 163.6625 | |
;; area-per-room [498.8875 318.9125 285.5375] | |
;; cost-per-room (1431.2991811365428 914.9541732438831 819.2019041041831) | |
;; let result: ("1431.30" "914.95" "819.20") | |
(rent-finder {:room-dimensions room-dimensions | |
:total-sq-ft total-sq-ft | |
:price low-price}) | |
;; room-dimensions [[15.25 11.25] [11.5 13.5] [12.5 9.75]] | |
;; total-sq-ft 1267 | |
;; price 3382 | |
;; room-sizes (171.5625 155.25 121.875) | |
;; cost-per-sq-foot 3382/1267 | |
;; common-space 818.3125 | |
;; common-space-pp 163.6625 | |
;; area-per-room [498.8875 318.9125 285.5375] | |
;; cost-per-room (1331.679183109708 851.2723559589583 762.18455011839) | |
;; let result: ("1331.68" "851.27" "762.18") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment