pull/600/merge
lor-engel 2024-12-02 18:06:22 +00:00 committed by GitHub
commit 57588f5f5a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 5 additions and 5 deletions

View File

@ -133,11 +133,11 @@ To generate the unique url, we could:
```python
def base_encode(num, base=62):
digits = []
while num > 0
remainder = modulo(num, base)
digits.push(remainder)
num = divide(num, base)
digits = digits.reverse
while num > 0:
num, remainder = divmod(num, base)
digits.append(remainder)
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: