diff --git a/.idea/.gitignore b/.idea/.gitignore
new file mode 100644
index 0000000..13566b8
--- /dev/null
+++ b/.idea/.gitignore
@@ -0,0 +1,8 @@
+# Default ignored files
+/shelf/
+/workspace.xml
+# Editor-based HTTP Client requests
+/httpRequests/
+# Datasource local storage ignored files
+/dataSources/
+/dataSources.local.xml
diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml
new file mode 100644
index 0000000..b0db9b0
--- /dev/null
+++ b/.idea/inspectionProfiles/Project_Default.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..b5b7f85
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 0000000..3cdd8ad
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/test-task-skeleton.iml b/.idea/test-task-skeleton.iml
new file mode 100644
index 0000000..6e7c09c
--- /dev/null
+++ b/.idea/test-task-skeleton.iml
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..94a25f7
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/test_skeleton.rb b/test_skeleton.rb
index 8f3e6f5..5519165 100644
--- a/test_skeleton.rb
+++ b/test_skeleton.rb
@@ -10,7 +10,7 @@ class TestSkeleton
# TestSkeleton.new.even_or_odd(0) should return "even"
# TestSkeleton.new.even_or_odd(-42) should return "even"
def even_or_odd(number)
- # Your solution should be here
+ number % 2 == 1 ? 'odd' : 'even'
end
# https://www.codewars.com/kata/5583090cbe83f4fd8c000051
@@ -21,7 +21,7 @@ def even_or_odd(number)
# TestSkeleton.new.reverse_array(348597) should return [7,9,5,8,4,3]
# TestSkeleton.new.reverse_array(0) should return [0]
def reverse_array(number)
- # Your solution should be here
+ number.to_s.reverse.chars.map{|c| c.to_i}
end
# https://www.codewars.com/kata/554b4ac871d6813a03000035
@@ -36,7 +36,7 @@ def reverse_array(number)
# There will always be at least one number in the input string.
# Output string must be two numbers separated by a single space, and highest number is first.
def high_and_low(test_string)
- # Your solution should be here
+ test_string.split.map{|i|i.to_i}.minmax.sort.reverse.join(' ')
end
# https://www.codewars.com/kata/5b16490986b6d336c900007d
@@ -49,7 +49,7 @@ def high_and_low(test_string)
# TestSkeleton.new.my_languages({"Hindi" => 60, "Dutch" => 93, "Greek" => 71}) should return ["Dutch", "Greek", "Hindi"]
# TestSkeleton.new.my_languages({"C++" => 50, "ASM" => 10, "Haskell" => 20}) should return []
def my_languages(hash)
- # Your solution should be here
+ hash.select{|v,k| k >= 60}.sort_by{|k,v| -v}.map{|k,v| k}
end
# https://www.codewars.com/kata/563089b9b7be03472d00002b
@@ -62,7 +62,7 @@ def my_languages(hash)
# values_list = [1, 3, 4, 2]
# TestSkeleton.new.remove_array_elements(integer_list, values_list) should return [5, 6 ,7 ,8]
def remove_array_elements(source_array, values_array)
- # Your solution should be here
+ source_array - values_array
end
# https://www.codewars.com/kata/5b39e91ee7a2c103300018b3
@@ -72,7 +72,7 @@ def remove_array_elements(source_array, values_array)
# string = "alpha beta beta gamma gamma gamma delta alpha beta beta gamma gamma gamma delta"
# TestSkeleton.new.consecutive_duplicates(string) should return "alpha beta gamma delta alpha beta gamma delta"
def consecutive_duplicates(string)
- # Your solution should be here
+ string.split(' ').slice_when{|w1,w2| w1 != w2}.map{|arr| arr[0]}.join(' ')
end
# https://www.codewars.com/kata/56747fd5cb988479af000028
@@ -90,6 +90,7 @@ def consecutive_duplicates(string)
# Output:
# The middle character(s) of the word represented as a string.
def middle_chars(test_string)
- # Your solution should be here
+ i = (test_string.length + 1) / 2
+ test_string[i-1..-i]
end
end