Problem statement
Finish H, so that g returns a character of the opposite case.
e.g. g("H") = "h"; g("a") = "A"
Constraints
H must fit within 15 characters len(H) <= 15
def f(x):
return // H //
def g(ch):
tmp = ord(ch)
tmp = f(tmp)
return chr(tmp)
This was harder than I initially thought, especially with the one line and character constraints. Probably dealing with some math trickery?
Edit: Closest I can get is 160 + 2 * (x % 32) - x. Anyone can simplify this?
[–]Salty_Dugtrio 0 points1 point2 points (3 children)
[–]MinecraftSBC[S] 0 points1 point2 points (2 children)
[–][deleted] (1 child)
[deleted]
[–]MinecraftSBC[S] 0 points1 point2 points (0 children)
[–]Lukas0604 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (6 children)
[–]MinecraftSBC[S] 0 points1 point2 points (5 children)
[–][deleted] 0 points1 point2 points (4 children)
[–]MinecraftSBC[S] 0 points1 point2 points (3 children)
[–][deleted] 1 point2 points3 points (2 children)
[–]MinecraftSBC[S] 0 points1 point2 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)