diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..99e1e0e Binary files /dev/null and b/.DS_Store differ diff --git a/Belal Dohal Exame.playground/Contents.swift b/Belal Dohal Exame.playground/Contents.swift new file mode 100644 index 0000000..15997ee --- /dev/null +++ b/Belal Dohal Exame.playground/Contents.swift @@ -0,0 +1,39 @@ +// MARK: Belal Ahmad Dohal +// Swift + +//Q1).Create a function that receives an integers array and returns the number that appeared only once. +func getOnlyOneNumber(arr:[Int]) -> [Int] { + var singleNumbers = [Int:Int]() + var result = [Int]() + for i in arr { + singleNumbers[i] = i + } + for i in singleNumbers { + result.append(i.key) + } + return result +} +//Q2).Create a function that receives a string then it converts uppercase letters into lowercase and vice versa. The function then should print the converted value. +func printConvertString(str:String) { + var result = "" + for i in str { + if i.isLowercase == true { + result += i.uppercased() + }else { + result += i.uppercased() + } + } + print(result) +} +//Q3).Create a function that receives an array of items & arrays and returns one flattened array with all items exluding null values. +func noNull(arr:[Any]) -> [Any] { + var result = [Any]() + for i in arr { + if i == nil { + result.append(i) + } + } + return result +} +//Q3).Create a function that receives a string that contains combination of parentheses, square brackets, and curly braces. Then, it returns true if every opening bracket has a closing pair. + diff --git a/Belal Dohal Exame.playground/contents.xcplayground b/Belal Dohal Exame.playground/contents.xcplayground new file mode 100644 index 0000000..cf026f2 --- /dev/null +++ b/Belal Dohal Exame.playground/contents.xcplayground @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/Belal Dohal Exame.playground/playground.xcworkspace/contents.xcworkspacedata b/Belal Dohal Exame.playground/playground.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..ca3329e --- /dev/null +++ b/Belal Dohal Exame.playground/playground.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/Belal Dohal Exame.playground/playground.xcworkspace/xcuserdata/mr_belal.xcuserdatad/UserInterfaceState.xcuserstate b/Belal Dohal Exame.playground/playground.xcworkspace/xcuserdata/mr_belal.xcuserdatad/UserInterfaceState.xcuserstate new file mode 100644 index 0000000..00d5d23 Binary files /dev/null and b/Belal Dohal Exame.playground/playground.xcworkspace/xcuserdata/mr_belal.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/README.md b/README.md index debb56b..92ded6e 100644 --- a/README.md +++ b/README.md @@ -51,3 +51,44 @@ Create a function that receives a string that contains combination of parenthese +=============== +// MARK: Belal Ahmad Dohal +// Swift + +//Q1).Create a function that receives an integers array and returns the number that appeared only once. +func getOnlyOneNumber(arr:[Int]) -> [Int] { + var singleNumbers = [Int:Int]() + var result = [Int]() + for i in arr { + singleNumbers[i] = i + } + for i in singleNumbers { + result.append(i.key) + } + return result +} +//Q2).Create a function that receives a string then it converts uppercase letters into lowercase and vice versa. The function then should print the converted value. +func printConvertString(str:String) { + var result = "" + for i in str { + if i.isLowercase == true { + result += i.uppercased() + }else { + result += i.uppercased() + } + } + print(result) +} +//Q3).Create a function that receives an array of items & arrays and returns one flattened array with all items exluding null values. +func noNull(arr:[Any]) -> [Any] { + var result = [Any]() + for i in arr { + if let num = i { + result.append(num) + } + } + return result +} +//Q3).Create a function that receives a string that contains combination of parentheses, square brackets, and curly braces. Then, it returns true if every opening bracket has a closing pair. + +