Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
7
Task/Nth/Picat/nth-1.picat
Normal file
7
Task/Nth/Picat/nth-1.picat
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
nth2(N) = N.to_string() ++ Th =>
|
||||
( tween(N) -> Th = "th"
|
||||
; 1 = N mod 10 -> Th = "st"
|
||||
; 2 = N mod 10 -> Th = "nd"
|
||||
; 3 = N mod 10 -> Th = "rd"
|
||||
; Th = "th" ).
|
||||
tween(N) => Tween = N mod 100, between(11, 13, Tween).
|
||||
7
Task/Nth/Picat/nth-2.picat
Normal file
7
Task/Nth/Picat/nth-2.picat
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
nth3(N) = cc(N,"th"), tween(N) => true.
|
||||
nth3(N) = cc(N,"st"), N mod 10 = 1 => true.
|
||||
nth3(N) = cc(N,"nd"), N mod 10 = 2 => true.
|
||||
nth3(N) = cc(N,"rd"), N mod 10 = 3 => true.
|
||||
nth3(N) = cc(N,"th") => true.
|
||||
% helper function
|
||||
cc(N,Th) = N.to_string() ++ Th.
|
||||
3
Task/Nth/Picat/nth-3.picat
Normal file
3
Task/Nth/Picat/nth-3.picat
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
nth4(N) = Nth =>
|
||||
Suffix = ["th","st","nd","rd","th","th","th","th","th","th"],
|
||||
Nth = N.to_string() ++ cond((N mod 100 <= 10; N mod 100 > 20), Suffix[1 + N mod 10], "th").
|
||||
5
Task/Nth/Picat/nth-4.picat
Normal file
5
Task/Nth/Picat/nth-4.picat
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
go =>
|
||||
Ranges = [ 0..25, 250..265, 1000..1025],
|
||||
foreach(Range in Ranges) println([nth2(I) : I in Range])
|
||||
end,
|
||||
nl.
|
||||
Loading…
Add table
Add a link
Reference in a new issue