walliuswilliam / machine-learning

0 stars 0 forks source link

8_queens.py simplifications #5

Closed charlieweinberger closed 3 years ago

charlieweinberger commented 3 years ago

I noticed two things that I think you can improve in your 8queens.py code. The first is on line 4. You have board = '........\n........\n........\n........\n........\n........\n........\n........'. This is a little long. It can be shortened with a for loop. Instead, we could have `board = '' for in range(8): board += '........\n'`. This may or may not be more simple to you, but I like this better.

This second thing I noticed is at the bottom of your code. Twice, on lines 61 and 66, you have print(''). I think this is to have a new line between print('passed') and print('testing random_optimizer on n_vals...'). Instead of having print(''), you can just put \n in front of 'testing random_optimizer on n_vals...'. It should look like this: print('\ntesting random_optimizer on n_vals...'). This will make a new line before the 'testing random_optimizer on n_vals...' is printed.

walliuswilliam commented 3 years ago

thanks, i fixed the problems