Update README.md

pull/600/head
lor-engel 2021-10-16 19:36:51 -07:00 committed by GitHub
parent 6984b4e956
commit 628efbb377
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 5 deletions

View File

@ -133,11 +133,12 @@ To generate the unique url, we could:
```python ```python
def base_encode(num, base=62): def base_encode(num, base=62):
digits = [] digits = []
while num > 0 while num > 0:
remainder = modulo(num, base) remainder = num % base
digits.push(remainder) digits.append(remainder)
num = divide(num, base) num = num // base
digits = digits.reverse digits = digits.reverse()
return digits
``` ```
* Take the first 7 characters of the output, which results in 62^7 possible values and should be sufficient to handle our constraint of 360 million shortlinks in 3 years: * Take the first 7 characters of the output, which results in 62^7 possible values and should be sufficient to handle our constraint of 360 million shortlinks in 3 years: