Skip to content

Commit

Permalink
Add some code to School roster
Browse files Browse the repository at this point in the history
  • Loading branch information
arthurwrls committed Oct 17, 2022
1 parent fb06c10 commit f553bd4
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ var artHistory: Set = ["Samantha", "Vanessa", "Aldrian", "Cynara", "Kenny", "Dec
var englishLiterature: Set = ["Gabby", "Jasmine", "Alex", "Alif", "Aldrian", "Adam", "Angela"]
var computerScience: Set = ["Galina", "Kenny", "Sonny", "Alex", "Skyla"]



var allStudents = spanish101.union(german101)
allStudents = advancedCalculus.union(artHistory)
allStudents = artHistory.union(englishLiterature)
Expand Down Expand Up @@ -39,3 +37,12 @@ for item in classSet {
}

print("Classes with 7+ students: \(sevenPlus) classes")

allStudents.remove("Skyla")
print("All students without Skyla: \(allStudents)")

var fieldTrip = computerScience.union(advancedCalculus)
print("Combine all students in computer science and advanced calculus")

fieldTrip = fieldTrip.subtracting(german101)
print("Students in field trip exluding german101: \(fieldTrip)")
41 changes: 41 additions & 0 deletions Codecademy.playground/Pages/Test_1.xcplaygroundpage/Contents.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
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"]



var allStudents = spanish101.union(german101)
allStudents = advancedCalculus.union(artHistory)
allStudents = artHistory.union(englishLiterature)
allStudents = computerScience.union(allStudents)

for item in allStudents {
print(item)
}

print("Students quantity: \(allStudents.count)")

var noLanguage = allStudents.subtracting(german101)
noLanguage = noLanguage.subtracting(spanish101)
print("Students not taken any language: \(noLanguage)")

var spanishOrGerman = spanish101.symmetricDifference(german101)
print("Student taken only one language: \(spanishOrGerman)")

var languageAwardWinners = spanish101.intersection(german101)
languageAwardWinners = languageAwardWinners.intersection(englishLiterature)
print("Students taken all languages and English literature: \(languageAwardWinners)")

var sevenPlus = 0
var classSet: Set = [spanish101, german101, advancedCalculus, artHistory, englishLiterature, computerScience]

for item in classSet {
if item.count >= 7 {
sevenPlus += 1
}
}

print("Classes with 7+ students: \(sevenPlus) classes")
Binary file not shown.

0 comments on commit f553bd4

Please sign in to comment.