-
Notifications
You must be signed in to change notification settings - Fork 68
/
Copy pathFixBugs.rb
33 lines (23 loc) · 930 Bytes
/
FixBugs.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
=begin
In this Kata you should fix/create a program that returns the following values:
false/False if either a or b (or both) are not numbers
a % b plus b % a if both arguments are numbers
You may assume the following:
If a and b are both numbers, neither of a or b will be 0.
Language-Specific Instructions
Javascript and PHP
In this Kata you should try to fix all the syntax errors found in the code.
Once you think all the bugs are fixed run the code to see if it works.
A correct solution should return the values specified in the overview.
Extension: Once you have fixed all the syntax errors present in the code
(basic requirement), you may attempt to optimise the code or try a different
approach by coding it from scratch.
=end
# My Solution
def my_first_kata(a,b)
!a.is_a?(Integer) || !b.is_a?(Integer) ? false : (a % b) + (b % a)
end
# Better Solution
def my_first_kata(a,b)
a % b + b % a rescue false
end