Skip to content

Instantly share code, notes, and snippets.

View MarcJacques's full-sized avatar

Marc Jacques MarcJacques

View GitHub Profile
# 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
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 {
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
@MarcJacques
MarcJacques / gist:1b1b4aac115aa93afccc2d717668c8d8
Created February 11, 2020 04:10
PalindromeCodeChallenge
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] {
@MarcJacques
MarcJacques / CodeChallenge5
Created September 11, 2019 15:29
Code Challenge #5
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]
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:
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
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 = []
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
}
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