Problem 561871 · easy · Phase 05 Advanced Algorithms & Graphs

Case Variants of a Code

backtracking · strings · binary choices

A voucher code is a string code of lowercase letters, digits and dashes. The website accepts the code with the letters in any mixture of upper and lower case. Return every string that the website would accept, in any order. Digits and dashes never change.

Examples

Input:  code = "a1b"
Output: ["a1b", "A1b", "a1B", "A1B"]

Input:  code = "7-7"
Output: ["7-7"]

Input:  code = ""
Output: [""]

Constraints

  • 0 <= len(code) <= 10, at most 8 of them letters
  • The result therefore holds at most 256 strings.

Goals

  • Branch two ways for letters and one way for other characters
  • Build strings position by position with an index parameter
Starting Python…