Browse Source

Bob problem

master
Julio Biason 4 years ago
parent
commit
9027faca9a
  1. 1
      clojure/bob/.exercism/metadata.json
  2. 22
      clojure/bob/README.md
  3. 4
      clojure/bob/project.clj
  4. 5
      clojure/bob/src/bob.clj
  5. 84
      clojure/bob/test/bob_test.clj

1
clojure/bob/.exercism/metadata.json

@ -0,0 +1 @@
{"track":"clojure","exercise":"bob","id":"53aa2b36151d43c8a0e7327291f678f4","url":"https://exercism.io/my/solutions/53aa2b36151d43c8a0e7327291f678f4","handle":"JBiason","is_requester":true,"auto_approve":false}

22
clojure/bob/README.md

@ -0,0 +1,22 @@
# Bob
Bob is a lackadaisical teenager. In conversation, his responses are very limited.
Bob answers 'Sure.' if you ask him a question.
He answers 'Whoa, chill out!' if you yell at him.
He answers 'Calm down, I know what I'm doing!' if you yell a question at him.
He says 'Fine. Be that way!' if you address him without actually saying
anything.
He answers 'Whatever.' to anything else.
Bob's conversational partner is a purist when it comes to written communication and always follows normal rules regarding sentence punctuation in English.
## Source
Inspired by the 'Deaf Grandma' exercise in Chris Pine's Learn to Program tutorial. [http://pine.fm/LearnToProgram/?Chapter=06](http://pine.fm/LearnToProgram/?Chapter=06)
## Submitting Incomplete Solutions
It's possible to submit an incomplete solution so you can see how others have completed the exercise.

4
clojure/bob/project.clj

@ -0,0 +1,4 @@
(defproject bob "0.1.0-SNAPSHOT"
:description "bob exercise."
:url "https://github.com/exercism/clojure/tree/master/exercises/bob"
:dependencies [[org.clojure/clojure "1.10.0"]])

5
clojure/bob/src/bob.clj

@ -0,0 +1,5 @@
(ns bob)
(defn response-for [s] ;; <- arglist goes here
;; your code goes here
)

84
clojure/bob/test/bob_test.clj

@ -0,0 +1,84 @@
(ns bob-test
(:require [clojure.test :refer [deftest is]]
bob))
(deftest responds-to-something
(is (= "Whatever." (bob/response-for "Tom-ay-to, tom-aaaah-to."))))
(deftest responds-to-shouts
(is (= "Whoa, chill out!" (bob/response-for "WATCH OUT!"))))
(deftest responds-to-shouting-gibberish
(is (= "Whoa, chill out!" (bob/response-for "FCECDFCAAB"))))
(deftest responds-to-questions
(is (= "Sure."
(bob/response-for "Does this cryogenic chamber make me look fat?"))))
(deftest responds-to-numeric-question
(is (= "Sure." (bob/response-for "You are, what, like 15?"))))
(deftest responds-to-gibberish-question
(is (= "Sure." (bob/response-for "fffbbcbeab?"))))
(deftest responds-to-forceful-talking
(is (= "Whatever." (bob/response-for "Let's go make out behind the gym!"))))
(deftest responds-to-acronyms
(is (= "Whatever."
(bob/response-for "It's OK if you don't want to go to the DMV."))))
(deftest responds-to-forceful-questions
(is (= "Calm down, I know what I'm doing!"
(bob/response-for "WHAT THE HELL WERE YOU THINKING?"))))
(deftest responds-to-shouting-numbers
(is (= "Whoa, chill out!" (bob/response-for "1, 2, 3 GO!"))))
(deftest responds-to-no-letters
(is (= "Whatever." (bob/response-for "1, 2, 3"))))
(deftest responds-to-question-with-no-letters
(is (= "Sure." (bob/response-for "4?"))))
(deftest responds-to-shouting-with-special-characters
(is (= "Whoa, chill out!"
(bob/response-for "ZOMG THE %^*@#$(*^ ZOMBIES ARE COMING!!11!!1!"))))
(deftest responds-to-shouting-with-no-exclamation-mark
(is (= "Whoa, chill out!" (bob/response-for "I HATE THE DMV"))))
(deftest responds-to-statement-containing-question-mark
(is (= "Whatever." (bob/response-for "Ending with ? means a question."))))
(deftest responds-to-non-letters-with-question
(is (= "Sure." (bob/response-for ":) ?"))))
(deftest responds-to-prattling-on
(is (= "Sure." (bob/response-for "Wait! Hang on. Are you going to be OK?"))))
(deftest responds-to-silence
(is (= "Fine. Be that way!" (bob/response-for ""))))
(deftest responds-to-prolonged-silence
(is (= "Fine. Be that way!" (bob/response-for " "))))
(deftest responds-to-alternate-silence
(is (= "Fine. Be that way!" (bob/response-for "\t\t\t\t\t\t\t\t\t\t"))))
(deftest responds-to-multiple-line-question
(is (= "Whatever."
(bob/response-for "\nDoes this cryogenic chamber make me look fat?\nNo."))))
(deftest responds-to-starting-with-whitespace
(is (= "Whatever." (bob/response-for " hmmmmmmm..."))))
(deftest responds-to-ending-with-whitespace
(is (= "Sure." (bob/response-for "Okay if like my spacebar quite a bit? "))))
(deftest responds-to-other-whitespace
(is (= "Fine. Be that way!" (bob/response-for "\n\r \t"))))
(deftest responds-to-non-question-ending-with-whitespace
(is (= "Whatever."
(bob/response-for "This is a statement ending with whitespace "))))
Loading…
Cancel
Save