This file contains hidden or 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 | |
# TO USE: | |
# 1. MAKE A CONFIG FILE AT ~/.go-to-bed | |
# it should look like this (don't include hashes in file, this will nag you starting at 12:16 AM until 6:00 AM) | |
# START_TIME:0.16 | |
# END_TIME:6.0 | |
# HUSHED_UNTIL:2023-11-23T1:40:00 | |
# | |
# 2. SAVE THIS SCRIPT SOMEWHERE, maybe ~/bin/go-to-bed |
This file contains hidden or 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)) |