Bingo with python

Bingo with python to kill time. I hate GUI so I don't use it 5 * 5 squares.

from random import choice
import itertools
import sys


def gett(dict, val):
    return [k for k, v in dict.items() if v == val]


def op(list1, list2):
    for x in list2:
        hmm = len(x)
        if len(set(x) & set(list1)) == hmm:
            return True
    return False


def bingo():
    input("Please press the enter key.")
    print("=========BINGO=========")
    lis = list(range(1, 76))

    def bingo_():
        bingo_print = ""
        for x in range(25):
            c_c = choice(lis)
            lis.remove(c_c)
            if x % 5 == 4:
                print(c_c)
                bingo_print += str(c_c)+"\n"
            elif x == 12:
                print("×  ", end="")
                bingo_print += "×  "
            else:
                if len(str(c_c)) == 1:
                    end_ = "  "
                else:
                    end_ = " "
                print(c_c, end=end_)
                bingo_print += str(c_c)+end_
        ch = bingo_print.split("\n")
        p = [x.split(" ") for x in ch]
        for x in p:
            for y in x:
                if not y:
                    x.remove(y)
        bind = dict(enumerate(list(itertools.chain.from_iterable(p))))
        print("\033[A", end="")
        print("=======================")
        k = 0
        xxx = list(range(1, 76))
        while k < 40:
            i = "×"
            while i == "×":
                i = choice(list(bind.values()))
            for x in range(25000):
                print("\r" + str(choice(xxx)), end="")
            print("\r" + str(i))
            if i in list(bind.values()):
                print("\033[31mATARI!! OMEDETO!!\033[0m")
                print("=========BINGO=========")
                for x, y in enumerate(list(bind.values())):
                    if y == i:
                        bind[gett(bind, y)[0]] = "×"
                        y = "×"
                    x = int(x)
                    if x % 5 == 4:
                        print(y)
                    else:
                        if len(str(y)) == 1 or y == "×":
                            e = "  "
                        else:
                            e = " "
                        print(y, end=e)
                xyz = sorted(gett(bind, "×"))
                zyx = [
                    list(range(4)),
                    list(range(5, 10)),
                    list(range(10, 15)),
                    list(range(15, 20)),
                    list(range(20, 25)),
                    [x*5 for x in range(5)],
                    [x*5+1 for x in range(5)],
                    [x*5+1 for x in range(5)],
                    [x*5+2 for x in range(5)],
                    [x*5+3 for x in range(5)],
                    [x*5+4 for x in range(5)],
                    [x*6 for x in range(5)],
                    [x*4 for x in range(4)]
                ]
                global foo
                foo = op(xyz, zyx)
                print("======================")
            else:
                print("HAZURE!! MATAARUSA!!")
                foo = False
            k += 1
            if k < 40:
                i = input("Did you become a bingo?\n(Y /N)")
                if i.lower() == "y":
                    if foo:
                        print("Congrats(・ З ・)")
                        sys.exit(0)
                    print("Liar ┌(┌^o^)┐")
                    sys.exit(0)
                elif i.lower() == "n":
                    if foo:
                        print("Liar ┌(┌^o^)┐")
                        sys.exit(0)
                    else:
                        print("Iiko Iiko(  ˊᵕˋ  )")
                else:
                    print("Illegal string")
                    sys.exit(0)
    bingo_()


bingo()

It took 3 hours. that was so hard

Recommended Posts

Bingo with python
FizzBuzz with Python3
Scraping with Python
Statistics with python
Scraping with Python
Python with Go
Twilio with Python
Integrate with Python
Play with 2016-Python
AES256 with python
Tested with Python
python starts with ()
with syntax (Python)
Zundokokiyoshi with python
Excel with Python
Microcomputer with Python
Cast with python
Serial communication with Python
Zip, unzip with python
Django 1.11 started with Python3.6
Primality test with Python
Python with eclipse + PyDev.
Socket communication with Python
Data analysis with python 2
Scraping with Python (preparation)
Learning Python with ChemTHEATER 03
Sequential search with Python
Run Python with VBA
Handling yaml with python
Solve AtCoder 167 with python
Serial communication with python
[Python] Use JSON with Python
Learning Python with ChemTHEATER 05-1
Learn Python with ChemTHEATER
Run prepDE.py with python3
1.1 Getting Started with Python
Collecting tweets with Python
Binarization with OpenCV / Python
3. 3. AI programming with Python
Kernel Method with Python
Non-blocking with Python + uWSGI
Scraping with Python + PhantomJS
Posting tweets with python
Use mecab with Python3
[Python] Redirect with CGIHTTPServer
Operate Kinesis with Python
Getting Started with Python
Use DynamoDB with Python
Zundko getter with python
Handle Excel with python
Ohm's Law with Python
Primality test with python
Run Blender with python
Solve Sudoku with Python
Python starting with Windows 7
Multi-process asynchronously with python
Python programming with Atom
Learning Python with ChemTHEATER 02
Competitive programming with python
Handle rabbimq with python
GRPC starting with Python