import random

def randomize():
    
    teams = ["Greece","Mexico","Italy","'Murica","Spain","Croatia","Serbia","Australia"]
    used = []
    m1 = []
    m2 = []
    m3 = []
    m4 = []

    def matchmake(mat,number):
        ri = random.randint(0,(7 - (2 * (number - 1))))
        mat.append(teams[ri])
        teams.remove(teams[ri])
        ri = random.randint(0,(6 - (2 * (number - 1))))
        mat.append(teams[ri])
        teams.remove(teams[ri])
        print(mat)
    
    matchmake(m1,1)
    matchmake(m2,2)
    matchmake(m3,3)
    matchmake(m4,4)

randomize()
var mines = []

function addcords() {
    for (let i = 11; i < 90; i++) {
        if (String(i)[0] != "9" && String(i)[0] != "0") {
            if (String(i)[1] != "9" && String(i)[1] != "0")
                mines.push({id:i, ms:0})
        }
    }
}

function placemines() { // early development, final should be more complex
    for (let i = 0; i < 10; i++) {
        r = Math.floor(Math.random() * 65)
        mines[r].ms = 9
    }
}

addcords()
placemines()
console.log(mines)
mines = { // object storing ids and number of surrounding mines
    cord: {

    }
}
nums = [] // all possible ids
mids = [] // ids of mines

function addcords() {
    for (let i = 11; i < 90; i++) {
        if (String(i)[0] != "9" && String(i)[0] != "0") {
            if (String(i)[1] != "9" && String(i)[1] != "0") {
                mines.cord[i] = {"ms" : 0}
                nums.push(i)
            }
        }
    }
}

function placemines() { // early development, final should be more complex
    for (let i = 0; i < 10; i++) {
        r = Math.floor(Math.random() * 64)
        if (mines.cord[nums[r]]["ms"] == 0) {
            mines.cord[nums[r]]["ms"] = 9
            mids.push(nums[r])
        }
    }
}

function calcmines() {
    dvals = [-11, -10, -9, -1, 1, 9, 10, 11]
    for (let i = 0; i < mids.length; i++) {
        for (let j = 0; j < dvals.length; j++) {
            try {
                mines.cord[mids[i] + dvals[j]]["ms"] += 1
                if (mines.cord[mids[i] + dvals[j]]["ms"] > 9){
                    mines.cord[mids[i] + dvals[j]]["ms"] -= 1
                }
            }
            catch(err) {
            }
        }
    }
}

addcords()
placemines()
calcmines()
console.log(mines)
console.log(mids)
{ cord: 
   { '11': { ms: 0 },
     '12': { ms: 0 },
     '13': { ms: 1 },
     '14': { ms: 2 },
     '15': { ms: 2 },
     '16': { ms: 1 },
     '17': { ms: 0 },
     '18': { ms: 0 },
     '21': { ms: 0 },
     '22': { ms: 0 },
     '23': { ms: 2 },
     '24': { ms: 9 },
     '25': { ms: 9 },
     '26': { ms: 1 },
     '27': { ms: 0 },
     '28': { ms: 0 },
     '31': { ms: 0 },
     '32': { ms: 0 },
     '33': { ms: 2 },
     '34': { ms: 9 },
     '35': { ms: 3 },
     '36': { ms: 1 },
     '37': { ms: 0 },
     '38': { ms: 0 },
     '41': { ms: 1 },
     '42': { ms: 2 },
     '43': { ms: 3 },
     '44': { ms: 2 },
     '45': { ms: 1 },
     '46': { ms: 1 },
     '47': { ms: 1 },
     '48': { ms: 1 },
     '51': { ms: 2 },
     '52': { ms: 9 },
     '53': { ms: 9 },
     '54': { ms: 1 },
     '55': { ms: 0 },
     '56': { ms: 1 },
     '57': { ms: 9 },
     '58': { ms: 1 },
     '61': { ms: 9 },
     '62': { ms: 3 },
     '63': { ms: 2 },
     '64': { ms: 1 },
     '65': { ms: 0 },
     '66': { ms: 1 },
     '67': { ms: 2 },
     '68': { ms: 2 },
     '71': { ms: 1 },
     '72': { ms: 1 },
     '73': { ms: 1 },
     '74': { ms: 1 },
     '75': { ms: 1 },
     '76': { ms: 0 },
     '77': { ms: 1 },
     '78': { ms: 9 },
     '81': { ms: 0 },
     '82': { ms: 0 },
     '83': { ms: 1 },
     '84': { ms: 9 },
     '85': { ms: 1 },
     '86': { ms: 0 },
     '87': { ms: 1 },
     '88': { ms: 1 } } }
[ 78, 24, 61, 57, 84, 52, 34, 25, 53 ]