CARVIEW |
Select Language
HTTP/2 200
date: Sat, 26 Jul 2025 08:59:50 GMT
content-type: text/html; charset=utf-8
cf-ray: 9652b4043ad8cb77-BLR
cf-cache-status: DYNAMIC
cache-control: private
set-cookie: prov=0976c1a2-75ac-4655-9801-0bc213d1e043; expires=Sun, 26 Jul 2026 08:59:50 GMT; domain=.stackexchange.com; path=/; secure; httponly
strict-transport-security: max-age=31536000; includeSubDomains
vary: Accept-Encoding
content-security-policy: upgrade-insecure-requests; frame-ancestors 'self' https://stackexchange.com
x-clacks-overhead: GNU Terry Pratchett
x-frame-options: SAMEORIGIN
x-request-guid: c1a02120-78f2-4b0c-96f7-26cd48a8acca
x-worker-origin-response-time: 454000000
x-dns-prefetch-control: off
set-cookie: prov=0976c1a2-75ac-4655-9801-0bc213d1e043; Path=/; HttpOnly; Domain=stackexchange.com
set-cookie: __cf_bm=TuNIwMbNxtDUVYumHSXc6VpbVh1p_t2desmu_zo7_Dc-1753520390-1.0.1.1-JdyEZTklTKfTKuUMshCkVodf6qy0KDPlfKQDwzw5kiU2JQE1TqfAtjbRfrvcILMD.4Frdb48IFtJaCtbL4JnyJd7WJhtzFOl9cp6j2oIe7g; path=/; expires=Sat, 26-Jul-25 09:29:50 GMT; domain=.stackexchange.com; HttpOnly; Secure; SameSite=None
set-cookie: _cfuvid=cFl0TnOD_ye69lP9lqn0g_zwB0mXM5fyN5Ooc3aDo.Y-1753520390269-0.0.1.1-604800000; path=/; domain=.stackexchange.com; HttpOnly; Secure; SameSite=None
server: cloudflare
content-encoding: gzip
Newest 'backtracking' Questions - Code Review Stack Exchange
Skip to main content
Stack Exchange Network
Stack Exchange network consists of 183 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
Visit Stack ExchangeTeams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about TeamsQuestions tagged [backtracking]
Backtracking is a general algorithm for finding solutions to some computational problem, that incrementally builds candidates to the solutions, and rejects continued processing of tracks that would lead to impossible solutions.
85 questions
- Bountied 0
- Unanswered
- Frequent
- Score
- Trending
- Week
- Month
- Unanswered (my tags)
6
votes
3
answers
687
views
N queen problem-like (+rooks and a different goal)
The problem is:
You have Q queens and R rooks on a board with sides of length (R+Q) ≤ 8, and you have to place all the pieces so that none attack any other piece. Each square on the board has a score ...
3
votes
1
answer
170
views
Pentomino solver in Python
When I was a child, I used to play Ubongo board game, recently I discovered Pentomino puzzle and I wanted to create a custom solver in python for it. Here is what I got:
...
1
vote
1
answer
104
views
Positioning boxes in a box with backtracking in Java
A large cube-shaped box has the dimensions 5x5x5. This box is to be completely filled with smaller boxes. Possible candidates are:
...
2
votes
0
answers
195
views
Backtracking graph algorithms for a word puzzle in Python
Motivation
Recently, Buzzfeed released a browser-based puzzle game called "Pyramid Scheme." It is available at the following link. The puzzle in an initial state looks like this:
To solve ...
1
vote
2
answers
372
views
Count the number of ways N queens can be placed on an N✕N chess board
The n-queens puzzle is the problem of placing n queens on an n✕n chessboard such that no two queens attack each other.
Given an integer n, this code returns the number of distinct solutions to the n-...
1
vote
1
answer
110
views
2 slow and barely working sudoku solving implementations
The code below is working however, if more zeros (empty cells) are added to the sudoku grid g, it takes longer to run, if it ever finishes.
...
2
votes
0
answers
136
views
Followup: Use backtracking to put as many ships on a battleship-board as possible
I created a simple battleship game and wanted to be able to place as many ships on my board as possible.
The logic to place the ships uses some kind of backtracking to find a correct placement.
...
3
votes
1
answer
134
views
Exceeded time limit on Trie search with Backtracking using Swift
I have been trying to solve Trie related problems over at leet code and came across this interesting problem 211. Design Add and Search Words Data Structure
Here is the question for convenience:
211. ...
5
votes
2
answers
611
views
Leet Code 139 (Word Break) using a trie with recursion
I was attempting to solve LeetCode 139 - Word Break
Given a string s and a dictionary of strings wordDict, return
...
9
votes
2
answers
2k
views
Sudoku Solver in C without recursion
I am trying to learn backtracing , so i wrote program for Sudoku
It solves sudoku in approx. 1 ms in online c compiler
but this one sudoku puzzle is taking approx. 35 sec in that online c compiler ...
1
vote
1
answer
151
views
Speed up performance of backtracking solution for Sudoku solver
I can't improve the performance of the following Sudoku Solver backtracking solution. I know there are 3 loops here and they probably cause slow performance but I can't find a better/more efficient ...
3
votes
1
answer
609
views
Optimize "Fill magic square" in python with backtracking
I have written a python program with backtracking that fills a n * n magic square. It solves for n = 4 in 4.5 seconds but gets stuck when I run it for n = 5 on my ...
3
votes
1
answer
122
views
Recursive backtracking Sudoku algorithm
I've tried optimising my program by removing invalid values for possible spaces instead of searching from 1-9, and by choosing values with the lowest number of empty spaces in its row and column, but ...
6
votes
1
answer
191
views
Rust based Sudoku solver using backtracking
I've just started learning rust and have written a basic sudoku solver, however it seems to run much slower than I expected. So I'm looking for any possible performance improvements as well as any ...
6
votes
2
answers
508
views
Python backtracking algorithm to solve sudoku
I have recently gotten back into writing python and i decided to take up a project of writing a backtracking algorithm in python to solve Sudoku puzzles
How it Works
A matrix is declared to represent ...
- The Overflow Blog
-
-
- Featured on Meta
-
-
Related Tags
algorithm × 31
java × 24
sudoku × 22
python × 20
recursion × 17
performance × 17
c++ × 15
n-queens × 10
c × 8
beginner × 7
python-3.x × 6
chess × 5
combinatorics × 4
haskell × 4
matrix × 3
game × 3
complexity × 3
c# × 3
battleship × 2
f# × 2
graph × 2
iteration × 2
more related tags
Hot Network Questions
- Break long equation: vertical alignment of indentation
- How can I allow a contact to update their organisation using FormBuilder?
- Why is this delayed differential system giving errors in plotting the solution?
- Source that Eliyahu Hanavi was an angel at the creation
- Tracking stored procedure performance metrics
- How much of a really big a spaceship could a nuke take out?
- How many simple groups are there of a given infinite cardinality?
- Where did the name of Windows XP come from? Was it connected to the Cairo project?
- Did the first sin in the garden of Eden actually take place before the fruit was eaten?
- Word order for a phrase with a number, adjective and noun
- Humans on alien planet get tailed by silent humanoids
- Where should a drain saddle for an RO system be installed?
- What Isp can be gotten from a napthalene (mothball) hot gas thruster? Did it work in space?
- When was the last time all humans were on the ground not in the air?
- Why does “brew search” for “peertube” match with “freetube”? How does the search work?
- Is the surface of Mars or the Moon mostly (or relatively) homogeneous, unlike the Earth?
- Mars colony book I read in the 80's. The name?
- Symbols for A.P. Morse's book in Set Theory
- Why does the node Bounding Box suddenly produce a different result in version 4.5?
- Is a chemistry-first technological paradigm as plausible as one focused on physics or biology?
- Can you yaw an airplane by only using differential thrust?
- Likelihood of the data in a OU-like process
- Can a minor run a business by having an adult act on their behalf?
- Why is 0.0 printed as 0.00001 when rounding upward?