Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Bogo

  shuffle = ->
    for x in [0..VA.length]
      VA.swap x, Math.floor(Math.random()*VA.length)
  
  sort = ->
    VA.play()
    if !checkSorted()
      shuffle()
      setTimeout(sort, 10)
    
  checkSorted = ->
    for x in [0..VA.length-1]
      if VA.gte(x, x+1)
          return false
    return true
  
  sort()


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: