+ 3

N queens problem

I was requested to solve this task few days ago. And that confuse me a lot. It requires you to solve n queens problem and 4≤n≤1000. It is known we cannot use brute force, since the task requires at max 4 secs running time. I can't figure out how else I can do it. Can anyone give me some hints?

31st Dec 2018, 10:43 PM
William Tseng
William Tseng - avatar
7 Answers
1st Jan 2019, 3:45 AM
Kishalaya Saha
Kishalaya Saha - avatar
+ 3
You are going to need a programming language with good runtime so go with C++
2nd Jan 2019, 7:54 PM
Shuaib Nuruddin
Shuaib Nuruddin - avatar
+ 2
Kishalaya Saha much thanks ❤️
1st Jan 2019, 5:11 AM
William Tseng
William Tseng - avatar
+ 1
Anna So your code is generating different queens on random position until whole plate is filled. Am I correct? If so, I don't think 4s is enough for the calculation.
1st Jan 2019, 3:34 AM
William Tseng
William Tseng - avatar
+ 1
Anna Is there any way to efficiently calculate? Something worth mentioning, I've found ALMOST every situation can be satisfied by starting from {1,2} ( {x - 1 to n ,y - 1 to n} ) Then jump 1 for x-coordinates, 2 for y. When the y index exceeds n, go the process again. But 32, 128 won't do. I've tried
1st Jan 2019, 3:41 AM
William Tseng
William Tseng - avatar
+ 1
You're welcome, William Tseng 😊
1st Jan 2019, 5:27 AM
Kishalaya Saha
Kishalaya Saha - avatar