Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from ezephyr/master
Update the kata to work with the newest versions of clojure, lein and midje
- Loading branch information
Showing
16 changed files
with
84 additions
and
149 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
(defproject clojure-katas "1.0.0-SNAPSHOT" | ||
(defproject clojure-katas "2.0.0-SNAPSHOT" | ||
:description "Clojure Katas with: write" | ||
:dependencies [[org.clojure/clojure "1.2.0"] | ||
[org.clojure/clojure-contrib "1.2.0"]] | ||
:dev-dependencies [[swank-clojure "1.2.1"] | ||
[midje "1.1-alpha-3"]]) | ||
:profiles {:dev {:plugins [[lein-midje "3.0.1"]] | ||
:dependencies [[midje "1.5.1"]]}} | ||
:dependencies [[org.clojure/clojure "1.5.0"] | ||
[org.clojure/math.numeric-tower "0.0.2"]]) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,12 @@ | ||
(ns clojure-katas.fib) | ||
|
||
;; Calculate the fibonacci sequence | ||
;; f(0) = 0, f(1) = 1 | ||
;; f(n) = f(n-1) + f(n-2) | ||
(ns clojure-katas.fib | ||
(:use [midje.sweet])) | ||
|
||
(defn fib[n]) | ||
|
||
|
||
(future-facts "Calculate the fibonacci sequence | ||
f(0) = 0, f(1) = 1 | ||
f(n) = f(n-1) + f(n-2)" | ||
(fib 0) => 0 | ||
(fib 1) => 1 | ||
(fib 3) => 2 | ||
(fib 10) => 55) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,14 @@ | ||
(ns clojure-katas.fizzbuzz) | ||
(ns clojure-katas.fizzbuzz | ||
(:use [midje.sweet])) | ||
|
||
;; answer should return "fizz" for n divisible by 3, | ||
;; "buzz" for n divisible by 5 | ||
;; and "fizzbuzz" for n divisible by 5 and 3 | ||
;; otherwise just the number | ||
(defn fizzbuzz [n]) | ||
|
||
(defn answer [n]) | ||
(future-facts "Fizzbuzz returns \"fizz\" when the number is divisible | ||
by 3, and \"buzz\" when the number is divisible by 5. If divisible by | ||
3 AND 5, return \"fizzbuzz\". Otherwise, return the number." | ||
|
||
(fizzbuzz 3) => "fizz" | ||
(fizzbuzz 5) => "buzz" | ||
(fizzbuzz 15) => "fizzbuzz" | ||
(fizzbuzz 7) => 7 | ||
(fizzbuzz 7) =not=> "fizz") |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,12 @@ | ||
(ns clojure-katas.gcd | ||
(:require [clojure.contrib.math :as math])) | ||
|
||
;; Greatest Common divisor | ||
;; gcd(a,0) = a | ||
;; gcd(b, a mod b) | ||
(:use [midje.sweet]) | ||
(:require [clojure.math.numeric-tower :as math])) | ||
|
||
(defn gcd [a b]) | ||
|
||
(future-facts "Greatest Common divisor: | ||
gcd(a,0) = a | ||
gcd(b, a mod b)" | ||
(gcd 3 0) => 3 | ||
(gcd 48 180) => 12 | ||
(gcd 9 28) => 1) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,10 @@ | ||
(ns clojure-katas.nasa-countdown) | ||
|
||
;; Countdown should return a list counting down from the start all the | ||
;; way to zero | ||
(ns clojure-katas.nasa-countdown | ||
(:use [midje.sweet])) | ||
|
||
(defn countdown [start]) | ||
|
||
(future-fact "Countdown should return a list counting down from the | ||
start all the way to zero" | ||
|
||
(countdown 5) => '(5 4 3 2 1 0) | ||
(countdown 0) => '(0)) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
(ns clojure-katas.reverseword) | ||
|
||
;; Reverse a given input word | ||
(ns clojure-katas.reverseword | ||
(:use [midje.sweet])) | ||
|
||
(defn reverse-word [word]) | ||
|
||
(future-fact "Reverse a given input word" | ||
(reverse-word "looc") => "cool") |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,15 @@ | ||
(ns clojure-katas.teaparty) | ||
|
||
;; welcome should return the greeting with the proper title depending | ||
;; on whether it is a man, woman, or knight | ||
;; A woman is addressed as Ms. | ||
;; A man is addressed as Mr. | ||
;; A knight is addressed as Sir | ||
;; The return string should be "Welcome (the title) (last name) | ||
(ns clojure-katas.teaparty | ||
(:use [midje.sweet])) | ||
|
||
(defn welcome [last-name is-woman? is-sir?]) | ||
|
||
(future-fact "Welcome should return the greeting with the proper title | ||
depending on whether it is a man, woman, or knight. | ||
A woman is addressed as Ms. | ||
A man is addressed as Mr. | ||
A knight is addressed as Sir. | ||
The return string should be Welcome (the title) (last name)" | ||
|
||
(welcome "Austen" true false) => "Welcome Ms. Austen" | ||
(welcome "Orwell" false false) => "Welcome Mr. Orwell" | ||
(welcome "Newton" false true) => "Welcome Sir Newton") |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,17 @@ | ||
(ns clojure-katas.teleprompter) | ||
|
||
;; Given an input text string and a list of slang words and their | ||
;; translations | ||
;; return the cleansed input string of the slang words | ||
(ns clojure-katas.teleprompter | ||
(:use [midje.sweet])) | ||
|
||
(defn translate [input-string dictionary]) | ||
|
||
(def dict-1 {"hizzle" "house"}) | ||
(def dict-2 {"hizzle" "house" | ||
"brainspin" "insomnia"}) | ||
|
||
(future-facts "Given an input text string and a list of slang words | ||
and their translations, return a string cleansed of the slang words, | ||
by replacing them with their translations." | ||
|
||
(translate "In the hizzle" dict-1) => "In the house" | ||
(translate "In the hizzle, hizzle" dict-1) => "In the house, house" | ||
(translate "In the hizzle, suffering from brainspin" dict-2) | ||
=> "In the house, suffering from insomnia") |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.