Skip to content

Instantly share code, notes, and snippets.

@popey456963
Last active November 2, 2015 16:46
Show Gist options
  • Select an option

  • Save popey456963/0588a653f73484934b5d to your computer and use it in GitHub Desktop.

Select an option

Save popey456963/0588a653f73484934b5d to your computer and use it in GitHub Desktop.
Counting Up

#Title

Counting Up

#Statement Write a program that takes a {{String}} as it's input and outputs a [[String]] as output based on several factors:

  • If the [[character]] is an upper-case letter [A-Z] then print out the letters [A-[[character]]].
  • If the [[character]] is a lower-case letter [a-z] then print out the letters [a-[[character]]].
  • If the [[character]] is a digit [0-9], then print out the numbers [0-[[character]]]

#Input <> - A {{String}} containing a series of alphanumerical characters.

#Output <> - A {{String}} containing each character in the input, replaced with all the characters before it in the fashion stated above.

#Constraints

  • The {{String}} will be between 0 and 255 characters (inclusive)
  • The {{String}} will only contain alphanumerical characters

#Format

  • Superfast

#Game Modes

  • Fastest
  • Shortest
  • Reverse

#Test Cases

B --> AB
d --> abcd
5 --> 012345
Bd5 --> ABabcd012345

#Code

inputchar = input()
alphLower = "abcdefghijklmnopqrstuvwxyz"
alphHigher = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
numbers = "0123456789"
stack = ""
for i in inputchar:
    if i in alphLower:
        stack +=  alphLower[:alphLower.index(i)+1]
    if i in alphHigher:
        stack += alphHigher[:alphHigher.index(i)+1]
    if i in numbers:
        stack += numbers[:numbers.index(i)+1]
print(stack)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment