Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

18
Task/Nth/Ruby/nth.rb Normal file
View file

@ -0,0 +1,18 @@
class Integer
def ordinalize
num = self.abs
ordinal = if (11..13).include?(num % 100)
"th"
else
case num % 10
when 1; "st"
when 2; "nd"
when 3; "rd"
else "th"
end
end
"#{self}#{ordinal}"
end
end
[(0..25),(250..265),(1000..1025)].each{|r| puts r.map(&:ordinalize).join(", "); puts}