I have code for calculating the date for orthodox Easter and it makes me cry when I look at the if
-else
part. Please give your suggestions on how to make it shine (if possible).
I guess I can format day/month to DateTime format but I'm afraid it'll bring just more mess.
It works just fine though this.
puts "- Hello, I'm EasterEvaluator. I can tell you when will be(or was) Easter."
puts "- Please enter the year which you'r interested in:"
year = gets.chomp.to_i
a = year % 19
b = year % 4
c = year % 7
d = (19*a+15) % 30
e = (2*b + 4*c + 6*d + 6) % 7
f = d + e
if f<=9
easter = 22+f
easter = easter + 13 if year > 1918
if easter > 31
easter = easter - 31
month = "April"
else
month = "March"
end
else
easter = f-9
easter = easter + 13 if year > 1918
if easter > 30
easter = easter-30
month = "May"
else
month = "April"
end
end
puts "- In #{year}, Easter is going to be on #{easter} of #{month}."