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
| # Terminal Cheat Sheet | |
| pwd # print working directory | |
| ls # list files in directory | |
| cd # change directory | |
| ~ # home directory | |
| .. # up one directory | |
| - # previous working directory | |
| help # get help | |
| -h # get help |
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
| import Foundation | |
| extension String { | |
| func anotherContains(_ searchString: String) -> Bool { | |
| let searchString = searchString.lowercased() | |
| let string = self.lowercased() | |
| let test = string.range(of: searchString) | |
| if test == nil { | |
| return false | |
| } else { |
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
| import UIKit | |
| func expandTheNumber(number: Int) -> [Int] { | |
| let numberString = String(number) | |
| let numberArray = numberString.compactMap { Int(String($0)) } | |
| var expandingArray: [Int] = [] | |
| // print(numberArray) | |
| numberArray.count | |
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
| import UIKit | |
| var word = "racecar" | |
| func palindromeChecker (word: String) -> Bool { | |
| let letters = Array(word.lowercased()) | |
| var index = 0 | |
| while index < letters.count/2 { //check for the index half way through the word | |
| if letters[index] == letters[letters.count - index - 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
| import UIKit | |
| struct Country { | |
| let name: String | |
| let capital: String | |
| let altSpellings:[String] | |
| let population: Int | |
| let timeZones: [String] | |
| let currencies: [CurrencySymbol] | |
| let languages: [Name] |
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
| import UIKit | |
| func replaceVowels(_ word: String, _ replacement: Character) { | |
| var newWord = "" | |
| for letter in word.lowercased() { | |
| switch letter { | |
| case "a", "e", "i", "o", "u": | |
| newWord.append(replacement) | |
| default: |
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
| import UIKit | |
| func sumOf35Multiples(_ number: Int) -> Int { | |
| var sum = 0 | |
| if number > 0 { | |
| for x in 1..<number { | |
| let multiplesOf3 = x % 3 | |
| let multiplesof5 = x % 5 | |
| if multiplesOf3 == 0 || multiplesof5 == 0 { | |
| sum += x |
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
| import UIKit | |
| func sumAndProduct(_ sum: UInt,_ product: UInt) -> [UInt] { | |
| let x = sum / 2 | |
| let y = product / x | |
| var solutionArray: [UInt] | |
| if x + y != sum || x * y != product { | |
| solutionArray = [] |
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 numberOfVowels(in string: String) -> String { | |
| var count = 0 | |
| for vowels in string.lowercased() { | |
| switch vowels { | |
| case "a", "e", "i", "o", "u": | |
| print(vowels) | |
| count += 1 | |
| default: | |
| break | |
| } |
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
| import UIKit | |
| func smallNum (sum: UInt, product: UInt) -> [UInt] { | |
| let x = sum / 2 | |
| let y = product / 2 | |
| var smallNumber: [UInt] = [] | |
| if x > y { | |
| smallNumber.append(x) | |
| smallNumber.append(y) | |
| return smallNumber |
NewerOlder