diff --git a/challenge1.playground/Contents.swift b/challenge1.playground/Contents.swift new file mode 100644 index 0000000..2ce687e --- /dev/null +++ b/challenge1.playground/Contents.swift @@ -0,0 +1,20 @@ +//Challenge 1 + +import UIKit + +func swap(inout var1: Any, inout with var2: Any) { (var1, var2) = (var2, var1) } + +var var1 = "hi", var2 = "bye" +swap(&var1, &var2) + +[var1, var2] + + + + + + + + + + diff --git a/challenge1.playground/contents.xcplayground b/challenge1.playground/contents.xcplayground new file mode 100644 index 0000000..5da2641 --- /dev/null +++ b/challenge1.playground/contents.xcplayground @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/challenge1.playground/playground.xcworkspace/contents.xcworkspacedata b/challenge1.playground/playground.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..919434a --- /dev/null +++ b/challenge1.playground/playground.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/challenge1.playground/playground.xcworkspace/xcuserdata/Riley.xcuserdatad/UserInterfaceState.xcuserstate b/challenge1.playground/playground.xcworkspace/xcuserdata/Riley.xcuserdatad/UserInterfaceState.xcuserstate new file mode 100644 index 0000000..246ef85 Binary files /dev/null and b/challenge1.playground/playground.xcworkspace/xcuserdata/Riley.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/challenge2.playground/Contents.swift b/challenge2.playground/Contents.swift new file mode 100644 index 0000000..9b84bc5 --- /dev/null +++ b/challenge2.playground/Contents.swift @@ -0,0 +1,26 @@ +//: Playground - noun: a place where people can play + + +func flexSrings(s1: String?, s2: String?) -> String +{ + if (s1==nil && s2==nil) { + return("none") + } + + if (s2==nil && s1 != nil) { + return(s1!) + } + + else { + return (s1!+s2!) + } + +} + + +flexSrings(nil, s2: nil) + + + + + diff --git a/challenge2.playground/contents.xcplayground b/challenge2.playground/contents.xcplayground new file mode 100644 index 0000000..5da2641 --- /dev/null +++ b/challenge2.playground/contents.xcplayground @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/challenge2.playground/playground.xcworkspace/contents.xcworkspacedata b/challenge2.playground/playground.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..919434a --- /dev/null +++ b/challenge2.playground/playground.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/challenge2.playground/playground.xcworkspace/xcuserdata/Riley.xcuserdatad/UserInterfaceState.xcuserstate b/challenge2.playground/playground.xcworkspace/xcuserdata/Riley.xcuserdatad/UserInterfaceState.xcuserstate new file mode 100644 index 0000000..572807f Binary files /dev/null and b/challenge2.playground/playground.xcworkspace/xcuserdata/Riley.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/challenge3.playground/Contents.swift b/challenge3.playground/Contents.swift new file mode 100644 index 0000000..aee32fe --- /dev/null +++ b/challenge3.playground/Contents.swift @@ -0,0 +1,48 @@ +func sumAny(inputs: Any...) -> String { + + var total: Int = 0 + + // add -10 if string is empty + if (inputs.isEmpty) { + total += -10 + } + + var i = 0 + + + // loop over all inputs + while (i= 0) { + total += inputVar + } + } + } + i += 1 // count to iterate over all inputs + } + + let totalString = String(total) + return totalString + } +print(sumAny("Marin Rood", 2, 22, "10", 0, 33, -5)) diff --git a/challenge3.playground/contents.xcplayground b/challenge3.playground/contents.xcplayground new file mode 100644 index 0000000..5da2641 --- /dev/null +++ b/challenge3.playground/contents.xcplayground @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/challenge3.playground/playground.xcworkspace/contents.xcworkspacedata b/challenge3.playground/playground.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..919434a --- /dev/null +++ b/challenge3.playground/playground.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/challenge3.playground/playground.xcworkspace/xcuserdata/Riley.xcuserdatad/UserInterfaceState.xcuserstate b/challenge3.playground/playground.xcworkspace/xcuserdata/Riley.xcuserdatad/UserInterfaceState.xcuserstate new file mode 100644 index 0000000..6253012 Binary files /dev/null and b/challenge3.playground/playground.xcworkspace/xcuserdata/Riley.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/challenge4.playground/Contents.swift b/challenge4.playground/Contents.swift new file mode 100644 index 0000000..4eab3c3 --- /dev/null +++ b/challenge4.playground/Contents.swift @@ -0,0 +1,9 @@ +func countFrom(from: Int, to: Int) { + print(from) + + if (from < to) { + countFrom(from + 1, to: to) + } +} + +countFrom(1, to: 5) diff --git a/challenge4.playground/contents.xcplayground b/challenge4.playground/contents.xcplayground new file mode 100644 index 0000000..5da2641 --- /dev/null +++ b/challenge4.playground/contents.xcplayground @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/challenge4.playground/playground.xcworkspace/contents.xcworkspacedata b/challenge4.playground/playground.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..919434a --- /dev/null +++ b/challenge4.playground/playground.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/challenge4.playground/playground.xcworkspace/xcuserdata/Riley.xcuserdatad/UserInterfaceState.xcuserstate b/challenge4.playground/playground.xcworkspace/xcuserdata/Riley.xcuserdatad/UserInterfaceState.xcuserstate new file mode 100644 index 0000000..c573100 Binary files /dev/null and b/challenge4.playground/playground.xcworkspace/xcuserdata/Riley.xcuserdatad/UserInterfaceState.xcuserstate differ