Skip to content

Instantly share code, notes, and snippets.

@poochin
Created May 27, 2011 01:44
Show Gist options
  • Select an option

  • Save poochin/994492 to your computer and use it in GitHub Desktop.

Select an option

Save poochin/994492 to your computer and use it in GitHub Desktop.
#!/usr/bin/python
# -*- coding: utf-8 -*-
import unittest
from random import randrange
class TestShuffle(unittest.TestCase):
def setUp(self):
pass
def testShuffle(self):
base = range(10)
self.assertNotEqual(base, shuffle(base))
def shuffle(array):
result = array[:]
for i in range(len(result) - 1):
j = randrange(i + 1, len(result))
result[i], result[j] = result[j], result[i]
return result
def main():
unittest.main()
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment