Comment detail

比較しないソートの作成 (Nested Flatten)
比較していないかといわれると
しているような気もします。

お題をどう理解するかで変わってきますね。
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
def sort( min, max, count, list ){
   def larges = list.findAll{ it >= max }
   list -= larges
   def smalls = list.findAll{ it <= min }
   list -= smalls

   smalls + ((list.empty)?[]:sort(min-1, max-1, list.size(), list)) + larges
}

// 試行
def list = [-1,9,4,8,9,6,3,9,5,2]
println  sort(-10, 10, list.size(), list)

Index

Feed

Other

Link

Pathtraq

loading...