Last active
October 19, 2018 19:24
-
-
Save luckydonald/7d60fd94a7f45b4ef1ebd8241c6672ff to your computer and use it in GitHub Desktop.
LCD Challange, read only part 1 first: https://github.com/Chase22/NumberToLcd/tree/82c73574f5a84a2c99a33a0e6fb3dc32d473efcb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def num(n): | |
string = ["", "", ""] | |
for d in str(int(n)): | |
for i, l in enumerate(digit(int(d)).split("\n")): | |
string[i] += l | |
# end for | |
# end for | |
return "\n".join(string) | |
# end def | |
def digit(n): | |
string = " " | |
string += "." if n in (1,4) else "_" | |
string += " \n" | |
string += "'" if n in (1,2,3,7) else "|" | |
string += "." if n in (0,1,7) else "_" | |
string += "'" if n in (5,6) else "|" | |
string += "\n" | |
string += "|" if n in (0,2,6,8) else "'" | |
string += "." if n in (1,4,7) else "_" | |
string += "'" if n in (2,) else "|" | |
return string | |
# end def | |
for i in range(0,101): | |
print(num(i), i) | |
# end for |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def num(n, width=1, height=1): | |
string = [""] * (height + height + 3) | |
for d in str(int(n)): | |
for i, l in enumerate(digit(int(d), width, height).split("\n")): | |
string[i] += l | |
# end for | |
# end for | |
return "\n".join(string) | |
# end def | |
def digit(n, width=1, height=1): | |
string = " " + (("." if n in (1,4) else "_") * width) + " \n" | |
string += (("'" if n in (1,2,3,7) else "|") + (" " * width) + ("'" if n in (5,6) else "|") + "\n") * (height-1) | |
string += ("'" if n in (1,2,3,7) else "|") + (("." if n in (0, 1, 7) else "_") * width) + ("'" if n in (5,6) else "|") + "\n" | |
string += (("|" if n in (0,2,6,8) else "'") + (" " * width) + ("'" if n in (2,) else "|") + "\n") * (height-1) | |
string += ("|" if n in (0,2,6,8) else "'") + (("." if n in (1,4,7) else "_") * width) + ("'" if n in (2,) else "|") + "\n" | |
return string | |
# end def | |
for i in range(0,101): | |
print(num(i, width=3, height=2), i) | |
# end for |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment