Skip to content

Commit 6b2a9ce

Browse files
committed
solve 2 Codewars kata
1 parent 7400c5e commit 6b2a9ce

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

_codewars.rb

+23
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,26 @@
1+
# codewars kata: which are in?
2+
# http://www.codewars.com/kata/which-are-in/train/ruby
3+
4+
def in_array(array1, array2)
5+
string = array2.join(' ')
6+
array1.select { |substring| string.include? substring }.sort!
7+
end
8+
9+
10+
# codewars kata: deodorant evaporator
11+
# http://www.codewars.com/kata/deodorant-evaporator/train/ruby
12+
13+
def evaporator(content, evap_per_day, threshold)
14+
days = 0
15+
threshold_amount = threshold.fdiv(100) * content
16+
until content < threshold_amount do
17+
content -= evap_per_day.fdiv(100) * content
18+
days += 1
19+
end
20+
days
21+
end
22+
23+
124
# codewars kata: operations with sets
225
# http://www.codewars.com/kata/operations-with-sets/train/ruby
326

0 commit comments

Comments
 (0)