Created
May 24, 2011 02:31
-
-
Save poochin/988044 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/python | |
| # -*- coding: utf-8 -*- | |
| import unittest | |
| class TestHist(unittest.TestCase): | |
| def setUp(self): | |
| self.datas = [35, 25, 56, 78, 43, 66, 71, 73, 80, 90, 0, 73, 35, 65, | |
| 100, 78, 80, 85, 35, 50] | |
| self.ans = [1, 0, 1, 3, 1, 2, 2, 5, 3, 1, 1] | |
| def testHist(self): | |
| self.assertEqual(self.ans, hist(self.datas)) | |
| def hist(points): | |
| histgram = [0 for _ in range(0, 11)] | |
| for point in points: | |
| if point < 0 or 100 < point: | |
| return False | |
| histgram[point / 10] += 1 | |
| return histgram | |
| 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