We are no longer publishing to YouTube! We have a site now: https://apropos-site.vercel.app/
Domain coming soon!
Show page: https://apropos-site.vercel.app/episode/54
Discord - Join if you want to watch us live or chat! https://discord.gg/xEsH53Ey
| # Coffee shop scenario | |
| Background: *This scenario is from a self-service ordering touchscreen at a coffee shop that you are assigned to develop. Jill is a customer who wants some coffee.* | |
| Jill starts to order some coffee at the touchscreen. She adds a small, dark roast. Then | |
| she adds a large medium roast with double almond syrup. She adds a | |
| medium medium roast with two soy milk shots (the second one by | |
| accident). She reads the price and it's too expensive. So she removes | |
| the second coffee (the one with the almond syrup). Then she realizes | |
| the third coffee has two soy milk shots and she removes one. The price |
| # Coffee shop scenario | |
| Background: *This scenario is from a self-service ordering touchscreen at a coffee shop that you are assigned to develop. Jill is a customer who wants some coffee.* | |
| Operation set: | |
| (defn create-order []) ;;=> Order | |
| (defn add-coffee [order coffee]) ;;=> Order | |
| (defn order-price [order]) ;;=> Price | |
| (defn remove-coffee [order coffee-index]) ;;=> Order |
We are no longer publishing to YouTube! We have a site now: https://apropos-site.vercel.app/
Domain coming soon!
Show page: https://apropos-site.vercel.app/episode/54
Discord - Join if you want to watch us live or chat! https://discord.gg/xEsH53Ey
Jill starts to order some coffee. She adds a small, dark roast. Then she adds a large medium roast with double almond syrup. She adds a medium medium roast with two soy shots (the second one by accident). She reads the price and it's too expensive. So she removes the second coffee (the one with the almond syrup). Then she realizes the third coffee has two soy shots and she removes one. The price looks good, so she submits the order.
String difference
You are given two strings, a and b. We consider each letter to be unique, meaning duplicates are significant. Write a function that returns the count of letters in b which do not occur in a.
Examples
(strdiff "abc" "") ;=> {} ;; no characters in b don't occur in a
(strdiff "abc" "abc") ;=> {} ;; ditto
(strdiff "" "abc") ;=> {\a 1 \b 1 \c 1}| #!/bin/sh | |
| #_( | |
| #_DEPS is same format as deps.edn. Multiline is okay. | |
| DEPS=' | |
| {:deps {clj-time {:mvn/version "0.14.2"}}} | |
| ' | |
| #_You can put other options here | |
| OPTS=' |
| /** | |
| // Using number of minutes for prep time | |
| mealPrep([120]) | |
| 2 // one single long dish | |
| mealPrep([30, 30, 30, 20]) | |
| 2 // multiple shorter dishes | |
| ^ | |
| I don't understand, this should take 60 minutes. |
Super Digit
This is kind of a contrived problem, but it's the kind that breeds lots of interesting implementations and tests your understanding of lower-level details. So let's do it!
You're given an integer n and an integer k. There is an integer p
that is k instances of the digits of n concatenated together. For example:
Digit search
This is one of those weird programming puzzles with no real point except practice. But it's considered Very Hard in JavaScript. Let's see how we do in Clojure.
Write a function that takes a sequence of integers. You're trying to get all 10 digits by looking through the numbers sequentially. When you have found one instance of every decimal digit, return whatever number you were on when you found the last one. If you get to the end of the sequence without finding all the digits (for instance, maybe there was no 9), then just return nil.
Example
(digit-search [5175 4538 2926 5057 6401 4376 2280 6137]) ;=> 5057How many digits?
Imagine you took all the integers between n and m (exclusive, n < m) and concatenated them together. How many digits would you have? Write a function that takes two numbers and returns how many digits. Note that the numbers can get very big, so it is not possible to build the string in the general case.
Examples:
(num-digits 0 1) ;=> 0 (there are no integers between 0 and 1)
(num-digits 0 10) ;=> 9 (1, 2, 3, 4, 5, 6, 7, 8, 9)
(num-digits 9 100) ;=> 180