 //: ### Exercise 3
 //: How many characters are in this string? 
 let howManyCharacters = "How much wood could a woodchuck chuck if a woodchuck could chuck wood?"
+howManyCharacters.characters.count
 //: ### Exercise 4
 //: How many times does the letter "g" or "G" appear in the following string? Use a for-in loop to find out!
 let gString = "Gary's giraffe gobbled gooseberries greedily"
 var count = 0
+
+for character in gString.characters {
+    if character == "G" || character == "g" {
+        count += 1
+    }
+}
+
+count
 //: ### Exercise 5
 //: Write a program that tells you whether or not this string contains the substring "tuna".
 let word = "fortunate"
+
+word.contains("tuna")
 //: ### Exercise 6
 //: Write a program that deletes all occurrences of the word "like" in the following string.
 let lottaLikes = "If like, you wanna learn Swift, like, you should build lots of small apps, cuz it's like, a good way to practice."
+
+lottaLikes.replacingOccurrences(of: "like", with: "")
 //: ### Exercise 7
 // Example
 let sillyMonkeyString = "A monkey stole my iPhone"

//: 10b) Imagine you are writing an app for a credit card company. Declare two entities: creditLimit and balance.
//: ### Exercise 11
//: Below is the code to reverse a string. Have a look at the entities declared: stringToReverse and reversedString. Choose whether to declare each with let or var. When you're finished uncomment the code and see if the compiler agrees with your choices!
//let or var stringToReverse = "Mutable or Immutable? That is the question." //TODO:Choose let or var
//let or var reversedString = "" //TODO:Choose let or var
//for character in stringToReverse.characters {
//    reversedString = "\(character)" + reversedString
//}
//print(reversedString, terminator: "")




//: You can start off with this dictionary and string.
let dictionary = ["monkey": "🐒", "iPhone":"📱"]
var newestString = sillyMonkeyString

for (word, emoji) in dictionary {
    newestString = newestString.replacingOccurrences(of: word, with: emoji)
}

newestString
//: ### Exercise 8
//: Josie has been saving her pennies and has them all counted up. Write a program that, given a number of pennies, prints out how much money Josie has in dollars and cents.
// Example
let numOfPennies = 567

let numOfDollars = Double(numOfPennies) / 100

"$ \(numOfDollars)"
//desired output = "$5.67"
//: # Let or Var?
import UIKit
import Foundation
//: ### Exercise 9
//: Below is the code to find all the numbers present in an array, convert them to Ints, and calculate their sum. Have a look at the entities declared below: array, sum, and intToAdd. Think about whether each should be a constant or a variable and choose whether to declare them with let or var. When you're finished uncomment the code and see if the compiler agrees with your choices!
let array = ["A", "13", "B","5","87", "t", "41"]
var sum = 0
for string in array {
    if Int(string) != nil {
        let intToAdd = Int(string)!
        sum += intToAdd
    }
}
print(sum)
//: ### Exercise 10
//: For each of the following pairs, choose whether to declare a constant or a variable.
//:
