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

  • SEARCH
  • Home
  • 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 3949522
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T01:30:13+00:00 2026-05-20T01:30:13+00:00

I am trying to build a Sudoku solver for a project I am working

  • 0

I am trying to build a Sudoku solver for a project I am working on. I have a 9×9 grid with each position numbered 0..80, left to right, top to bottom

e.g.:

0 1 2 3 4 5 6 7 8

9 10 …

I am trying to return a list of Int’s that represent the 3×3 grid that a position falls in. For example for position 1, which is in grid (0,0) it would return [0,1,2,9,10,11,18,19,20] and for position 8, which is in grid (0,2) it would return [6,7,8,15,16,17,24,25,26].

I have written a function which returns the required 3×3 grid, on a 9×9 Sudoku:

getBlock :: Int -> Int -> [[Int]]
getBlock x y = [[((x * sudokuSizeSq + 0) * sudokuSize) + (y * sudokuSizeSq + 0),((x * sudokuSizeSq + 0) * sudokuSize) + (y * sudokuSizeSq + 1)..((x * sudokuSizeSq + 0) * sudokuSize) + (y * sudokuSizeSq + (sudokuSizeSq-1))],[((x * sudokuSizeSq + 1) * sudokuSize) + (y * sudokuSizeSq + 0),((x * sudokuSizeSq + 1) * sudokuSize) + (y * sudokuSizeSq + 1)..((x * sudokuSizeSq + 1) * sudokuSize) + (y * sudokuSizeSq + (sudokuSizeSq-1))],[((x * sudokuSizeSq + 2) * sudokuSize) + (y * sudokuSizeSq + 0),((x * sudokuSizeSq + 2) * sudokuSize) + (y * sudokuSizeSq + 1)..((x * sudokuSizeSq + 2) * sudokuSize) + (y * sudokuSizeSq + (sudokuSizeSq-1))]]

Where:
sudokuSizeSq is the square of the width (3)
sudokuSize is the width (9)

x and y represent the possible grids.

This works, however I would like to increase it so it will work for larger grids. I changed my code to the follow but it seems then wont load the function.

getBlock :: Int -> Int -> [[Int]]
getBlock x y = [[((x * sudokuSizeSq + 0) * sudokuSize) + (y * sudokuSizeSq + 0),((x * sudokuSizeSq + 0) * sudokuSize) + (y * sudokuSizeSq + 1)..((x * sudokuSizeSq + 0) * sudokuSize) + (y * sudokuSizeSq + (sudokuSizeSq-1))],[((x * sudokuSizeSq + 1) * sudokuSize) + (y * sudokuSizeSq + 0),((x * sudokuSizeSq + 1) * sudokuSize) + (y * sudokuSizeSq + 1)..((x * sudokuSizeSq + 1) * sudokuSize) + (y * sudokuSizeSq + (sudokuSizeSq-1))]..[((x * sudokuSizeSq + (sudokuSizeSq-1)) * sudokuSize) + (y * sudokuSizeSq + 0),((x * sudokuSizeSq + (sudokuSizeSq-1)) * sudokuSize) + (y * sudokuSizeSq + 1)..((x * sudokuSizeSq + (sudokuSizeSq-1)) * sudokuSize) + (y * sudokuSizeSq + (sudokuSizeSq-1))]]

The way I’m doing it seems very cumbersome, is there a better way to do this or a way to fix the problem I’m having. Thanks.

  • 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-05-20T01:30:13+00:00Added an answer on May 20, 2026 at 1:30 am
    [ a + b
    | a <- take sudokuSizeSq $ map (sudokuSize *) [x * sudokuSizeSq .. ]
    , b <- take sudokuSizeSq [y * sudokuSizeSq ..] ]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a std::vector< tr1::shared_ptr<mapObject> > that I'm trying build from data contained in
Trying to build a mavenized project with NetBeans fails: Failed to execute goal org.jvnet.jaxb2.maven2:maven-jaxb2-plugin:0.7.5:generate
Trying to build my android project with Buildr (Apache), but can't find any info
Im trying to build a text classifier in JAVA with Weka. I have read
trying to build an ad hoc distribution with Xcode 4. Consider that my project.xcodeproj
In trying to build a ant script for my Flex project i've come across
Trying to build Android open source project on Ubuntu 10.04 (on VMware Player). I
I'm trying build a method which returns the shortest path from one node to
Trying to build a GUI application in Java/Swing. I'm mainly used to painting GUIs
Trying to build sslsniff on a RHEL 5.2 system here. When compiling sslsniff on

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.