CARVIEW |
Select Language
HTTP/2 200
date: Sun, 27 Jul 2025 05:57:51 GMT
content-type: text/html; charset=utf-8
cf-ray: 9659e6d21f7cc16d-BLR
cf-cache-status: DYNAMIC
cache-control: private
set-cookie: prov=bc0da675-a6fb-4ad2-9797-95a6c9ad1999; expires=Mon, 27 Jul 2026 05:57:51 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: dbf70ce8-52c0-49f7-aa95-b8f02e337fc9
x-worker-origin-response-time: 424000000
x-dns-prefetch-control: off
set-cookie: prov=bc0da675-a6fb-4ad2-9797-95a6c9ad1999; Path=/; HttpOnly; Domain=stackexchange.com
set-cookie: __cf_bm=xait7kgIjb9oFLK9S0hkZEfMKycEgWfq7jHVpnEBQho-1753595871-1.0.1.1-z.ho11bUpSfKBybL1AZt7.mm4.TKbjLxmUGQoIyQM6maeV6MpG6WA7p._X35QPHHNYxIKMqLn4e9ayj8_zduPdJmERNKwOFjfdRrBVjf18g; path=/; expires=Sun, 27-Jul-25 06:27:51 GMT; domain=.stackexchange.com; HttpOnly; Secure; SameSite=None
set-cookie: _cfuvid=ptEA10jsTJ50KOJ9X6IYybn33Et7u5cRRQy6iG_J1LY-1753595871498-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
612
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
- How should one pronounce plural French-derived German words?
- Confusing/incorrect sentence in proof of Zorn's Lemma in Lang's "Real and Functional Analysis"
- What does it mean to "cancel" a command in the linux kernel and how can one do so?
- Why does the node Bounding Box suddenly produce a different result in version 4.5?
- how is it possible for a player to have crossed 2400 and secure 3+ IM norms to stay FM
- Upload open access pdfs or link to publisher for visibility?
- Lay explaination of 'lower evolutionary constraint genes'?
- How do I set up a recursive algorithm to repeatedly square root a positive real number?
- spots / stains on tubeless tire
- Not being introduced to the team – should I ask for it?
- Most practical way to determine concentration of reducing sugar in frozen French fries?
- Anonymizing a submission for double-blind review
- Did the first sin in the garden of Eden actually take place before the fruit was eaten?
- Not your ordinary affix riddle
- What is the best way to bevel these corners without these deformations showing?
- How many simple groups are there of a given infinite cardinality?
- What does this word "ahn-shdah-heh" mean?
- How can I translate tariff rates to changes in trade flow?
- Tracking stored procedure performance metrics
- Existence of Jordan curves between a compact and an open set
- Story that taught cryptography in the form of a manga
- About security concerns using in find -exec vs interactively performing the same task
- Why am I winning always? A coincidence perhaps?
- Class for validating code in different Conda environments with PyTorch