Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
18
Task/Nth/Crystal/nth.crystal
Normal file
18
Task/Nth/Crystal/nth.crystal
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
struct Int
|
||||
def ordinalize
|
||||
num = self.abs
|
||||
ordinal = if (11..13).includes?(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{ |n| n.ordinalize }.join(", "); puts}
|
||||
Loading…
Add table
Add a link
Reference in a new issue