math.randomseed( os.time() )
local black, white, none, code = "X", "O", "-"
local colors, codeLen, maxGuess, rept, alpha, opt = 6, 4, 10, false, "ABCDEFGHIJKLMNOPQRST", ""
local guesses, results
function createCode()
    code = ""
    local dic, a = ""
    for i = 1, colors do
        dic = dic .. alpha:sub( i, i )
    end
    for i = 1, codeLen do
        a = math.floor( math.random( 1, #dic ) )
        code = code .. dic:sub( a, a )
        if not rept then
            dic = dic:sub(1, a - 1 ) .. dic:sub( a + 1, #dic )
        end
    end
end
function checkInput( inp )
    table.insert( guesses, inp )
    local b, w, fnd, str = 0, 0, {}, ""
    for bl = 1, codeLen do
        if inp:sub( bl, bl ) == code:sub( bl, bl ) then
            b = b + 1; fnd[bl] = true
        else
            for wh = 1, codeLen do
                if nil == fnd[bl] and wh ~= bl and inp:sub( wh, wh ) == code:sub( bl, bl ) then
                    w = w + 1; fnd[bl] = true
                end
            end
        end
    end
    for i = 1, b do str = str .. string.format( "%s ", black ) end
    for i = 1, w do str = str .. string.format( "%s ", white ) end
    for i = 1, 2 * codeLen - #str, 2 do str = str .. string.format( "%s ", none ) end
    table.insert( results, str )
    return b == codeLen
end
function play()
    local err, win, r = true, false;
    for j = 1, colors do opt = opt .. alpha:sub( j, j ) end
    while( true ) do
        createCode(); guesses, results = {}, {}
        for i = 1, maxGuess do
            err = true;
            while( err ) do
                io.write( string.format( "\n