filwaitman / playground

Area for some scripts, challenges, solutions and more.
0 stars 0 forks source link

What do you think about the "99 lisp problems" ? #1

Open alexandre opened 8 years ago

alexandre commented 8 years ago

I like the 99 LISP Problems[0] and I'm trying to solve them with Racket[1].

I know you like chess, so what about a solution for this one (the 90th) using Python ?:

P90 (**) Eight queens problem This is a classical problem in computer science. The objective is to place eight queens on a chessboard so that no two queens are attacking each other; i.e., no two queens are in the same row, the same column, or on the same diagonal.

Hint: Represent the positions of the queens as a list of numbers 1..N. Example: (4 2 7 3 6 8 5 1) means that the queen in the first column is in row 4, the queen in the second column is in row 2, etc. Use the generate-and-test paradigm.

I hope you like. =]

0 - http://www.ic.unicamp.br/~meidanis/courses/problemas-lisp/L-99_Ninety-Nine_Lisp_Problems.html 1 - https://racket-lang.org/ (let me know if you want to talk about Racket/FP)

[ ]'s

filwaitman commented 5 years ago

Oh man. I kind of abandoned this repo for the last years. Shame on me. =(

Now answering with a slight delay of 3 years:

I didn't know this "99 lisp problems" page. I'm definitely going to have some fun with it for the next days. hahahaha Thanks for that!

As for the particular 8 queens problem: I already spent some time thinking about it and honestly I didn't find a decent (meaning: not greedy) solution. For me it seems much more like a math challenge (P=NP complete?) than a computing challenge.

Despite the delay, it was nice to hear from you! =D