May-09-2022, 01:11 PM
(May-09-2022, 12:17 PM)codingCat Wrote: And here is another offering of my own -- I took the random maze idea from youTube's 8-bit guy and combined it with a random maze idea of my own. I had to do a little research as I've never had a reason to use the single line if/else before (as a teacher, readability is important).
from random import randint if randint(0,1) == 0: cnt = 0 while True: str = "/" if randint(0,1) == 0 else "\\" print(str,end="") cnt = cnt + 1 if cnt % 80 == 0: print() else: flag = 0 rooms = 30 while True: flag = 1 if flag == 0 else 0 print("|",end="") for i in range(0,rooms): wall = randint(0,1) if flag == 0: str = "--+" if wall == 0 else " +" else: str = " |" if wall == 0 or i == rooms - 1 else " " print(str,end="") print("")
Hello,
from random import randint if randint(0,1) == 0: while True: for cnt in range(1, 81): print("/" if randint(0,1) == 0 else "\\", end="" if cnt != 80 else "\n") flag = 0 while True: flag = 1 if flag == 0 else 0 print("|",end="") for i in range(0,rooms:=30): wall = randint(0,1) if flag == 0: print("--+" if wall == 0 else " +", end="" if i !=29 else "\n") else: print(" |" if wall == 0 or i == rooms - 1 else " ", end="" if i!=29 else "\n")
I speak Python but I don't speak English (I just read it a little). If I express myself badly, please blame the translator^^.