DAY 3
0

## Day02｜Codewars 刷題日 (1)

hmm.. 我們還是換題好了 σ`∀´)σ

## 5kyu. Number of trailing zeros of N!

Write a program that will calculate the number of trailing zeros in a factorial of a given number.

N! = 1 * 2 * 3 * ... * N

### Examples

``````zeros(6) = 1
# 6! = 1 * 2 * 3 * 4 * 5 * 6 = 720 --> 1 trailing zero

zeros(12) = 2
# 12! = 479001600 --> 2 trailing zeros
``````

``````def zeros(n):
count = 0
while n >= 5:
count += n//5
n //= 5
return count
``````

count = n // 5 + n // 25 + n // 125 + ...

## 6kyu. Duplicate Encoder

The goal of this exercise is to convert a string to a new string where each character in the new string is "(" if that character appears only once in the original string, or ")" if that character appears more than once in the original string. Ignore capitalization when determining if a character is a duplicate.

### Examples

``````"din"      =>  "((("
"recede"   =>  "()()()"
"Success"  =>  ")())())"
"(( @"     =>  "))(("
``````

（本人犯的低級錯誤）

``````def duplicate_encode(word):
word = word.lower()
ans = ""
for i in word:
if word.count(i) > 1:
ans += ")"
else: ans += "("
return ans
``````