Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8855863
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T14:13:53+00:00 2026-06-14T14:13:53+00:00

I’m working on an assignment for my CIS class in python. We have to

  • 0

I’m working on an assignment for my CIS class in python. We have to code a Sudoku checker. In a 9×9 board we obviously have to check each row, col and 3×3 square for duplicates. I’m a little stuck on the idea of how to check the numbers by a 3×3 square. Below is my code for checking each row and col, if someone could help me a little with an outline or an approach just something for checking each 3×3 square that would be amazing!

self.columns = [ ]
     for col in range(9):
        col_tiles = [ ]
        self.columns.append(col_tiles)
        for row in range(9):
            col_tiles.append(self.tiles[row][col])
self.squares = [ ]
for col in range(1, 10, 3):
        for row in range(1, 10, 3):
            square_tiles = [ ]
            self.squares.append(square_tiles)
            for x in range(3):
                for y in range(3):
                    square_tiles.append(self.tiles[x][y])
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T14:13:54+00:00Added an answer on June 14, 2026 at 2:13 pm

    This assumes you have the freedom to read the data and structure how you want. We want a set of unique values 1-9 for each row/column/3×3 grid, so one way is to either use a set or a list comparison (we’ll use set here to make it cleaner). If we create a set equal to the numbers from 1 to 9, we have a point against which we can compare all of our other groups. Assume a structure like this (from here):

    In [1]: r1 = [9,3,2,5,4,8,1,7,6]
    
    In [2]: r2 = [1,8,7,9,2,6,5,4,3]
    
    In [3]: r3 = [5,4,6,3,7,1,2,8,9]
    
    # Continues....
    

    Where each row represents a full row of data. Now lets create a section of that data that represents the first three rows, pull out one grid and compare the contents to our set:

    In [4]: sec1 = [r1, r2, r3]
    
    In [5]: nums = set(range(1, 10))
    
    In [6]: nums == set(n for row in sec1 for n in row[:3])
    Out[6]: True
    

    This iterates over the first three rows and returns the first three elements in each of those rows. To get a better visual, here is the equivalent for-loop code to make it a bit easier to decipher:

    result = set()
    for row in sec1:
        for n in row[:3]:
          result.add(n)
    

    Since our set of numbers includes everything from 1-9, we know it is valid. To move to the second, we range the row[:3] to row[3:6] (and row[6:9] after that). You’ll then need to handle this for the next two sections as well. I’ll leave it to you as to how to wrap this in a more dynamic structure (note the multiples of three), but hopefully this will get you started 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
this is what i have right now Drawing an RSS feed into the php,
I have a small JavaScript validation script that validates inputs based on Regex. I
I have a French site that I want to parse, but am running into
I am doing a simple coin flipping experiment for class that involves flipping a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.