Skip to content
DeepForgeby svx
All problems
EasyAlgorithmsal-311

Base64 Decode

Problem

Decode a standard base64 string back to the original text, ignoring padding.

Unpack each group of four characters into three bytes, keeping only the bytes that were actually encoded. The empty string decodes to the empty string.

Hint

The number of original bytes in the final group is known from how many characters remain after stripping padding.

Test cases

case 1
in: ["aGVsbG8="]
expected: "hello"
case 2
in: [""]
expected: ""
case 3
in: ["YQ=="]
expected: "a"
case 4
in: ["YWJj"]
expected: "abc"
case 5
in: ["TWFu"]
expected: "Man"
Starter codePython
def base64_decode(s):
    # Your code here
    pass

5 test cases · run your code against them in the editor