Groovy web console

subscribe to the feed Subscribe
to this
site

prog test question

Published 3 months ago by Bob Bick
Actions Execute script  ▶ Edit in console Back to console Show/hide line numbers View recent scripts
def foo(def list, def count) {
   Map m = [:]
   list.each {
      if (m[it]) {
         m[it] = m[it] + 1
      } else {
         m[it] = 1
      }
   }
   m.findAll {a,b -> b == count  }.keySet()
}

println foo([1,2,99,4,99,3,1,2,99,6,4,1,1,99], 4)