Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
39 changes: 39 additions & 0 deletions Belal Dohal Exame.playground/Contents.swift
Original file line number Diff line number Diff line change
@@ -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.

4 changes: 4 additions & 0 deletions Belal Dohal Exame.playground/contents.xcplayground
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<playground version='5.0' target-platform='ios' buildActiveScheme='true' importAppTypes='true'>
<timeline fileName='timeline.xctimeline'/>
</playground>

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.
41 changes: 41 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.