Sha256: dc8652177acf450a40017d65b592660b4507320f6ae320e5b2936eae21f49bfe

Contents?: true

Size: 523 Bytes

Versions: 50

Compression:

Stored size: 523 Bytes

Contents

class Roman {
  def Roman() {
    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

50 entries across 25 versions & 1 rubygems

Version Path
trackler-2.2.1.10 tracks/groovy/exercises/roman-numerals/Example.groovy
trackler-2.2.1.10 tracks/groovy/exercises/roman-numerals/Roman.groovy
trackler-2.2.1.9 tracks/groovy/exercises/roman-numerals/Example.groovy
trackler-2.2.1.9 tracks/groovy/exercises/roman-numerals/Roman.groovy
trackler-2.2.1.8 tracks/groovy/exercises/roman-numerals/Example.groovy
trackler-2.2.1.8 tracks/groovy/exercises/roman-numerals/Roman.groovy
trackler-2.2.1.7 tracks/groovy/exercises/roman-numerals/Example.groovy
trackler-2.2.1.7 tracks/groovy/exercises/roman-numerals/Roman.groovy
trackler-2.2.1.6 tracks/groovy/exercises/roman-numerals/Example.groovy
trackler-2.2.1.6 tracks/groovy/exercises/roman-numerals/Roman.groovy
trackler-2.2.1.5 tracks/groovy/exercises/roman-numerals/Roman.groovy
trackler-2.2.1.5 tracks/groovy/exercises/roman-numerals/Example.groovy
trackler-2.2.1.4 tracks/groovy/exercises/roman-numerals/Roman.groovy
trackler-2.2.1.4 tracks/groovy/exercises/roman-numerals/Example.groovy
trackler-2.2.1.3 tracks/groovy/exercises/roman-numerals/Roman.groovy
trackler-2.2.1.3 tracks/groovy/exercises/roman-numerals/Example.groovy
trackler-2.2.1.2 tracks/groovy/exercises/roman-numerals/Example.groovy
trackler-2.2.1.2 tracks/groovy/exercises/roman-numerals/Roman.groovy
trackler-2.2.1.1 tracks/groovy/exercises/roman-numerals/Roman.groovy
trackler-2.2.1.1 tracks/groovy/exercises/roman-numerals/Example.groovy