Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Done #18

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Done #18

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
8 changes: 8 additions & 0 deletions .idea/.gitignore

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

6 changes: 6 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

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

4 changes: 4 additions & 0 deletions .idea/misc.xml

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

8 changes: 8 additions & 0 deletions .idea/modules.xml

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

15 changes: 15 additions & 0 deletions .idea/test-task-skeleton.iml

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

6 changes: 6 additions & 0 deletions .idea/vcs.xml

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

15 changes: 8 additions & 7 deletions test_skeleton.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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