Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
11
Task/Roman-numerals-Encode/Red/roman-numerals-encode-1.red
Normal file
11
Task/Roman-numerals-Encode/Red/roman-numerals-encode-1.red
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
Red []
|
||||
|
||||
table: [1000 M 900 CM 500 D 400 CD 100 C 90 XC 50 L 40 XL 10 X 9 IX 5 V 4 IV 1 I]
|
||||
|
||||
to-Roman: function [n [integer!] return: [string!]][
|
||||
out: copy ""
|
||||
foreach [a r] table [while [n >= a][append out r n: n - a]]
|
||||
out
|
||||
]
|
||||
|
||||
foreach number [40 33 1888 2016][print [number ":" to-Roman number]]
|
||||
13
Task/Roman-numerals-Encode/Red/roman-numerals-encode-2.red
Normal file
13
Task/Roman-numerals-Encode/Red/roman-numerals-encode-2.red
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
Red []
|
||||
|
||||
table: [1000 M 900 CM 500 D 400 CD 100 C 90 XC 50 L 40 XL 10 X 9 IX 5 V 4 IV 1 I]
|
||||
|
||||
to-Roman: func [n [integer!] return: [string!]][
|
||||
case [
|
||||
tail? table [table: head table copy ""]
|
||||
table/1 > n [table: skip table 2 to-Roman n]
|
||||
'else [append copy form table/2 to-Roman n - table/1]
|
||||
]
|
||||
]
|
||||
|
||||
foreach number [40 33 1888 2016][print [number ":" to-Roman number]]
|
||||
11
Task/Roman-numerals-Encode/Red/roman-numerals-encode-3.red
Normal file
11
Task/Roman-numerals-Encode/Red/roman-numerals-encode-3.red
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
Red []
|
||||
|
||||
to-Roman: function [n [integer!]] reduce [
|
||||
'case collect [
|
||||
foreach [a r] [1000 M 900 CM 500 D 400 CD 100 C 90 XC 50 L 40 XL 10 X 9 IX 5 V 4 IV 1 I][
|
||||
keep compose/deep [n >= (a) [append copy (form r) any [to-Roman n - (a) copy ""]]]
|
||||
]
|
||||
]
|
||||
]
|
||||
|
||||
foreach number [40 33 1888 2016][print [number ":" to-Roman number]]
|
||||
Loading…
Add table
Add a link
Reference in a new issue