Data update
This commit is contained in:
parent
35bcdeebf8
commit
74c69a0df6
2427 changed files with 31826 additions and 3468 deletions
|
|
@ -1,6 +1,7 @@
|
|||
import extensions;
|
||||
import system'collections;
|
||||
import system'routines;
|
||||
import system'culture;
|
||||
|
||||
static RomanDictionary = Dictionary.new()
|
||||
.setAt("I".toChar(), 1)
|
||||
|
|
@ -16,7 +17,7 @@ extension op : String
|
|||
toRomanInt()
|
||||
{
|
||||
var minus := 0;
|
||||
var s := self.upperCase();
|
||||
var s := self.toUpper();
|
||||
var total := 0;
|
||||
|
||||
for(int i := 0, i < s.Length, i += 1)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,18 @@
|
|||
(var numerals {"M" 1000 "D" 500 "C" 100 "L" 50 "X" 10 "V" 5 "I" 1})
|
||||
|
||||
; Approach A
|
||||
(function ro->ar r
|
||||
(-> (reverse (upper-case r))
|
||||
(map numerals)
|
||||
(split-with val)
|
||||
(map (.. +0))
|
||||
(reduce @(((< % %1) + -)))))
|
||||
|
||||
; Approach B
|
||||
(function ro->ar r
|
||||
(-> (upper-case r)
|
||||
(map numerals)
|
||||
@(reduce (fn [sum lastv] curr [(+ sum curr ((< lastv curr) (* -2 lastv) 0)) curr]) [0 0])
|
||||
0))
|
||||
|
||||
(map ro->ar ["MDCLXVI" "MMMCMXCIX" "XLVIII" "MMVIII"])
|
||||
Loading…
Add table
Add a link
Reference in a new issue