GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — leetcode/python/412_Fizz_Buzz.py at master · qiyuangong/leetcode Expand file tree/ Copy path412_Fizz_Buzz.pyMore file actions 42 lines (39 loc) · 1.21 KB / Copy path412_Fizz_Buzz.pyFile metadata and controls42 lines (39 loc) · 1.21 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 class Solution(object): # def fizzBuzz(self, n): # """ # :type n: int # :rtype: List[str] # """ # res = [] # for i in range(1, n + 1): # if i % 3 == 0: # if i % 5 == 0: # res.append('FizzBuzz') # else: # res.append('Fizz') # elif i % 5 == 0: # res.append('Buzz') # else: # res.append(str(i)) # return res # def fizzBuzz(self, n): # """ # :type n: int # :rtype: List[str] # """ # res = [] # for i in range(1, n + 1): # curr = '' # if i % 3 == 0: # curr += 'Fizz' # if i % 5 == 0: # curr += 'Buzz' # if not len(curr): # curr += str(i) # res.append(curr) # return res def fizzBuzz(self, n): return [str(i) * (i % 3 != 0 and i % 5 != 0) + "Fizz" * (i % 3 == 0) + "Buzz" * (i % 5 == 0) for i in range(1, n + 1)] # def fizzBuzz(self, n): # return ['Fizz' * (not i % 3) + 'Buzz' * (not i % 5) or str(i) for i in range(1, n+1)] |
| You are visitor 01402792 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |