This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash -x | |
# config file looks like | |
#START_TIME:0.16 | |
#END_TIME:6.0 | |
#HUSHED_UNTIL:2023-11-23T1:40:00 | |
if [ "$1" = "-from-cron" ] | |
then | |
if ps aux | grep osascript | grep -q 'Time to Sleep' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_candidate_boards(board): | |
boards = [] | |
queen_locations = [(x, y) for x in range(len(board)) for y in range(len(board)) if board[x][y] == "Q"] | |
left_diagonals = [(x-y, 0) for (x, y) in queen_locations] | |
right_diagonals = [(x+y, 0) for (x, y) in queen_locations] | |
for x, y in ((x, y) for x in range(len(board)) for y in range(len(board)) if board[x][y] != "Q"): | |
temp_board = board[:x] + [board[x][:y] + ["Q"] + board[x][y+1:]] + board[x+1:] | |
valid_cols = all(col.count("Q") < 2 for col in temp_board) | |
valid_rows = all(row.count("Q") < 2 for row in zip(*temp_board)) |