# Path: kaidoku/misc.py
# def blank(s):
#     """Count numbers of blank cells."""
#     blank = 0
#     for i in range(81):
#         if s[i] == 0:
#             blank = blank + 1
#     return (blank)
# 
# Path: kaidoku/misc.py
# def cell(i):
#     """Address of the cell."""
#     return ('R' + str(i // 9 + 1) + 'C' + str(i % 9 + 1))
# 
# Path: kaidoku/misc.py
# def check(s):
#     """Check if there is no duplicate numbers in same row, column and box."""
#     b = box()
#     for i in range(81):
#         if s[i] > 0:
#             for j in b[i]:
#                 if s[i] == s[j]:
#                     return ('Both ' + cell(i) + ' and ' + cell(j)
#                             + ' have the same value of ' + str(
#                             s[i]) + '.', True)
#     return ('', False)
# 
# Path: kaidoku/output.py
# def output(s):
#     """Convert to text output format."""
#     out = '  1 2 3 4 5 6 7 8 9\n'
#     out += ' +-----+-----+-----+\n'
#     for i in range(9):
#         out += str(i + 1) + '|'
#         for j in range(9):
#             v = s[i * 9 + j]
#             if v == 0:
#                 out += ' '
#             else:
#                 out = out + str(v)
#             if j % 3 == 2:
#                 out += "|"
#             else:
#                 out += ' '
#         out += '\n'
#         if i % 3 == 2:
#             out += ' +-----+-----+-----+\n'
#     return out


import datetime
import itertools
from kaidoku.misc import blank
from kaidoku.misc import cell
from kaidoku.misc import check
from kaidoku.output import output
    from kaidoku.misc import box
    from kaidoku.misc import line
    from kaidoku.misc import pbox
    from kaidoku.chain import pairchain
    from kaidoku.chain import remotepair
    from kaidoku.misc import boxlist
    from kaidoku.misc import combmir
    from kaidoku.misc import pairs
    from kaidoku.misc import wingpos
    from kaidoku.search import search
    from kaidoku.search import trial
    from kaidoku.wing import xwing
    from kaidoku.wing import xywing
    from kaidoku.wing import xyzwing
    from kaidoku.misc import box
    """Naked single."""
    for i in range(81):
        if s[i] == 0:
            for i2 in b[i]:
                v = s[i2]
                if v > 0:
                    p[i][v - 1] = 0
        else:
            p[i] = [10]

    found = False
    message = ''
    for i in range(81):
        if (sum(p[i])) == 0:
            if verbose > 0:
                message = 'This sudoku has no solution because ' + \
                    cell(i) + ' has no candidate.'
            return (s, p, message, False, True)
        if (sum(p[i])) == 1:
            i2 = p[i].index(1)
            found = True
            s[i] = i2 + 1
            if verbose > 3:
                if message == '':
                    message = ('Naked single: ')
                else:
                    message = message + ", "
                message = message + cell(i) + " = " + str(i2 + 1)

    if blank(s) == 0:

# Path: kaidoku/misc.py
# def blank(s):
#     """Count numbers of blank cells."""
#     blank = 0
#     for i in range(81):
#         if s[i] == 0:
#             blank = blank + 1
#     return (blank)
# 
# Path: kaidoku/misc.py
# def cell(i):
#     """Address of the cell."""
#     return ('R' + str(i // 9 + 1) + 'C' + str(i % 9 + 1))
# 
# Path: kaidoku/misc.py
# def check(s):
#     """Check if there is no duplicate numbers in same row, column and box."""
#     b = box()
#     for i in range(81):
#         if s[i] > 0:
#             for j in b[i]:
#                 if s[i] == s[j]:
#                     return ('Both ' + cell(i) + ' and ' + cell(j)
#                             + ' have the same value of ' + str(
#                             s[i]) + '.', True)
#     return ('', False)
# 
# Path: kaidoku/output.py
# def output(s):
#     """Convert to text output format."""
#     out = '  1 2 3 4 5 6 7 8 9\n'
#     out += ' +-----+-----+-----+\n'
#     for i in range(9):
#         out += str(i + 1) + '|'
#         for j in range(9):
#             v = s[i * 9 + j]
#             if v == 0:
#                 out += ' '
#             else:
#                 out = out + str(v)
#             if j % 3 == 2:
#                 out += "|"
#             else:
#                 out += ' '
#         out += '\n'
#         if i % 3 == 2:
#             out += ' +-----+-----+-----+\n'
#     return out


# Path: kaidoku/calc.py
import datetime
import itertools
from kaidoku.misc import blank
from kaidoku.misc import cell
from kaidoku.misc import check
from kaidoku.output import output
    from kaidoku.misc import box
    from kaidoku.misc import line
    from kaidoku.misc import pbox
    from kaidoku.chain import pairchain
    from kaidoku.chain import remotepair
    from kaidoku.misc import boxlist
    from kaidoku.misc import combmir
    from kaidoku.misc import pairs
    from kaidoku.misc import wingpos
    from kaidoku.search import search
    from kaidoku.search import trial
    from kaidoku.wing import xwing
    from kaidoku.wing import xywing
    from kaidoku.wing import xyzwing
    from kaidoku.misc import box

    """Naked single."""
    for i in range(81):
        if s[i] == 0:
            for i2 in b[i]:
                v = s[i2]
                if v > 0:
                    p[i][v - 1] = 0
        else:
            p[i] = [10]

    found = False
    message = ''
    for i in range(81):
        if (sum(p[i])) == 0:
            if verbose > 0:
                message = 'This sudoku has no solution because ' + \
                    cell(i) + ' has no candidate.'
            return (s, p, message, False, True)
        if (sum(p[i])) == 1:
            i2 = p[i].index(1)
            found = True
            s[i] = i2 + 1
            if verbose > 3:
                if message == '':
                    message = ('Naked single: ')
                else:
                    message = message + ", "
                message = message + cell(i) + " = " + str(i2 + 1)

    if blank(s) == 0:

        message2, err = check(s)