Revisions
-
mirontoli revised this gist
Jun 13, 2014 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -2,7 +2,7 @@ $dog = $_ 1..98 | % { $cat = $_ @{ "Dog" = $dog "Cat" = $cat "Mouse" = 100 - $dog -$cat -
mirontoli revised this gist
Jun 13, 2014 . 1 changed file with 13 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,13 @@ 1..98 | % { $dog = $_ 1..98 | % { $cat = $_ return @{ "Dog" = $dog "Cat" = $cat "Mouse" = 100 - $dog -$cat } } } | ? { $_.Mouse -gt 0 } | ? { $_.Dog * 15 + $_.Cat * 1 + $_.Mouse * 0.25 -eq 100 } -
mirontoli revised this gist
Jun 13, 2014 . 1 changed file with 14 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,14 @@ $range = 1..98 $combinations = $range | % { $dog = $_ $range | % { $cat = $_ return @{"Dog" = $dog; "Cat" = $cat; "Mouse" = 100 - $dog -$cat } } } | ? { $_.Mouse -gt 0 } function winner?($combination) { return $combination.Dog * 15 + $combination.Cat * 1 + $combination.Mouse * 0.25 -eq 100 } $winner = $combinations | ? { winner? $_ } -
mirontoli revised this gist
Jun 13, 2014 . 1 changed file with 31 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,31 @@ ekvation 1: 15h + k + 0,25m = 100 (1) multiplicerad med 4 för att få heltal: 60h + 4k + m = 400 (1) ekvation 2: h + k + m = 100 (2) sätt in (2) i (1) ger: 60(100 - k - m) + 4k + m = 400 5600 = 56k + 59m k = (5600 - 59m)/56 = 100 - 59m/56 enda heltalslösningen är för m = 56 vilket ger k = 41 h = 100 - k - m = 3 alltså: 3 hundar: 3 x 15 = 45 kr 41 katter: 41 kr 56 möss: 56 x 0,25 = 14 kr -
mirontoli revised this gist
Jun 13, 2014 . 1 changed file with 3 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,3 @@ function winner?($dog, $cat, $mouse) { return $dog * 15 + $cat * 1 + $mouse * 0.25 -eq 100 } -
mirontoli revised this gist
Jun 12, 2014 . 1 changed file with 8 additions and 6 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,11 +1,13 @@ (def combinations (for [dog (range 1 98) cat (range 1 98) :when (>= 98 (+ dog cat))] (let [mouse (- 100 dog cat)] {:dog dog :cat cat :mouse mouse}))) (defn winner? [{:keys [dog cat mouse]}] (== 100 (+ (* 15 dog) (* 1 cat) (* 0.25 mouse)))) (defn find-winner [] (filter winner? combinations)) (println (find-winner)) -
Erik Kronberg revised this gist
Jun 12, 2014 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -4,8 +4,8 @@ (let [z (- 100 x y)] {:x x :y y :z z}))) (defn winner? [{:keys [x y z]}] (== 100 (+ (* 15 x) (* 1 y) (* 0.25 z)))) (defn find-winner [] (filter winner? combinations)) -
Erik Kronberg created this gist
Jun 12, 2014 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,11 @@ (def combinations (for [x (range 1 98) y (range 1 98) :when (>= 98 (+ x y))] (let [z (- 100 x y)] {:x x :y y :z z}))) (defn winner? [combo] (== 100 (+ (* 15 (:x combo)) (* 1 (:y combo)) (* 0.25 (:z combo))))) (defn find-winner [] (filter winner? combinations))