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
| import numpy | |
| DIMENSIONS = 3 | |
| SCREEN_DIMENSIONS = 2 | |
| class Palette(object): | |
| def __init__(self, zero, one): | |
| self.zero, self.one = numpy.array(zero), numpy.array(one) | |
| def color(self, c): |
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
| TEST_CASES = [ | |
| ('\x00', '37CE6F8BDF1ECE1E6771D61F3477C4EE71CF3793A0'), | |
| ('\x01\x02\x03\x04', '060960EAF8755D47AB14F62948CEE0ED010378755BB4A788'), | |
| ('\xFF', '0D295288F8563D9AA6324875B3EA7A9C841321F6CD'), | |
| # watch out: not '\xFF\xFF'. Typo is my fault. | |
| ('\xFFFF', '88C41CB3F295FD198F0351D44A1AF4BE4DB526D3341C52'), | |
| (''.join(map(chr, xrange(256))), '5E78B8D2B8A93AF01590AB44E647F8D0CFF663E3E120479B0C903E76199A6B8CA1B2073583B63A4A28A31C34B3B6355175983CEB7C452731712C83F6AE551511BBE2827603F1F4B8714E8A8584BD75B04811CFA65CDA95DB47E7F35BD49443FF2820C2AAA35E6B0701F932053212976A94EBDFA96F87FE7E9FA4E52CC87322E4A6B75AE762BC72704D2C48BF8A374C31B5D6733F5B1C42B85A7306FF8B4273DFE423845141B2777049FFEBB2730EBC8684FAA69371834FDF6A5F3850D4E185E2DFE16A860AF376FCCB34CA86068D08E8760B3C9A3C32511EE39EF38EECF2A89A2324BE0661A044313C7C3F160193B4C000A5D6EC7711FEF5D1EDCB95C455A9DF9438644D50F51928EED7F17CA42D589DD78D36C5')] | |
| if __name__ == '__main__': | |
| for plain, cipher in TEST_CASES: |
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
| ## no classes | |
| def Monster(name, hp, strength): | |
| return {"name": name, "hp": hp, "hp_left": hp, "strength": strength} | |
| def describe_monster(monster): | |
| return "A wild %s. %d/%d HP." % (monster["name"], monster["hp_left"], monster["hp"]) | |
| def sustain_damage(monster, damage): | |
| if damage > monster["hp_left"]: |
NewerOlder