Update all new Tasks
This commit is contained in:
parent
00a190b0a6
commit
91df62d461
5697 changed files with 93386 additions and 804 deletions
18
Task/Nth/Ruby/nth.rb
Normal file
18
Task/Nth/Ruby/nth.rb
Normal 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}
|
||||
Loading…
Add table
Add a link
Reference in a new issue