diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/.idea/coding-challenges.iml b/.idea/coding-challenges.iml new file mode 100644 index 0000000..d6ebd48 --- /dev/null +++ b/.idea/coding-challenges.iml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..639900d --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..1e88721 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/README.md b/README.md index debb56b..cf6c922 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,18 @@ Create a function that receives an integers array and returns the number that ap | (1,1,2) | 2 | | (2,2,1) | 1 | +fun OnlyOnce(var numbers: Array):Int{ + foreach (i in numbers.size){ + var x : Int + if (i == x){ + //do nothing its existed + } + else{ + return i + } + x = i + } +} ## 2nd Challenge 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. @@ -21,6 +33,14 @@ Create a function that receives a string then it converts uppercase letters into | My name is Ali | mY NAME IS aLI | | sHroog | ShROOG | +fun Strings.toLowercase (val h :String ){ + this.super() + if(h.char){} +} + + + + ## 3rd Challenge Create a function that receives an array of items & arrays and returns one flattened array with all items exluding null values. @@ -33,6 +53,10 @@ Create a function that receives an array of items & arrays and returns one flatt | 4 | [3, 5, [5, 9, 0]] | [3, 5, 5, 9, 0] | +fun (array:Array):Array{ +return array.filter(Number) +} + ## 4th Challenge 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. @@ -49,5 +73,11 @@ Create a function that receives a string that contains combination of parenthese | {[(}]) | true | | {[}]) | false | - +fun g (var g : String):Boolean{ +if (g.count > 1){ +return false +} +elseif(){ +} +}