一般编程题,但是题目的叙述方式真的好奇怪
1 class ImageDithering: 2 def count(self, dithered, screen): 3 counter = 0 4 for line in screen: 5 for ch in line: 6 if ch in dithered: 7 counter += 1 8 return counter 9 10 11 # test 12 o = ImageDithering() 13 14 # test case 15 assert(o.count('BW', ("AAAAAAAA", 16 "ABWBWBWA", 17 "AWBWBWBA", 18 "ABWBWBWA", 19 "AWBWBWBA", 20 "AAAAAAAA")) == 24)