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
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 |
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
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!?" |
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
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) | |
} |
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
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: |
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
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 |
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
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: |
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
Assumptions: | |
I don't have any assumptions. The instructions were pretty straightforward. | |
Test Cases: | |
[0, 1, 2, 3] | |
[2, 2, 3, 3, 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
Assumptions: | |
I do not have any assumptions, it seems pretty straightforward. | |
Test Cases: | |
1. 0 | |
2. 4 | |
3. 33 | |
4. 24 |
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
func sumOfDigits2(number: Int) -> Int { | |
var sum = 0 | |
var count = 1 | |
var newNumber = number | |
if newNumber < 0 { | |
newNumber *= -1 | |
} | |
while newNumber > 10 { |
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
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" |
OlderNewer