Soyuz Spacecraft Landing

Soyuz Spacecraft Landing

平庸将你的心灵烘干到没有一丝水分

然后荣光才会拨动你心灵最深处的弦

— Márquez, One Hundred Years of Solitude

使用SQL Server Management Studio的向导方式为新建的DB执行From Device Restore时,出现Error 提示:“The backup set holds a backup of a database other than the existing database”,使用以下方法解决:

  1. 删除新建的DB
  2. 直接右键Databases–>Restore Database
  3. 在弹出窗口中的To database栏位填写需要新建的DB名称(不存的名称)
  4. 选择From Device
  5. 选择DB的.bak备份文件
  6. done!

至今不知道“先建DB然后再还原这种常用方式”总是报错的原因,但是这两种方式是殊途同归,都可以达到Restore的目的,这种方式是Restore的同时新建一个DB.

Write a program that outputs the string representation of numbers from 1 to n.

But for multiples of three it should output Fizz instead of the number and for the multiples of five output Buzz. For numbers which are multiples of both three and five output FizzBuzz.

Example:

Input:
n = 15

Output:
Return:
[
    "1",
    "2",
    "Fizz",
    "4",
    "Buzz",
    "Fizz",
    "7",
    "8",
    "Fizz",
    "Buzz",
    "11",
    "Fizz",
    "13",
    "14",
    "FizzBuzz"
]

Solution Ⅰ:

class Solution(object):
    def fizzBuzz(self, n):
        """
        :type n: int
        :rtype: List[str]
        """
        self = []
        for i in range(1, n+1):
            if i % 15 == 0:
                self.append('FizzBuzz')
            elif i % 3 == 0:
                self.append('Fizz')
            elif i % 5 == 0:
                self.append('Buzz')
            else:
                self.append(str(i))

        return self

Solution Ⅱ:

class Solution(object):
    def fizzBuzz(self, n):
        """
        :type n: int
        :rtype: List[str]
        """
        self = []
        for x in range(1, n+1):
            self.append("Fizz"[x % 3 * 4:] + "Buzz"[x % 5 * 4:] or x)
        return self

via: http://zhangzhenyu.com.cn/, all copyright by Mr.zzy.