Skip to content

Instantly share code, notes, and snippets.

@AustinBCole
AustinBCole / Daily Challenge 11-8
Created November 8, 2018 16:45
Daily Challenge 11/8
Assumptions:
I assume that I need to write a line of code to filter out non-postivie integers, because we only want the multiples of
positive integers. That is really the only assumption I am making, the rest of the instruction is fairly straightforward and does
not require further assumptions.
Test Cases:
-1: Should return nil, the function will not run.
0: Should return nil as well, because 0 is also not a postiive integer
1: Should return 0, because there are 0 multiples of 5 or 3 between 0 and 1
10: Should return 23
@AustinBCole
AustinBCole / gist:8ceb5ecc8fbce457462dc244aff573f2
Created November 13, 2018 16:44
Daily Challenge Nov. 13th Austin Cole
Assumptions:
I assume that neither punctuation, numbers nor spaces will not count toward whether or not a word is a palindrome, so I will want to
exclude those in my function. I also want to guard against empty strings.
Test Cases:
"Sally"
"race car"
"race car!?"
func expandedNumber(number: Int) -> [Int] {
var numberArray : [Int] = []
if number < 1000 {
let numberString = String(number)
let count = numberString.count
for place in count...1 {
let newNumber = number % (10^place)
numberArray.append(number - newNumber)
}
Assumptions:
The instructions are pretty straightforward. I am not making any assumptions.
Test Cases:
[1, 2, 3, 4] - if it works with one it should work with all of them.
Implementation:
Assumptions:
I am assuming that we are differentiating between letters that represent consonants and vowels and not between
vowel and consonant sounds. The letter "y" is not always considered a vowel and so I will not be counting it, nor will I
be counting the letter "w".
Test Cases:
"Hello World"//3
"Downton Abbey"//4
Assumptions: I don't have any assumptions. It seems to be pretty straightforward.
Test Cases.
[-2, 3, 10, 11]
[3, 2, 1]
[1, 2, 3]
[2, 2, 5, 4]
Approach:
Assumptions:
I don't have any assumptions. The instructions were pretty straightforward.
Test Cases:
[0, 1, 2, 3]
[2, 2, 3, 3, 2]
[]
Assumptions:
I do not have any assumptions, it seems pretty straightforward.
Test Cases:
1. 0
2. 4
3. 33
4. 24
func sumOfDigits2(number: Int) -> Int {
var sum = 0
var count = 1
var newNumber = number
if newNumber < 0 {
newNumber *= -1
}
while newNumber > 10 {
Assumptions:
I will need to guard against an empty string. I will need to ignore anything that is not a letter.
Test Cases:
1. AbCdE
2. Fat Cat
3. "Ft6lKI9 !m"