<commit_before>#!/usr/bin/python3
"""
Copyright (c) 2013, <NAME> <<EMAIL>>
All rights reserved.

Redistribution and use in source and binary forms,
with or without modification, are permitted provided
that the following conditions are met:

* Redistributions of source code must retain the
above copyright notice, this list of conditions
and the following disclaimer.
* Redistributions in binary form must reproduce
the above copyright notice, this list of conditions
and the following disclaimer in the documentation
and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS
AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.
"""

##Error codes
#5: too small screen.

import random
import math
import time
import sys
import platform  #Needed to detect if we are running on OSX
import curses
from curses import panel

#We need a workaround for OSX, which doesn't like set_curs() function.
if platform.system() == 'darwin':
    def show_cursor(value):
        return True;
else:
    def show_cursor(value):
        curses.curs_set(value)

min_width = 54  #Determinated by header banner
min_height = 20

card_header = {
    9  : 'P I N G O',
    16 : '  P I N G O  ',
    25 : 'P   I   N   G   O',
    36 : '  P   I   N   G   O  ',
    49 : '    P   I   N   G   O    '
}


class card:
    def __init__(self, size, level, y, x):
        self.size = size
        self.level = level
        self.numbers = []
        self.y = y
        self.x = x
        self.dimension = int(math.sqrt(self.size))

    def fill(self):
        rints = [i for i in                         #As in random ints
            range(1, int(self.size + ((self.size / 4) * self.level)))]
        random.shuffle(rints)
        for row in range(0, self.dimension):
            self.numbers.append([])
            for column in range(0, self.dimension):
                self.numbers[row].append(rints[(row*self.dimension+column)])

    def draw(self, wnumbers):
        for row in range(0, self.dimension):
            if row == 0:
                cwin.move(self.y, self.x)
                cwin.addstr('|' + ('----' * self.dimension)[:-1] + '|')
                cwin.move(cwin.getyx()[0] + 1, self.x)
                cwin.addstr('| ')
                cwin.attron(curses.A_BLINK)
                cwin.attron(curses.color_pair(1))
                cwin.addstr(card_header[self.size])
                cwin.refresh()
                cwin.attroff(curses.A_BLINK)
                cwin.attroff(curses.color_pair(1))
                cwin.addstr(' |')
                cwin.move(cwin.getyx()[0] + 1, self.x)
            cwin.addstr('|---' * self.dimension + '|')
            cwin.move(cwin.getyx()[0] + 1, self.x)
            for col in range(0, self.dimension):
                if self.numbers[row][col] in wnumbers:
                    color = 2       #Magenta on black
                else:
                    color = 3       #Green on black
                if self.numbers[row][col] >= 10:
                    cwin.addstr('| ')
                    cwin.attron(curses.color_pair(color))
                    cwin.addstr(str(self.numbers[row][col]))
                    cwin.attroff(curses.color_pair(color))
                else:
                    cwin.addstr('| ')
                    cwin.attron(curses.color_pair(color))
                    cwin.addstr(str(self.numbers[row][col]))
                    cwin.attroff(curses.color_pair(color))
                    cwin.addstr(' ')
            cwin.addstr('|')
            cwin.move(cwin.getyx()[0] + 1, self.x)
        cwin.addstr('|---' * self.dimension + '|')

    def check(self, wnumbers):
        vert = 0
        horz = 0
        topbot = 0

        for row in range(0, self.dimension):
            if set(self.numbers[row]).issubset(set(wnumbers)):
                horz += 1

        for col in range(0, self.dimension):
            column = []
            for row in self.numbers:
                column.append(row[col])
            if set(column).issubset(set(wnumbers)):
                vert += 1

        tb_array = []
        for i in range(0, self.dimension):
            tb_array.append(self.numbers[i][i])
        if set(tb_array).issubset(set(wnumbers)):
            topbot += 1

        tb_array = []
        for i in range(0, self.dimension):
            tb_array.append(self.numbers[self.dimension - 1 - i][i])
        if set(tb_array).issubset(set(wnumbers)):
            topbot += 1

        return (vert, horz, topbot)     #Number of vertical, horizontal and top
                                        #to bottom/left to right (MAX 2) bingos


def menu_size():
    mwin.erase()        #Make sure the screen is clean
    mwin.border()
    mwin.move(1, 1)
    mwin.addstr('Choose card size:')
    for size in card_sizes:
        mwin.move(mwin.getyx()[0] + 1, 1)
        if size == 25:
            mwin.addstr('   %d:\t%dx%d *' %
                (size, math.sqrt(size), math.sqrt(size)))
        else:
            mwin.addstr('   %d:\t%dx%d' %
                (size, math.sqrt(size), math.sqrt(size)))
        yx = mwin.getyx()
    mwin.move(mwin.getyx()[0] + 2, 1)
    mwin.addstr('q: quit', curses.color_pair(1))
    curses.echo()
    mwin.move(mwin.getyx()[0] + 1, 1)
    mwin.addstr(':> ')<commit_msg>Remove an old line, not needed anymore.<commit_after>#!/usr/bin/python3
