Sha256: 484c1ec04030261f4eedf2b8d19c5954152bdd87e6788bcbf9c1cebaf8ef0691

Contents?: true

Size: 539 Bytes

Versions: 168

Compression:

Stored size: 539 Bytes

Contents

class RomanNumerals {
  def RomanNumerals() {
    Integer.metaClass.getRoman = {->
      def romanMappings = [
        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"
      ]

      def roman = new String()
      def num = delegate

      romanMappings.each() { k, v ->
        while (num >= k) {
          roman += v
          num -= k
        }
      }

      roman
    }
  }
}

Version data entries

168 entries across 168 versions & 1 rubygems

Version Path
trackler-2.2.1.119 tracks/groovy/exercises/roman-numerals/Example.groovy
trackler-2.2.1.118 tracks/groovy/exercises/roman-numerals/Example.groovy
trackler-2.2.1.117 tracks/groovy/exercises/roman-numerals/Example.groovy
trackler-2.2.1.116 tracks/groovy/exercises/roman-numerals/Example.groovy
trackler-2.2.1.115 tracks/groovy/exercises/roman-numerals/Example.groovy
trackler-2.2.1.114 tracks/groovy/exercises/roman-numerals/Example.groovy
trackler-2.2.1.113 tracks/groovy/exercises/roman-numerals/Example.groovy
trackler-2.2.1.111 tracks/groovy/exercises/roman-numerals/Example.groovy
trackler-2.2.1.110 tracks/groovy/exercises/roman-numerals/Example.groovy
trackler-2.2.1.109 tracks/groovy/exercises/roman-numerals/Example.groovy
trackler-2.2.1.108 tracks/groovy/exercises/roman-numerals/Example.groovy
trackler-2.2.1.107 tracks/groovy/exercises/roman-numerals/Example.groovy
trackler-2.2.1.106 tracks/groovy/exercises/roman-numerals/Example.groovy
trackler-2.2.1.105 tracks/groovy/exercises/roman-numerals/Example.groovy
trackler-2.2.1.104 tracks/groovy/exercises/roman-numerals/Example.groovy
trackler-2.2.1.103 tracks/groovy/exercises/roman-numerals/Example.groovy
trackler-2.2.1.102 tracks/groovy/exercises/roman-numerals/Example.groovy
trackler-2.2.1.101 tracks/groovy/exercises/roman-numerals/Example.groovy
trackler-2.2.1.100 tracks/groovy/exercises/roman-numerals/Example.groovy
trackler-2.2.1.99 tracks/groovy/exercises/roman-numerals/Example.groovy