Comment detail

アルファベットの繰り上がり (Nested Flatten)
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
def alpha( num ){
   def alphas = "A".."Z"
   def result = ""

   def mod = num % alphas.size()
   def next = (int)((num-mod)/alphas.size())
   if( next <= 0 ){
       result = alphas[num-1].toString()
   } else {
       result = alpha(next) + alphas[mod-1]
   }

   result
}

1..100.each{
    println alpha(it)
}

Index

Feed

Other

Link

Pathtraq

loading...