"""
Copyright (c) 2013, <NAME> <<EMAIL>>
All rights reserved.

Redistribution and use in source and binary forms,
with or without modification, are permitted provided
that the following conditions are met:

* Redistributions of source code must retain the
above copyright notice, this list of conditions
and the following disclaimer.
* Redistributions in binary form must reproduce
the above copyright notice, this list of conditions
and the following disclaimer in the documentation
and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS
AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.
"""

##Error codes
#5: too small screen.

import random
import math
import time
import sys
import platform  #Needed to detect if we are running on OSX
import curses
from curses import panel

#We need a workaround for OSX, which doesn't like set_curs() function.
if platform.system() == 'darwin':
    def show_cursor(value):
        return True;
else:
    def show_cursor(value):
        curses.curs_set(value)

min_width = 54  #Determinated by header banner
min_height = 20

card_header = {
    9  : 'P I N G O',
    16 : '  P I N G O  ',
    25 : 'P   I   N   G   O',
    36 : '  P   I   N   G   O  ',
    49 : '    P   I   N   G   O    '
}


class card:
    def __init__(self, size, level, y, x):
        self.size = size
        self.level = level
        self.numbers = []
        self.y = y
        self.x = x
        self.dimension = int(math.sqrt(self.size))

    def fill(self):
        rints = [i for i in                         #As in random ints
            range(1, int(self.size + ((self.size / 4) * self.level)))]
        random.shuffle(rints)
        for row in range(0, self.dimension):
            self.numbers.append([])
            for column in range(0, self.dimension):
                self.numbers[row].append(rints[(row*self.dimension+column)])

    def draw(self, wnumbers):
        for row in range(0, self.dimension):
            if row == 0:
                cwin.move(self.y, self.x)
                cwin.addstr('|' + ('----' * self.dimension)[:-1] + '|')
                cwin.move(cwin.getyx()[0] + 1, self.x)
                cwin.addstr('| ')
                cwin.attron(curses.A_BLINK)
                cwin.attron(curses.color_pair(1))
                cwin.addstr(card_header[self.size])
                cwin.refresh()
                cwin.attroff(curses.A_BLINK)
                cwin.attroff(curses.color_pair(1))
                cwin.addstr(' |')
                cwin.move(cwin.getyx()[0] + 1, self.x)
            cwin.addstr('|---' * self.dimension + '|')
            cwin.move(cwin.getyx()[0] + 1, self.x)
            for col in range(0, self.dimension):
                if self.numbers[row][col] in wnumbers:
                    color = 2       #Magenta on black
                else:
                    color = 3       #Green on black
                if self.numbers[row][col] >= 10:
                    cwin.addstr('| ')
                    cwin.attron(curses.color_pair(color))
                    cwin.addstr(str(self.numbers[row][col]))
                    cwin.attroff(curses.color_pair(color))
                else:
                    cwin.addstr('| ')
                    cwin.attron(curses.color_pair(color))
                    cwin.addstr(str(self.numbers[row][col]))
                    cwin.attroff(curses.color_pair(color))
                    cwin.addstr(' ')
            cwin.addstr('|')
            cwin.move(cwin.getyx()[0] + 1, self.x)
        cwin.addstr('|---' * self.dimension + '|')

    def check(self, wnumbers):
        vert = 0
        horz = 0
        topbot = 0

        for row in range(0, self.dimension):
            if set(self.numbers[row]).issubset(set(wnumbers)):
                horz += 1

        for col in range(0, self.dimension):
            column = []
            for row in self.numbers:
                column.append(row[col])
            if set(column).issubset(set(wnumbers)):
                vert += 1

        tb_array = []
        for i in range(0, self.dimension):
            tb_array.append(self.numbers[i][i])
        if set(tb_array).issubset(set(wnumbers)):
            topbot += 1

        tb_array = []
        for i in range(0, self.dimension):
            tb_array.append(self.numbers[self.dimension - 1 - i][i])
        if set(tb_array).issubset(set(wnumbers)):
            topbot += 1

        return (vert, horz, topbot)     #Number of vertical, horizontal and top
                                        #to bottom/left to right (MAX 2) bingos


def menu_size():
    mwin.erase()        #Make sure the screen is clean
    mwin.border()
    mwin.move(1, 1)
    mwin.addstr('Choose card size:')
    for size in card_sizes:
        mwin.move(mwin.getyx()[0] + 1, 1)
        if size == 25:
            mwin.addstr('   %d:\t%dx%d *' %
                (size, math.sqrt(size), math.sqrt(size)))
        else:
            mwin.addstr('   %d:\t%dx%d' %
                (size, math.sqrt(size), math.sqrt(size)))
    mwin.move(mwin.getyx()[0] + 2, 1)
    mwin.addstr('q: quit', curses.color_pair(1))
    curses.echo()
    mwin.move(mwin.getyx()[0] + 1, 1)
    mwin.addstr(':> ')
{'fraction_non_alphanumeric': 0.11519029976423038, 'fraction_numerical': 0.011451667228022903, 'mean_word_length': 1.9559482329517173, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6127966', 'n_tokens_mistral': 3926, 'n_tokens_neox': 3589, 'n_words': 1060}