diff --git a/1-hello-world/art/bjarne.gif b/1-hello-world/art/bjarne.gif deleted file mode 100644 index 7c91ea1..0000000 Binary files a/1-hello-world/art/bjarne.gif and /dev/null differ diff --git a/1-hello-world/art/bjarne2.gif b/1-hello-world/art/bjarne2.gif deleted file mode 100644 index 82c67a3..0000000 Binary files a/1-hello-world/art/bjarne2.gif and /dev/null differ diff --git a/1-hello-world/art/compiler.png b/1-hello-world/art/compiler.png deleted file mode 100644 index 766025f..0000000 Binary files a/1-hello-world/art/compiler.png and /dev/null differ diff --git a/1-hello-world/art/file-name.png b/1-hello-world/art/file-name.png deleted file mode 100644 index 618d4fb..0000000 Binary files a/1-hello-world/art/file-name.png and /dev/null differ diff --git a/1-hello-world/art/files1.png b/1-hello-world/art/files1.png deleted file mode 100644 index 974cc3c..0000000 Binary files a/1-hello-world/art/files1.png and /dev/null differ diff --git a/1-hello-world/art/files2.png b/1-hello-world/art/files2.png deleted file mode 100644 index 2a44d45..0000000 Binary files a/1-hello-world/art/files2.png and /dev/null differ diff --git a/1-hello-world/art/introduction.gif b/1-hello-world/art/introduction.gif new file mode 100644 index 0000000..b00b554 Binary files /dev/null and b/1-hello-world/art/introduction.gif differ diff --git a/1-hello-world/art/process.svg b/1-hello-world/art/process.svg deleted file mode 100644 index 0d1c5a1..0000000 --- a/1-hello-world/art/process.svg +++ /dev/null @@ -1,202 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/1-hello-world/art/program-structure.png b/1-hello-world/art/program-structure.png deleted file mode 100644 index a4f4b79..0000000 Binary files a/1-hello-world/art/program-structure.png and /dev/null differ diff --git a/1-hello-world/block-letters/Newlines.swift b/1-hello-world/block-letters/Newlines.swift new file mode 100644 index 0000000..5c3cb90 --- /dev/null +++ b/1-hello-world/block-letters/Newlines.swift @@ -0,0 +1,4 @@ +// Lance Adriano +// Fun fact: I skipped third grade. + +print("L A\nL A A\nL A A\nL AAAAA\nL A A\nL A A\nLLLLL A A") diff --git a/2-variables/BMI.swift b/2-variables/BMI.swift index fb90bf1..4ecd99b 100644 --- a/2-variables/BMI.swift +++ b/2-variables/BMI.swift @@ -1,3 +1,6 @@ +// Body Mass Index ๐Ÿ‹๏ธโ€ +// Sonny Li + var height: Double = 1.85 var weight: Double = 82 var bmi: Double diff --git a/2-variables/Temperature.swift b/2-variables/Temperature.swift index e7befc4..be50ce6 100644 --- a/2-variables/Temperature.swift +++ b/2-variables/Temperature.swift @@ -1,3 +1,6 @@ +// Temperature ๐ŸŒก๏ธ +// Sonny Li + var tempf: Double = 83.0 var tempc: Double = 0.0 diff --git a/2-variables/art/compiler.png b/2-variables/art/compiler.png deleted file mode 100644 index 766025f..0000000 Binary files a/2-variables/art/compiler.png and /dev/null differ diff --git a/2-variables/art/folder-icon.png b/2-variables/art/folder-icon.png deleted file mode 100644 index 24b881d..0000000 Binary files a/2-variables/art/folder-icon.png and /dev/null differ diff --git a/2-variables/art/folder-icon.svg b/2-variables/art/folder-icon.svg deleted file mode 100644 index 5004f16..0000000 --- a/2-variables/art/folder-icon.svg +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/2-variables/art/process-quiz.png b/2-variables/art/process-quiz.png deleted file mode 100644 index a346a83..0000000 Binary files a/2-variables/art/process-quiz.png and /dev/null differ diff --git a/2-variables/art/process.gif b/2-variables/art/process.gif deleted file mode 100644 index 0eb4ea2..0000000 Binary files a/2-variables/art/process.gif and /dev/null differ diff --git a/2-variables/art/process.svg b/2-variables/art/process.svg deleted file mode 100644 index 0d1c5a1..0000000 --- a/2-variables/art/process.svg +++ /dev/null @@ -1,202 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/2-variables/art/program-structure.png b/2-variables/art/program-structure.png deleted file mode 100644 index a4f4b79..0000000 Binary files a/2-variables/art/program-structure.png and /dev/null differ diff --git a/2-variables/art/terminal.png b/2-variables/art/terminal.png deleted file mode 100644 index 54537f4..0000000 Binary files a/2-variables/art/terminal.png and /dev/null differ diff --git a/2-variables/dog-years/DogYears.swift b/2-variables/dog-years/DogYears.swift index 772d774..91fcd89 100644 --- a/2-variables/dog-years/DogYears.swift +++ b/2-variables/dog-years/DogYears.swift @@ -1,4 +1,4 @@ -// Dog Years (Swift) +// Dog Years ๐Ÿถ // Sonny Li var dogAge: Double = 2.5 diff --git a/2-variables/dog-years/HumanYears.swift b/2-variables/dog-years/HumanYears.swift new file mode 100644 index 0000000..fdb7c8c --- /dev/null +++ b/2-variables/dog-years/HumanYears.swift @@ -0,0 +1,17 @@ +//Human Years +//Jacob Kline +//Much like the Dog Years program, this program only works when the human age is above the "underageYears" (21 years) + +//This is the human's age stored as a double +var humanAge: Double = 21.5 + +//This is how many dog years a human's "underage years" (first 21 years) are +let underageYears: Double = 2 + +//This is how many dog years a human's "later years" make up (every year of their life except their first 21) +let adultYears: Double = (humanAge - 21) / 4 + +//This is the total age of the human in dog years +let dogYears: Double = underageYears + adultYears + +print("My Name is Jacob! Hi hi, I am \(dogYears) years old in dog years.") diff --git a/2-variables/piggy-bank/PiggyBank.swift b/2-variables/piggy-bank/PiggyBank.swift index 2f57811..54c97f1 100644 --- a/2-variables/piggy-bank/PiggyBank.swift +++ b/2-variables/piggy-bank/PiggyBank.swift @@ -1,4 +1,4 @@ -// Piggy Bank (Swift) +// Piggy Bank ๐Ÿฝ // Sonny Li var pesos: Double = 4 diff --git a/2-variables/quadratic-formula/Quadratic.swift b/2-variables/quadratic-formula/Quadratic.swift index c545d8a..0fb4379 100644 --- a/2-variables/quadratic-formula/Quadratic.swift +++ b/2-variables/quadratic-formula/Quadratic.swift @@ -1,4 +1,4 @@ -// Quadratic Formula (Swift) +// Quadratic Formula ๐Ÿ“ˆ // Sonny Li var a: Double = 6 diff --git a/2-variables/types.gif b/2-variables/types.gif new file mode 100644 index 0000000..72a4629 Binary files /dev/null and b/2-variables/types.gif differ diff --git a/3-conditionals/donut_factory.gif b/3-conditionals/donut_factory.gif new file mode 100644 index 0000000..ba50c51 Binary files /dev/null and b/3-conditionals/donut_factory.gif differ diff --git a/3-conditionals/magic-8-ball/ChallengeSolution.swift b/3-conditionals/magic-8-ball/ChallengeSolution.swift deleted file mode 100644 index c3dc31c..0000000 --- a/3-conditionals/magic-8-ball/ChallengeSolution.swift +++ /dev/null @@ -1,34 +0,0 @@ -let playerName = "Galina" - -let playerQuestion = "Will there be any more snowfall in New York for winter 2020? โ„๏ธ" - -let randomNumber = Int.random(in: 1...9) -// print(randomNumber) - -let eightBall: String - -switch randomNumber { - case 1: - eightBall = "Yes - definitely" - case 2: - eightBall = "It is decidedly so" - case 3: - eightBall = "Without a doubt" - case 4: - eightBall = "Reply hazy, try again" - case 5: - eightBall = "Ask again later" - case 6: - eightBall = "Better not tell you now" - case 7: - eightBall = "My sources say no" - case 8: - eightBall = "Outlook not so good" - case 9: - eightBall = "Very doubtful" - default: - eightBall = "Error" -} - -playerName.isEmpty ? print("Question: \(playerQuestion)") : print("\(playerName) asks: \(playerQuestion)") -print("Magic 8 Ball's answer: \(eightBall)") \ No newline at end of file diff --git a/3-conditionals/magic-8-ball/ProjectSolution.swift b/3-conditionals/magic-8-ball/Magic8Ball.swift similarity index 77% rename from 3-conditionals/magic-8-ball/ProjectSolution.swift rename to 3-conditionals/magic-8-ball/Magic8Ball.swift index 2e596db..e07c59f 100644 --- a/3-conditionals/magic-8-ball/ProjectSolution.swift +++ b/3-conditionals/magic-8-ball/Magic8Ball.swift @@ -1,3 +1,6 @@ +// Magic 8-Ball ๐ŸŽฑ +// Galina Podstrechnaya + let playerName = "Galina" let playerQuestion = "Will there be any more snowfall in New York for winter 2020? โ„๏ธ" @@ -31,4 +34,8 @@ switch randomNumber { } print("\(playerName)'s Question: \(playerQuestion)") -print("Magic 8 Ball's answer: \(eightBall)") \ No newline at end of file + +// Challenge: +// playerName.isEmpty ? print("Question: \(playerQuestion)") : print("\(playerName) asks: \(playerQuestion)") + +print("Magic 8 Ball's answer: \(eightBall)") diff --git a/4-loops/99-Bottles/Bottles.swift b/4-loops/99-bottles/Bottles.swift similarity index 50% rename from 4-loops/99-Bottles/Bottles.swift rename to 4-loops/99-bottles/Bottles.swift index 22975f4..ff16a47 100644 --- a/4-loops/99-Bottles/Bottles.swift +++ b/4-loops/99-bottles/Bottles.swift @@ -1,10 +1,10 @@ // Bottles (Swift) - Prints the full lyrics to "99 Bottles of Milk" song // Alex DiStasi -//numBottles represents the number of bottles left on the wall +// numBottles represents the number of bottles left on the wall var numBottles: Int = 99 -//While there are more than 0 bottles on the wall, print the song lyrics +// While there are more than 0 bottles on the wall, print the song lyrics while numBottles > 0 { print ("\(numBottles) bottles of milk on the wall, \(numBottles) bottles of milk!") @@ -17,6 +17,17 @@ while numBottles > 0 { print ("\(numBottles) bottles of milk on the wall, \(numBottles) bottles of milk!\nGo to the store and buy some more,\n99 bottles of milk on the wall!") +/* +// Solution to optional challenge 1 +for numBottles in stride(from: 99, to: 0, by: -1){ + print ("\(numBottles) bottles of milk on the wall, \(numBottles) bottles of milk!") + print ("You take one down and pass it around...") + print ("\(numBottles-1) bottles of milk on the wall!") +} + +print ("0 bottles of milk on the wall, 0 bottles of milk!\nGo to the store and buy some more,\n99 bottles of milk on the wall!") + +*/ diff --git a/4-loops/Five Little Monkeys/Monkeys.swift b/4-loops/99-bottles/FiveLittleMonkeys.swift similarity index 86% rename from 4-loops/Five Little Monkeys/Monkeys.swift rename to 4-loops/99-bottles/FiveLittleMonkeys.swift index e95e7db..7c5f0cf 100644 --- a/4-loops/Five Little Monkeys/Monkeys.swift +++ b/4-loops/99-bottles/FiveLittleMonkeys.swift @@ -1,4 +1,4 @@ -// Monkeys.swift +// Five Little Monkeys ๐Ÿต๐Ÿ™‰๐Ÿ™Š๐Ÿ™ˆ๐Ÿ’ // Alex DiStasi // Purpose: Prints the lyrics to Five Little Monkeys song @@ -11,12 +11,11 @@ while numMonkeys > 1 { print ("One fell off and bumped their head!") print ("Mama called the doctor and the doctor said") print ("'No more monkeys jumping on the bed!'\n") - // Decrease the value of numMonkeys by 1 numMonkeys -= 1 } // Print the final lyrics print ("\(numMonkeys) little monkey jumping on the bed.") -print ("They fell off bumped their head!") +print ("They fell off and bumped their head!") print ("Mama called the doctor and the doctor said") print ("'Put those monkeys straight to bed!'") diff --git a/4-loops/Review.swift b/4-loops/Review.swift new file mode 100644 index 0000000..3c30c66 --- /dev/null +++ b/4-loops/Review.swift @@ -0,0 +1,48 @@ +// Test your ๐Ÿ” skills! + +// First challenge: +for num in 1...100 { + // If a number is fully divisible by 2, it's an even number + if num % 2 == 0 { + print("even") + } else { + print("odd") + } +} + + +// Second Challenge +// checkPrime can be changed to a positive number greater than 1 +var checkPrime = 17 +// Assume the number is prime until proven otherwise +var isPrime = true +for num in 2...checkPrime - 1 { + // If checkPrime is fully divisible by the current number it's not a prime number + if checkPrime % num == 0 { + isPrime = false + break + } +} + +print("Is \(checkPrime) a prime numer? \(isPrime)!") + + +// Third Challenge +var counter = 0 +for _ in "What is this a string for ants?" { + counter += 1 +} + +print("There are \(counter) characters in that string!") + + +// Fourth Challenge +// use starTracker to store the # of *s +var starTracker = "" +// stopNum controls when to stop the loop +var stopNum = 4 + +for _ in 1...stopNum { + starTracker += "*" + print(starTracker) +} \ No newline at end of file diff --git a/4-loops/fizzbuzz/FizzBuzz.swift b/4-loops/fizzbuzz/FizzBuzz.swift index ef92eee..c39bda5 100644 --- a/4-loops/fizzbuzz/FizzBuzz.swift +++ b/4-loops/fizzbuzz/FizzBuzz.swift @@ -1,8 +1,9 @@ +// Fizz Buzz ๐Ÿ // Kenny Lin -// Solutions for FizzBuzz -// while loop: +// Using a while loop: var counter = 1 + while counter <= 100 { // Could also do: counter % 15 == 0 if counter % 3 == 0 && counter % 5 == 0 { @@ -17,7 +18,7 @@ while counter <= 100 { counter += 1 } -// for-in loop: +// Using a for-in loop: for num in 1...100 { // Could also do: num % 15 == 0 if num % 3 == 0 && num % 5 == 0 { @@ -71,4 +72,4 @@ for num in 1...500 { print(num) } } -*/ \ No newline at end of file +*/ diff --git a/4-loops/whale-talk/WhaleTalk.swift b/4-loops/whale-talk/WhaleTalk.swift index bb3c443..ec6d244 100644 --- a/4-loops/whale-talk/WhaleTalk.swift +++ b/4-loops/whale-talk/WhaleTalk.swift @@ -1,9 +1,7 @@ +// Whale Talk ๐Ÿ‹ // Kenny Lin -// Solution for Whale Talk -// Create your Whale Talk program below: - -var input = "I know not all that may be coming, but be it what it will, I'll go to it laughing. -Moby Dick" +var input = "I know not all that may be coming, but be it what it will, I'll go to it laughing. - Moby Dick" var output = "" diff --git a/4-loops/whale-talk/whale_talk.gif b/4-loops/whale-talk/whale_talk.gif new file mode 100644 index 0000000..6ce30c7 Binary files /dev/null and b/4-loops/whale-talk/whale_talk.gif differ diff --git a/5-arrays-and-sets/DNA.swift b/5-arrays-and-sets/DNA.swift new file mode 100644 index 0000000..4545f53 --- /dev/null +++ b/5-arrays-and-sets/DNA.swift @@ -0,0 +1,9 @@ +// DNA Sequencing ๐Ÿงฌ +// Sonny Li + +var dna = ["ATG", "ACG", "GAA", "TAT"] + +dna.insert("GTG", at: 3) +dna.remove(at: 0) + +print(dna) diff --git a/5-arrays-and-sets/NewYearNewMe.swift b/5-arrays-and-sets/NewYearNewMe.swift new file mode 100644 index 0000000..9e7b56e --- /dev/null +++ b/5-arrays-and-sets/NewYearNewMe.swift @@ -0,0 +1,11 @@ +// New Year Resolutions ๐Ÿ’ช +// Sonny Li + +var resolutions = ["play more music ๐ŸŽธ", + "read more books ๐Ÿ“š", + "drink more water ๐Ÿ’ง"] + +resolutions.append("cook more food ๐Ÿ") +resolutions += ["save more money ๐Ÿ’ฐ"] + +print(resolutions) diff --git a/5-arrays-and-sets/RetailTherapy.swift b/5-arrays-and-sets/RetailTherapy.swift new file mode 100644 index 0000000..caff896 --- /dev/null +++ b/5-arrays-and-sets/RetailTherapy.swift @@ -0,0 +1,14 @@ +// Receipt ๐Ÿงพ +// Sonny Li + +var receipt = [12.00, 3.75, 6.50, 19.99] + +var total: Double = 0.0 + +for item in receipt { + total += item +} + +total *= 1.08875 + +print(total) diff --git a/5-arrays/caesar-cipher/CaesarCipher.swift b/5-arrays-and-sets/caesar-cipher/CaesarCipher.swift similarity index 94% rename from 5-arrays/caesar-cipher/CaesarCipher.swift rename to 5-arrays-and-sets/caesar-cipher/CaesarCipher.swift index 5b61814..2c2ee5f 100644 --- a/5-arrays/caesar-cipher/CaesarCipher.swift +++ b/5-arrays-and-sets/caesar-cipher/CaesarCipher.swift @@ -1,4 +1,4 @@ -// Caesar Cipher (Swift) +// Caesar Cipher ๐Ÿ› // Sonny Li var alphabet: [Character] = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"] diff --git a/5-arrays-and-sets/caesar-cipher/project_thumbnail.png b/5-arrays-and-sets/caesar-cipher/project_thumbnail.png new file mode 100644 index 0000000..00ddba0 Binary files /dev/null and b/5-arrays-and-sets/caesar-cipher/project_thumbnail.png differ diff --git a/5-arrays/mixtape/AwesomeMixVol1.swift b/5-arrays-and-sets/mixtape/AwesomeMixVol1.swift similarity index 98% rename from 5-arrays/mixtape/AwesomeMixVol1.swift rename to 5-arrays-and-sets/mixtape/AwesomeMixVol1.swift index 85b5b39..8c949ee 100644 --- a/5-arrays/mixtape/AwesomeMixVol1.swift +++ b/5-arrays-and-sets/mixtape/AwesomeMixVol1.swift @@ -1,4 +1,4 @@ -// Make a Mixtape 101 ๐Ÿ“ป +// Make a Mixtape 101 ๐Ÿ“ผ // Sonny Li print(".------------------------. ") diff --git a/5-arrays/mixtape/Mixtape.swift b/5-arrays-and-sets/mixtape/Mixtape.swift similarity index 100% rename from 5-arrays/mixtape/Mixtape.swift rename to 5-arrays-and-sets/mixtape/Mixtape.swift diff --git a/5-arrays/mixtape/Taylor.swift b/5-arrays-and-sets/mixtape/Taylor.swift similarity index 98% rename from 5-arrays/mixtape/Taylor.swift rename to 5-arrays-and-sets/mixtape/Taylor.swift index ae7b385..7ba9fb8 100644 --- a/5-arrays/mixtape/Taylor.swift +++ b/5-arrays-and-sets/mixtape/Taylor.swift @@ -1,4 +1,5 @@ // Make a Mixtape 101 ๐Ÿ“ผ +// Sonny Li print(".------------------------.") print("| Tay Tay's Ultimate Mix |") diff --git a/5-arrays/palindrome/Palindrome.swift b/5-arrays-and-sets/palindrome/Palindrome.swift similarity index 75% rename from 5-arrays/palindrome/Palindrome.swift rename to 5-arrays-and-sets/palindrome/Palindrome.swift index 403765a..db8c60d 100644 --- a/5-arrays/palindrome/Palindrome.swift +++ b/5-arrays-and-sets/palindrome/Palindrome.swift @@ -1,25 +1,18 @@ -// Palindrome +// Palindrome ๐Ÿ’ฌ // Sonny Li var text = ["h", "e", "l", "l", "o"] - var reversed = [String]() var counter = text.count - 1 -while(counter >= 0) { - +while counter >= 0 { reversed.append(text[counter]) counter = counter - 1 - } -if (text == reversed) { - +if text == reversed { print("We have a palindrome!") - } else { - print("\(text) is not palindrome.") - } diff --git a/5-arrays/palindrome/palindrome_project_thumbnail.jpg b/5-arrays-and-sets/palindrome/palindrome_project_thumbnail.jpg similarity index 100% rename from 5-arrays/palindrome/palindrome_project_thumbnail.jpg rename to 5-arrays-and-sets/palindrome/palindrome_project_thumbnail.jpg diff --git a/5-arrays-and-sets/school-roster/Roster.swift b/5-arrays-and-sets/school-roster/Roster.swift new file mode 100644 index 0000000..16c1377 --- /dev/null +++ b/5-arrays-and-sets/school-roster/Roster.swift @@ -0,0 +1,63 @@ +// File Name: Roster.swift +// Author: Alex DiStasi +// Date: 3/3/2020 + +var spanish101: Set = ["Angela", "Declan", "Aldany", "Alex", "Sonny", "Alif", "Skyla"] +var german101: Set = ["Angela", "Alex", "Declan", "Kenny", "Cynara", "Adam"] +var advancedCalculus: Set = ["Cynara", "Gabby", "Angela", "Samantha", "Ana", "Aldany", "Galina", "Jasmine"] +var artHistory: Set = ["Samantha", "Vanessa", "Aldrian", "Cynara", "Kenny", "Declan", "Skyla"] +var englishLiterature: Set = ["Gabby", "Jasmine", "Alex", "Alif", "Aldrian", "Adam", "Angela"] +var computerScience: Set = ["Galina", "Kenny", "Sonny", "Alex", "Skyla"] + +// Write your code below ๐ŸŽ + +// Task Group: Creating a Roster of All Students +// Create a set of all students enrolled in at least 1 class +var allStudents = spanish101.union(german101) +allStudents = allStudents.union(advancedCalculus) +allStudents = allStudents.union(artHistory) +allStudents = allStudents.union(englishLiterature) +allStudents = allStudents.union(computerScience) + +// Print each student Name +for student in allStudents { + print(student) +} + +// Print the total number of students +print("Total number of students: \(allStudents.count)") + + + +// Task Group: Language Classes + +// Students taking no language class +var spanishAndGerman = spanish101.union(german101) +var noLanguages = allStudents.subtracting(spanishAndGerman) +print("Students taking no languages: \(noLanguages)") + +// Students taking Spanish101 OR German101, but not both +var oneLanguage = spanish101.symmetricDifference(german101) +print("Students taking only one lanuage: \(oneLanguage)") + +// Students taking Spanish101, German101, and English Literature +var languageAwardWinners = spanish101.intersection(german101).intersection(englishLiterature) +print("Language award winners: \(languageAwardWinners)") + + + +// Task Group: Class Size + +var sevenPlus = 0 + +// Create a set that contains sets +var classSet: Set = [spanish101, german101, englishLiterature, computerScience, artHistory, advancedCalculus] + +// Loop through classSet to find which sets have >= 7 students +for aClass in classSet { + if aClass.count >= 7 { + sevenPlus += 1 + } +} +print ("There are \(sevenPlus) classes with seven or more students.") + diff --git a/5-arrays-and-sets/swift_team.gif b/5-arrays-and-sets/swift_team.gif new file mode 100644 index 0000000..5e02fcf Binary files /dev/null and b/5-arrays-and-sets/swift_team.gif differ diff --git a/6-dictionaries/Morse Decoder/Morse.swift b/6-dictionaries/Morse Decoder/Morse.swift new file mode 100644 index 0000000..ce1c7de --- /dev/null +++ b/6-dictionaries/Morse Decoder/Morse.swift @@ -0,0 +1,125 @@ +// File Name: Morse.swift +// Author: Alex DiStasi +// Purpose: Encode and decode morse code messages + + +// Task Group: Setting Up + +var englishText = "this is a secret message" +var secretMessage = ".... --- .-- -.. -.-- .--. .- .-. - -. . .-." + +// Create a dictionary with letters as keys and morse code counterparts as values +var lettersToMorse: [String: String] = [ + "a": ".-", + "b": "-...", + "c": "-.-.", + "d": "-..", + "e": ".", + "f": "..-.", + "g": "--.", + "h": "....", + "i": "..", + "j": ".---", + "k": "-.-", + "l": ".-..", + "m": "--", + "n": "-.", + "o": "---", + "p": ".--.", + "q": "--.-", + "r": ".-.", + "s": "...", + "t": "-", + "u": "..-", + "v": "...-", + "w": ".--", + "x": "-..-", + "y": "-.--", + "z": "--..", + ".": ".-.-.-", + "!": "-.-.--", + "?": "..--..", + ",": "--..--" +] + + +// Encoding a Message + +// Empty string that will store a morse code message +var morseText = "" + +// Loop through each character in englishText +for element in englishText { + // Check if the value exists in the dictionary + if let morseChar = lettersToMorse["\(element)"]{ + // Append the letter to morseText + // Append a space to morseText because each letter is separated by a single space in morse code. + morseText += morseChar + " " + } + else{ + // Append 3 spaces to morseText because each word in a morse code message is separated by three spaces + morseText+=" " + } +} +print (morseText) + + +// Decoding a Message + +var decodedMessage = "" +var currMorse = "" +// morseCodeArray will store individual morse code letters from secretMessage +var morseCodeArray = [String]() + +// Loop through each character in secretMorse +for char in secretMessage { + // Check if char is not a space + if char != " " { + // Append the value of char to currMorse + currMorse.append(char) + } + + // If the value of char is a space character, the code in the else statement will be executed + else { + // Use a switch statement to assemble characters into individual morse code letters + switch currMorse { + case "": + currMorse += " " + case " ": + // Append a space to morseCodeArray + morseCodeArray.append(" ") + currMorse = "" + default: + // Append the morse code letter to the array + morseCodeArray.append(currMorse) + // Reset the value of currMorse + currMorse = "" + } + + } +} +// Append the final value of currMorse to morseCodeArray +morseCodeArray.append(currMorse) + +// Create an empty dictionary. This will hold morse code values as Keys and their english counter parts as Values +var morseToLetter: [String: String] = [:] + +// Iterate through letterToMorse dictionary, add the keys as values and the values as keys to the morseToLetter dictionary +for (letter,morseChar) in lettersToMorse{ + morseToLetter[morseChar]=letter +} + +// Go through each element in morseCodeArray and find the text value via the morseToLetter dictionary +for morseValue in morseCodeArray { + // Check if the value exists in the morseToLetter dictionary + if let letterChar = morseToLetter[morseValue]{ + //Append the values to decodedMessage + decodedMessage += letterChar + } + //if it's not in the dictionary, it's probably a space + else { + // Add a space to decodedMessage + decodedMessage += " " + } +} +print (decodedMessage) diff --git a/7-functions/rock-paper-scissors/RockPaperScissors.swift b/7-functions/rock-paper-scissors/RockPaperScissors.swift new file mode 100644 index 0000000..6287c83 --- /dev/null +++ b/7-functions/rock-paper-scissors/RockPaperScissors.swift @@ -0,0 +1,65 @@ +// Rock Paper Scissors +// Galina Podstrechnaya + +func getUserChoice(userInput: String) -> String { + if userInput == "rock" || userInput == "paper" || userInput == "scissors" { + return userInput; + } else { + return "You can only enter rock, paper, or scissors. Try again" + } +} + +func getComputerChoice() -> String { + let random = Int.random(in: 0...2) + + switch random { + case 0: + return "rock" + case 1: + return "paper" + case 2: + return "scissors" + default: + return "Invalid number" + } +} + + +func determineWinner(_ userChoice: String, _ compChoice: String) -> String { + + var decision: String = "It's a tie" + + switch userChoice { + case "rock": + if compChoice == "paper" { + decision = "The computer won" + } else if compChoice == "scissors"{ + decision = "The user won" + } + + case "paper": + if compChoice == "rock" { + decision = "The user won" + } else if compChoice == "scissors"{ + decision = "The computer won" + } + + case "scissors": + if compChoice == "rock" { + decision = "The computer won" + } else if compChoice == "paper" { + decision = "The user won" + } + default: + print("Something went wrong") + } + return decision +} + + +let userChoice = getUserChoice(userInput: "paper") +let compChoice = getComputerChoice() + +print("You threw \(userChoice)") +print("The computer threw \(compChoice)") +print(determineWinner(userChoice, compChoice)) \ No newline at end of file diff --git a/8-structures/Structured Exercise Regimen/Exercise.swift b/8-structures/Structured Exercise Regimen/Exercise.swift new file mode 100644 index 0000000..7021878 --- /dev/null +++ b/8-structures/Structured Exercise Regimen/Exercise.swift @@ -0,0 +1,42 @@ +// Write your code below ๐Ÿ’ช + +struct Exercise { + var name: String + var muscleGroups: [String] + var reps: Int + var sets: Int + var totalReps: Int + + init(name: String, muscleGroups: [String], reps: Int, sets: Int) { + self.name = name + self.muscleGroups = muscleGroups + self.reps = reps + self.sets = sets + self.totalReps = sets * reps + } +} + +var pushUp = Exercise(name: "Push up", muscleGroups: ["Triceps", "Chest", "Shoulders"], reps: 10, sets: 3) + +struct Regimen { + var dayOfWeek: String + var exercises: [Exercise] + + init(dayOfWeek: String, exercises: [Exercise]) { + self.dayOfWeek = dayOfWeek + self.exercises = exercises + } + + func printExercisePlan() { + print("Today is \(self.dayOfWeek) and you're going to:") + for exercise in self.exercises { + print("Do \(exercise.sets) sets of \(exercise.reps) \(exercise.name)s") + print("That's a total of \(exercise.totalReps) \(exercise.name)s") + } + } +} + +var mondayRegimen = Regimen(dayOfWeek: "Monday", exercises:[pushUp]) + +mondayRegimen.printExercisePlan() + diff --git a/9-classes/pokedex/Pokedex.swift b/9-classes/pokedex/Pokedex.swift new file mode 100644 index 0000000..9d7ad17 --- /dev/null +++ b/9-classes/pokedex/Pokedex.swift @@ -0,0 +1,56 @@ +// Pokdex (Sonny Li) + +class Pokemon { + var num = 0 + var name = "" + var type = [""] + var ability: [""] + + init(num: Int, name: String, type: [String], ability: [String]) { + self.num = num + self.name = name + self.type = type + self.ability = ability + } + + func displayInfo() { + print("No. #\(num)") + print("Name \(name)") + print("Type \(type)") + print("Abilities \(ability)") + print("===================================") + } +} + +class GigantamaxPokemon: Pokemon { + + var location = "" + + init(num: Int, name: String, type: [String], ability: [String], location: String) { + self.location = location + super.init(num: num, name: name, type: type, ability: ability) + + } + + override func displayInfo() { + print("No. #\(num)") + print("Name \(name)") + print("Type \(type)") + print("Abilities \(ability)") + print("Location \(location)") + print("===================================") + } +} + +var bulbasaur = Pokemon(num: 1, name: "Bulbasaur", type: ["Grass ๐ŸŒฑ", "Poison ๐Ÿ’€"], ability: ["Overgrow"]) + +var charmander = Pokemon(num: 4, name: "Charmander", type: ["Fire ๐Ÿ”ฅ"], ability: ["Blaze"]) + +var squirtle = Pokemon(num: 7, name: "Squirtle", type: ["Water ๐Ÿ’ง"], ability: ["Torrent"]) + +var charizard = GigantamaxPokemon(num: 6, name: "Charizard", type: ["Fire ๐Ÿ”ฅ"], ability: ["Blaze"], location: "Lake of Outrage") + +bulbasaur.displayInfo() +charmander.displayInfo() +squirtle.displayInfo() +charizard.displayInfo() diff --git a/README.md b/README.md index feb954f..e7c1a95 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ -**Curriculum Developer:** Sonny Li (sonny@codecademy.com) [![alt text][2]][2.1] [![alt text][1]][1.1] +**Curriculum Developer:** Sonny Li @@ -19,20 +19,15 @@ -[1.1]: http://www.twitter.com/sonnynomnom -[2.1]: http://www.github.com/sonnynomnom - [2.2]: http://www.github.com/linkcoding -[2.3]: http://www.github.com/galinap684 -[2.4]: http://www.github.com/adistasicc **Curriculum Developer:** Kenny Lin (kenny@codecademy.com) [![alt text][2]][2.2] -**Curriculum Developer:** Galina Podstrechnaya (galina@codecademy.com) [![alt text][2]][2.3] +**Curriculum Developer:** Galina Podstrechnaya -**Curriculum Developer:** Alex DiStasi (adistasi@codecademy.com) [![alt text][2]][2.4] +**Curriculum Developer:** Alex DiStasi **Artwork:** Tim Liedtke (https://www.timliedtke.com) @@ -78,50 +73,33 @@ https://www.codecademy.com/learn/learn-swift ## 3. Conditionals & Logic ## -- [ ] `CoinFlip.swift` -- [ ] `Grade.swift` -- [ ] `PH.swift` -- [ ] `Pokedex.swift` -- [ ] `Space.swift` -- [ ] `LeapYear.swift` - **Magic 8-Ball:** -- [ ] `Magic8.swift` - -**Harry Potter Sorting Hat:** - +- [x] [`Magic8Ball.swift`](https://github.com/Codecademy/learn-swift/blob/master/3-conditionals/magic-8-ball/Magic8Ball.swift) -- [ ] `SortingHat.swift` +## 4. Loops ## -**Rock Paper Scissors Lizard Spock:** - +**Whale Talk:** -- [ ] `RPS.swift` -- [ ] `RPSLS.swift` -- [ ] `RPSLS_if.swift` -- [ ] `RPSLS_switch.swift` +- [x] [`WhaleTalk.swift`](https://github.com/Codecademy/learn-swift/blob/master/4-loops/whale-talk/WhaleTalk.swift) -## 4. Loops ## +**99 Bottles:** -- [ ] `EnterPIN.swift` -- [ ] `Guess.swift` -- [ ] `Square.swift` -- [ ] `Troublemaker.swift` -- [ ] `99Bottles.swift` +- [x] [`Bottles.swift`](https://github.com/Codecademy/learn-swift/blob/master/4-loops/99-bottles/Bottles.swift) +- [x] [`FiveLittleMonkeys.swift`](https://github.com/Codecademy/learn-swift/blob/master/4-loops/99-bottles/FiveLittleMonkeys.swift) **Fizz Buzz:** -- [ ] `FizzBuzz.swift` - -**99 Bottles:** - -- [ ] `Bottles.swift` +- [x] [`FizzBuzz.swift`](https://github.com/Codecademy/learn-swift/blob/master/4-loops/fizzbuzz/FizzBuzz.swift) ## 5. Arrays ## +- [x] [`NewYearNewMe.swift`](https://github.com/Codecademy/learn-swift/blob/master/5-arrays/NewYearNewMe.swift) +- [x] [`DNA.swift`](https://github.com/Codecademy/learn-swift/blob/master/5-arrays/DNA.swift) +- [x] [`RetailTherapy.swift`](https://github.com/Codecademy/learn-swift/blob/master/5-arrays/RetailTherapy.swift) + **Make a Mixtape 101:** - [x] [`AwesomeMixVol1.swift`](https://github.com/Codecademy/learn-swift/blob/master/5-arrays/mixtape/AwesomeMixVol1.swift) @@ -129,18 +107,29 @@ https://www.codecademy.com/learn/learn-swift **Palindrome:** -- [ ] `Palindrome.swift` +- [x] [`Palindrome.swift`](https://github.com/Codecademy/learn-swift/blob/master/5-arrays/palindrome/Palindrome.swift) **Caesar's Cipher:** - [x] [`CaesarCipher.swift`](https://github.com/Codecademy/learn-swift/blob/master/5-arrays/caesar-cipher/CaesarCipher.swift) +## 6. Dictionaries ## + +## 7. Functions ## + +## 8. Structures ## + +## 9. Classes ## + --- -### Cheat Sheets (BETA) ### +### Cheatsheets ### -1. [Hello World](https://www.codecademy.com/learn/learn-swift/modules/learn-swift-hello-world/reference) -2. [Variables](https://www.codecademy.com/learn/learn-swift/modules/learn-swift-variables/reference) +1. [Hello World](https://www.codecademy.com/learn/learn-swift/modules/learn-swift-hello-world/cheatsheet) +2. [Variables](https://www.codecademy.com/learn/learn-swift/modules/learn-swift-variables/cheatsheet) +3. [Condtionals & Logic](https://www.codecademy.com/learn/learn-swift/modules/learn-swift-conditionals/cheatsheet) +4. [Loops](https://www.codecademy.com/learn/learn-swift/modules/learn-swift-loops/cheatsheet) +5. [Arrays](https://www.codecademy.com/learn/learn-swift/modules/learn-swift-arrays/cheatsheet) ### Skill Paths ### @@ -157,16 +146,10 @@ https://www.codecademy.com/learn/learn-swift ### Swift Style Guides ### -* Codecademy C++ Style Guide +* Codecademy Swift Style Guide * [LinkedIn Swift Style Guide](https://github.com/linkedin/swift-style-guide) * [Google Swift Style Guide](https://google.github.io/swift/) -### Hall of Fame ### - -* TBA - -
- ## Contribution Guidelines We'd love to have you contribute! diff --git a/swift-team.jpg b/swift-team.jpg new file mode 100644 index 0000000..61c33bb Binary files /dev/null and b/swift-team.jpg differ