From 628efbb37709c74ace09f8875cd48df0d5cd88f7 Mon Sep 17 00:00:00 2001 From: lor-engel <83264925+lor-engel@users.noreply.github.com> Date: Sat, 16 Oct 2021 19:36:51 -0700 Subject: [PATCH 1/2] Update README.md --- solutions/system_design/pastebin/README.md | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/solutions/system_design/pastebin/README.md b/solutions/system_design/pastebin/README.md index 2d87ddcc..11cda6b2 100644 --- a/solutions/system_design/pastebin/README.md +++ b/solutions/system_design/pastebin/README.md @@ -133,11 +133,12 @@ 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: + remainder = num % base + digits.append(remainder) + num = num // base + 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: From 1657d2fdaea064942b550e57c4a4d19b1e2cb419 Mon Sep 17 00:00:00 2001 From: lor-engel <83264925+lor-engel@users.noreply.github.com> Date: Sun, 17 Oct 2021 06:04:27 -0700 Subject: [PATCH 2/2] Update README.md --- solutions/system_design/pastebin/README.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/solutions/system_design/pastebin/README.md b/solutions/system_design/pastebin/README.md index 11cda6b2..21827721 100644 --- a/solutions/system_design/pastebin/README.md +++ b/solutions/system_design/pastebin/README.md @@ -134,10 +134,9 @@ To generate the unique url, we could: def base_encode(num, base=62): digits = [] while num > 0: - remainder = num % base + num, remainder = divmod(num, base) digits.append(remainder) - num = num // base - digits = digits.reverse() + digits.reverse() return digits ```