progs/roman_sol.scala
changeset 111 cd6b9fe4bce5
parent 109 293ea84d82ca
child 265 59779ce322a6
equal deleted inserted replaced
110:62389faa66e4 111:cd6b9fe4bce5
   108 String2Int("MMMCMXCIX") // 3999
   108 String2Int("MMMCMXCIX") // 3999
   109 String2Int("XLVIII")    // 48
   109 String2Int("XLVIII")    // 48
   110 String2Int("MMVIII")    // 2008
   110 String2Int("MMVIII")    // 2008
   111 
   111 
   112 String2Int("MMXI")      // 2011 
   112 String2Int("MMXI")      // 2011 
   113 String2Int("MIM")       // 1999
   113 String2Int("MIM")       // 2001
   114 String2Int("MCMLVI")    // 1956 
   114 String2Int("MCMLVI")    // 1956 
   115 
   115 
   116 String2Int("III") 	// 3
   116 String2Int("III") 	// 3
   117 String2Int("XXX") 	// 30
   117 String2Int("XXX") 	// 30
   118 String2Int("CCC") 	// 300
   118 String2Int("CCC") 	// 300
   150 }
   150 }
   151 
   151 
   152 
   152 
   153 addromanfile("roman.txt")
   153 addromanfile("roman.txt")
   154 
   154 
       
   155 val ls = """IIII
       
   156 IV        
       
   157 VI        
       
   158 IX        
       
   159 MCMLXXIX  
       
   160 MCMXLIV   
       
   161           
       
   162 MDCLXI    
       
   163 MMMCMXCIX 
       
   164 XLVIII    
       
   165 MMVIII    
       
   166 
       
   167 MMXI      
       
   168 MIM       
       
   169 MCMLVI    
       
   170 
       
   171 III     
       
   172 XXX     
       
   173 CCC     
       
   174 MMM     
       
   175 VII     
       
   176 LXVI    
       
   177 CL      
       
   178 MCC     
       
   179 IV      
       
   180 IX      
       
   181 XC      
       
   182 MDCLXVI""".split("\n").map(_.trim).map(String2Int(_)).flatten
       
   183 
       
   184 String2Int("MIM")
   155 
   185 
   156 // Part 2 about Validation of Roman Numerals
   186 // Part 2 about Validation of Roman Numerals
   157 //===========================================
   187 //===========================================
   158 
   188 
   159 def Digit2Int(r: RomanDigit) = r match {
   189 def Digit2Int(r: RomanDigit) = r match {