class Functionator
def initialize(s)
s.split(' ').each { | i | define_singleton_method :"#{i}" do Functionator.new(s.split(' ')[1..-1].join(' ')) end }
end
end
def functionator(string)
Functionator.new(string)
end
# TODO: Replace examples and use TDD development by writing your own tests
# These are some of the methods available:
# Test.expect(boolean, [optional] message)
# Test.assert_equals(actual, expected, [optional] message)
# Test.assert_not_equals(actual, expected, [optional] message)
describe "t e s t s" do
it "t e s t s" do
obj = functionator('there are two kinds of people')
Test.expect(obj.there().are().two().kinds().of().people(),'Chain is incorrect');
obj = functionator('hello codewars world')
Test.expect(obj.hello().codewars().world(),'Chain is incorrect');
obj = functionator('theraretwokindsofpeople')
Test.expect(obj.theraretwokindsofpeople,'theraretwokindsofpeople is not defined');
end
end
function getMin(list) { x = Math.min(...list.filter(i => i > 0)); return x !== Infinity ? x : 0 }
- function getMin(list) {
let ret = list.reduce((prev, curr) => {if (curr <= 0) return prev;return (prev <= 0) ? curr : Math.min(curr, prev);}, -1);return ret > 0 ? ret : 0;- x = Math.min(...list.filter(i => i > 0));
- return x !== Infinity ? x : 0
- }