Skip to content

Commit

Permalink
Merge pull request #178 from Carrione/FreeCodingAnswersWithGuards
Browse files Browse the repository at this point in the history
FreeCoding.json update with Guard statements
  • Loading branch information
twostraws authored Feb 4, 2021
2 parents 018d6c4 + 8b431a5 commit 3a5ee7f
Showing 1 changed file with 40 additions and 2 deletions.
42 changes: 40 additions & 2 deletions Unwrap/Activities/Practice/FreeCoding/FreeCoding.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,16 @@
"func myFunction(input1:String,input2:String) -> Bool{\nletvar result:Bool\nresult = input1.uppercased() != input2.uppercased()\nreturn !result\n}",
"func myFunction(input1:String,input2:String) -> Bool{\nif input1.lowercased() == input2.lowercased(){\nreturn true\n}else{\nreturn false\n}\n}",
"func myFunction(input1:String,input2:String) -> Bool{\nif input1.lowercased() == input2.lowercased(){\nreturn true\n}\nreturn false\n}",
"func myFunction(input1:String,input2:String) -> Bool{\nguard input1.lowercased() == input2.lowercased() else { return false }\nreturn true\n}",
"func myFunction(input1:String,input2:String) -> Bool{\nif input1.uppercased() == input2.uppercased(){\nreturn true\n}else{\nreturn false\n}\n}",
"func myFunction(input1:String,input2:String) -> Bool{\nif input1.uppercased() == input2.uppercased(){\nreturn true\n}\nreturn false\n}",
"func myFunction(input1:String,input2:String) -> Bool{\nguard input1.uppercased() == input2.uppercased() else { return false }\nreturn true\n}",
"func myFunction(input1:String,input2:String) -> Bool{\nif input1.lowercased() != input2.lowercased(){\nreturn false\n}else{\nreturn true\n}\n}",
"func myFunction(input1:String,input2:String) -> Bool{\nif input1.lowercased() != input2.lowercased(){\nreturn false\n}\nreturn true\n}",
"func myFunction(input1:String,input2:String) -> Bool{\nguard input1.lowercased() != input2.lowercased() else { return true }\nreturn false\n}",
"func myFunction(input1:String,input2:String) -> Bool{\nif input1.uppercased() != input2.uppercased(){\nreturn false\n}else{\nreturn true\n}\n}",
"func myFunction(input1:String,input2:String) -> Bool{\nif input1.uppercased() != input2.uppercased(){\nreturn false\n}\nreturn true\n}"
"func myFunction(input1:String,input2:String) -> Bool{\nif input1.uppercased() != input2.uppercased(){\nreturn false\n}\nreturn true\n}",
"func myFunction(input1:String,input2:String) -> Bool{\nguard input1.uppercased() != input2.uppercased() else { return true }\nreturn false\n}
]
},
{
Expand Down Expand Up @@ -84,6 +88,10 @@
"var total:Int = 0\nfor number in numbers{\nif number == 5{\ntotal = total + 1\n}\n}\nprint(total)",
"var total:Int\ntotal = 0\nfor number in numbers{\nif number == 5{\ntotal += 1\n}\n}\nprint(total)",
"var total:Int\ntotal = 0\nfor number in numbers{\nif number == 5{\ntotal = total + 1\n}\n}\nprint(total)",
"var total:Int = 0\nfor number in numbers{\nguard number == 5 else { continue }\ntotal += 1\n}\nprint(total)",
"var total:Int = 0\nfor number in numbers{\nguard number == 5 else { continue }\ntotal = total + 1\n}\nprint(total)",
"var total:Int\ntotal = 0\nfor number in numbers{\nguard number == 5 else { continue }\ntotal += 1\n}\nprint(total)",
"var total:Int\ntotal = 0\nfor number in numbers{\nguard number == 5 else { continue }\ntotal = total + 1\n}\nprint(total)",
"var total:Int = 0\nfor number in numbers{\nif number != 5{\ncontinue\n}\ntotal += 1\n}\nprint(total)",
"var total:Int = 0\nfor number in numbers{\nif number != 5{ continue }\ntotal += 1\n}\nprint(total)",
"var total:Int\ntotal = 0\nfor number in numbers{\nif number != 5{\ncontinue\n}\ntotal += 1\n}\nprint(total)",
Expand All @@ -105,6 +113,9 @@
"var count = 0\nfor index in 0..<numbers.count {\nif numbers[index] == 5 {\ncount += 1\n}\n}\nprint(count)",
"var count = 0\nfor index in 0...numbers.count - 1 {\nif numbers[index] == 5 {\ncount += 1\n}\n}\nprint(count)",
"var count = 0\nfor index in 0...(numbers.count - 1) {\nif numbers[index] == 5 {\ncount += 1\n}\n}\nprint(count)",
"var count = 0\nfor index in 0..<numbers.count {\nguard numbers[index] == 5 else { continue }\ncount += 1\n}\nprint(count)",
"var count = 0\nfor index in 0...numbers.count - 1 {\nguard numbers[index] == 5 else { continue }\ncount += 1\n}\nprint(count)",
"var count = 0\nfor index in 0...(numbers.count - 1) {\nguard numbers[index] == 5 else { continue }\ncount += 1\n}\nprint(count)",
"var count = 0\nfor index in 0..<numbers.count {\nif numbers[index] != 5 { continue }\ncount += 1\n}\nprint(count)",
"var count = 0\nfor index in 0..<numbers.count {\nif numbers[index] != 5 {\ncontinue\n}\ncount += 1\n}\nprint(count)",
"var count = 0\nfor index in 0..<numbers.count {\nif numbers[index] != 5 {\ncontinue\n}else{\ncount += 1\n}\n}\nprint(count)",
Expand Down Expand Up @@ -168,7 +179,9 @@
"startingCode": "let names = [\"Terry Jones\", \"John Terry\", \"Terry Crews\", \"Terry Farrell\", \"Samuel Terry\"]",
"answers": [
"var parsed:[String] = [String]()\nfor name in names {\n\tif name.hasPrefix(\"Terry\") {\n\t\tparsed.append(name)\n\t}\n}",
"var parsed = [String]()\nfor name in names {\nguard name.hasPrefix(\"Terry\") else { continue }\nparsed.append(name)\n}",
"var parsed:[String] = [String]()\nfor name in names {\n\tif name.split(separator: \" \")[0] == \"Terry\" {\n\t\tparsed.append(name)\n\t}\n}",
"var parsed = [String]()\nfor name in names {\nguard name.split(separator: \" \")[0] == \"Terry\" else { continue }\nparsed.append(name)\n}",
"letvar parsed2:[String] = names.filter{optionalreturn $0.hasPrefix(\"Terry\")}",
"var parsed2 = [String]()\nparsed2 = names.filter{optionalreturn $0.hasPrefix(\"Terry\")}",
"letvar parsed2:[String] = names.filter{optionalreturn $0.split(separator: \" \")[0] == \"Terry\"}",
Expand All @@ -180,9 +193,18 @@
"var result = [String]()\nfor i in 0..<names.count {\nif names[i].hasPrefix(\"Terry\") {\nresult.append(names[i])\n}\n}",
"var result = [String]()\nfor i in 0...names.count - 1 {\nif names[i].hasPrefix(\"Terry\") {\nresult.append(names[i])\n}\n}",
"var result = [String]()\nfor i in 0...(names.count - 1) {\nif names[i].hasPrefix(\"Terry\") {\nresult.append(names[i])\n}\n}",
"var result = [String]()\nfor i in 0..<names.count {\nguard names[i].hasPrefix(\"Terry\") else { continue }\nresult.append(names[i])\n}",
"var result = [String]()\nfor i in 0...names.count - 1 {\nguard names[i].hasPrefix(\"Terry\") else { continue }\nresult.append(names[i])\n}",
"var result = [String]()\nfor i in 0...(names.count - 1) {\nguard names[i].hasPrefix(\"Terry\") else { continue }\nresult.append(names[i])\n}",
"var result = [String]()\nfor i in 0..<names.count {\nguard !names[i].hasPrefix(\"Terry\") else {\nresult.append(names[i])\ncontinue\n}\ncontinue\n}",
"var result = [String]()\nfor i in 0...names.count - 1 {\nguard !names[i].hasPrefix(\"Terry\") else {\nresult.append(names[i])\ncontinue\n}\ncontinue\n}",
"var result = [String]()\nfor i in 0...(names.count - 1) {\nguard !names[i].hasPrefix(\"Terry\") else {\nresult.append(names[i])\ncontinue\n}\ncontinue\n}",
"var result:[String] = [String]()\nfor i in 0..<names.count {\nif names[i].split(separator: \" \")[0] == \"Terry\" {\nresult.append(names[i])\n}\n}",
"var result:[String] = [String]()\nfor i in 0...names.count - 1 {\nif names[i].split(separator: \" \")[0] == \"Terry\" {\nresult.append(names[i])\n}\n}",
"var result:[String] = [String]()\nfor i in 0...(names.count - 1) {\nif names[i].split(separator: \" \")[0] == \"Terry\" {\nresult.append(names[i])\n}\n}"
"var result:[String] = [String]()\nfor i in 0...(names.count - 1) {\nif names[i].split(separator: \" \")[0] == \"Terry\" {\nresult.append(names[i])\n}\n}",
"var result = [String]()\nfor i in 0..<names.count {\nguard names[i].split(separator: \" \")[0] == \"Terry\" else { continue }\nresult.append(names[i])\n}",
"var result = [String]()\nfor i in 0...names.count - 1 {\nguard names[i].split(separator: \" \")[0] == \"Terry\" else { continue }\nresult.append(names[i])\n}",
"var result = [String]()\nfor i in 0...(names.count - 1) {\nguard names[i].split(separator: \" \")[0] == \"Terry\" else { continue }\nresult.append(names[i])\n}"
]
},
{
Expand Down Expand Up @@ -227,21 +249,37 @@
"var even1:[Int] = [Int]()\nfor i in 1...100 {\nif i % 2 == 1 { continue }\neven1.append(i)\n}",
"var even1:[Int] = [Int]()\nfor i in 1...100 {\nif i % 2 == 1 {\ncontinue\n}\neven1.append(i)\n}",
"var even1:[Int] = [Int]()\nfor i in 1...100 {\nif i % 2 == 1 {\ncontinue\n}else{\neven1.append(i)\n}\n}",
"var even1:[Int] = [Int]()\nfor i in 1...100 {\nguard i % 2 == 0 else { continue }\neven1.append(i)\n}",
"var even1:[Int] = [Int]()\nfor i in 1...100 {\nguard i % 2 != 0 else {\neven1.append(i)\ncontinue\n}\ncontinue\n}",
"var even1:[Int] = [Int]()\nfor i in 1...100 {\nguard i % 2 != 1 else { continue }\neven1.append(i)\n}",
"var even1:[Int] = [Int]()\nfor i in 1...100 {\nguard i % 2 == 1 else {\neven1.append(i)\ncontinue\n}\ncontinue\n}",
"var even2:[Int] = [Int]()\nfor i in 1...100 {\n\tletvar remainder = i % 2\n\tif remainder == 0 {\n\t\teven2.append(i)\n\t}\n}",
"var even1:[Int] = [Int]()\nfor i in 1...100 {\nletvar remainder = i % 2\nif remainder != 1 {\neven1.append(i)\n}\n}",
"var even1:[Int] = [Int]()\nfor i in 1...100 {\nletvar remainder = i % 2\nif remainder == 1 { continue }\neven1.append(i)\n}",
"var even1:[Int] = [Int]()\nfor i in 1...100 {\nletvar remainder = i % 2\nif remainder == 1 {\ncontinue\n}\neven1.append(i)\n}",
"var even1:[Int] = [Int]()\nfor i in 1...100 {\nletvar remainder = i % 2\nif remainder == 1 {\ncontinue\n}else{\neven1.append(i)\n}\n}",
"var even1:[Int] = [Int]()\nfor i in 1...100 {\nletvar remainder = i % 2\nguard remainder == 0 else { continue }\neven1.append(i)\n}",
"var even1:[Int] = [Int]()\nfor i in 1...100 {\nletvar remainder = i % 2\nguard remainder != 0 else {\neven1.append(i)\ncontinue\n}\ncontinue\n}",
"var even1:[Int] = [Int]()\nfor i in 1...100 {\nletvar remainder = i % 2\nguard remainder != 1 else { continue }\neven1.append(i)\n}",
"var even1:[Int] = [Int]()\nfor i in 1...100 {\nletvar remainder = i % 2\nguard remainder == 1 else {\neven1.append(i)\ncontinue\n}\ncontinue\n}",
"var even3:[Int] = [Int]()\nfor i in 1..<101 {\n\tif i % 2 == 0 {\n\t\teven3.append(i)\n\t}\n}",
"var even1:[Int] = [Int]()\nfor i in 1..<101 {\nif i % 2 != 1 {\neven1.append(i)\n}\n}",
"var even1:[Int] = [Int]()\nfor i in 1..<101 {\nif i % 2 == 1 { continue }\neven1.append(i)\n}",
"var even1:[Int] = [Int]()\nfor i in 1..<101 {\nif i % 2 == 1 {\ncontinue\n}\neven1.append(i)\n}",
"var even1:[Int] = [Int]()\nfor i in 1..<101 {\nif i % 2 == 1 {\ncontinue\n}else{\neven1.append(i)\n}\n}",
"var even1:[Int] = [Int]()\nfor i in 1..<101 {\nguard i % 2 == 0 else { continue }\neven1.append(i)\n}",
"var even1:[Int] = [Int]()\nfor i in 1..<101 {\nguard i % 2 != 0 else {\neven1.append(i)\ncontinue\n}\ncontinue\n}",
"var even1:[Int] = [Int]()\nfor i in 1..<101 {\nguard i % 2 != 1 else { continue }\neven1.append(i)\n}",
"var even1:[Int] = [Int]()\nfor i in 1..<101 {\nguard i % 2 == 1 else {\neven1.append(i)\ncontinue\n}\ncontinue\n}",
"var even4:[Int] = [Int]()\nfor i in 1..<101 {\n\tletvar remainder = i % 2\n\tif remainder == 0 {\n\t\teven4.append(i)\n\t}\n}",
"var even1:[Int] = [Int]()\nfor i in 1..<101 {\nletvar remainder = i % 2\nif remainder != 1 {\neven1.append(i)\n}\n}",
"var even1:[Int] = [Int]()\nfor i in 1..<101 {\nletvar remainder = i % 2\nif remainder == 1 { continue }\neven1.append(i)\n}",
"var even1:[Int] = [Int]()\nfor i in 1..<101 {\nletvar remainder = i % 2\nif remainder == 1 {\ncontinue\n}\neven1.append(i)\n}",
"var even1:[Int] = [Int]()\nfor i in 1..<101 {\nletvar remainder = i % 2\nif remainder == 1 {\ncontinue\n}else{\neven1.append(i)\n}\n}",
"var even1:[Int] = [Int]()\nfor i in 1..<101 {\nletvar remainder = i % 2\nguard remainder == 0 else { continue }\neven1.append(i)\n}",
"var even1:[Int] = [Int]()\nfor i in 1..<101 {\nletvar remainder = i % 2\nguard remainder != 0 else {\neven1.append(i)\ncontinue\n}\ncontinue\n}",
"var even1:[Int] = [Int]()\nfor i in 1..<101 {\nletvar remainder = i % 2\nguard remainder != 1 else { continue }\neven1.append(i)\n}",
"var even1:[Int] = [Int]()\nfor i in 1..<101 {\nletvar remainder = i % 2\nguard remainder == 1 else {\neven1.append(i)\ncontinue\n}\ncontinue\n}",
"var even5:[Int] = [Int]()\nfor i in stride(from: 2, through: 100, by: 2) {\n\teven5.append(i)\n}",
"letvar even6:[Int] = (1...100).filter { optionalreturn $0 % 2 == 0 }",
"letvar even7:[Int] = (1...100).filter { num in optionalreturn num % 2 == 0 }",
Expand Down

0 comments on commit 3a5ee7f

Please sign in to comment.