This file contains hidden or 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 order(_ firstNumber: Int, and secondNumber: Int) -> [Int] { | |
| if abs(firstNumber) > abs(secondNumber) { | |
| return [secondNumber, firstNumber] | |
| } else { | |
| return [firstNumber, secondNumber] | |
| } | |
| } | |
| func sumAndProduct(of firstNumber: Int, and secondNumber: Int) -> [Int] { |
This file contains hidden or 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 expandNumber(_ number: Int) -> [Int]{ | |
| var expandedArray: [Int] = [] | |
| var workingNumber = number | |
| var zeroesToAdd = 0 | |
| repeat { | |
| var smallestNumber = workingNumber % 10 | |
| for _ in 0..<zeroesToAdd { | |
| if smallestNumber == 0 { | |
| smallestNumber = 1 |
This file contains hidden or 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
| // Ok, I'm going to assume the following: | |
| // - I'll be given a String type. | |
| // - I need to account for capitals, punctuation, numbers, etc. None of these are vowels. | |
| // - The only vowels are A, E, I, O, U, a, e, i, o, & u. | |
| // - My function needs to give return the number of vowels as an Int | |
| func numberOfVowels(in string: String) -> Int { | |
| var vowelCount = 0 | |
| for character in string { | |
| if "aeiou".contains(Character(character.lowercased())) { |
NewerOlder