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
| import time | |
| import datetime | |
| def timing_protect(constant_time): | |
| """ | |
| The jitter will depend not on runtime but activity on the system writ large |
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
| import random | |
| def d20(): | |
| return random.randint(1,20) | |
| d = {} | |
| for i in range(1000000): | |
| r = max(d20(),d20()) | |
| d[r] = d.get(r,0) + 1 | |
| for i,n in d.items(): | |
| print(str(i)+","+str(n)) |
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
| class SLL_Node: | |
| def __init__(self, data, next): | |
| self.data = data | |
| self.next = next | |
| # IMPLEMENT THIS | |
| def average_of_list(head): | |
| if type(head) == float: | |
| return head |
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
| class Clock: | |
| def __init__(self,hours = 0,minutes = 0,seconds = 0): | |
| self.hours = hours | |
| self.minutes = minutes | |
| self.seconds = seconds | |
| def add_clocks(self,var1,var2,var3): | |
| self.seconds = self.seconds + var3 | |
| if self.seconds > 59: | |
| self.seconds -= 60 |
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
| RANK = 0 | |
| NAME = 1 | |
| COUNTRY = 2 | |
| POINTS = 3 | |
| BIRTH_YEAR = 4 | |
| def get_input(user_prompt):## | |
| user_input = input(user_prompt) |
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 check_win(game_state, token): | |
| all_rows = [[line[x] for line in game_state] for x in range(len(game_state))] + [game_state[len(game_state)-x-1][x] for x in range(len(game_state))] + [game_state[x][x] for x in range(len(game_state))] | |
| for line in all_rows: | |
| if sum([1 for t in line if t == token]) == len(game_state): | |
| return token | |
| return " " |
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
| list_of_list = [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16]] | |
| def make_diagonal(list_of_lists): | |
| diag = [] | |
| diag.append([list_of_lists[len(list_of_lists)-x-1][x] for x in range(len(list_of_lists))]) | |
| diag.append([list_of_lists[x][x] for x in range(len(list_of_lists))]) | |
| print(diag) |
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 make_col(a_list_of_lists): | |
| col_list = [] | |
| n = len(a_list_of_lists) | |
| for n in range(len(a_list_of_lists)): | |
| col = [l[n] for l in a_list_of_lists] | |
| col_list.append(col) | |
| print(col_list) | |
| return col_list |
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 user_input_dimentions(): | |
| not_correct_input = True | |
| while not_correct_input == True: | |
| try: | |
| boardDimentions = int(input("enter width of board: ")) | |
| not_correct_input = False | |
| except ValueError: | |
| print("please stop being an idiot") | |
| return boardDimentions |
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 transpose(matrix): | |
| result_matrix = [] | |
| for i in range(len(matrix[0])): | |
| result_matrix.append([m[i] for m in matrix]) | |
| return result_matrix |
NewerOlder