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
| from math import * | |
| from collections import deque, defaultdict, Counter | |
| import itertools | |
| import re | |
| from typing import TypeVar, Generator, Iterable, Tuple, List | |
| import heapq | |
| hpush = heapq.heappush | |
| hpop = heapq.heappop |
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 sys | |
| sys.setrecursionlimit(1000000) | |
| ans = res = 0 | |
| with open("input.txt") as f: | |
| s = f.read().strip() | |
| ##s = """FF7FSF7F7F7F7F7F---7 | |
| ##L|LJ||||||||||||F--J | |
| ##FL-7LJLJ||||||LJL-77 | |
| ##F--JF--7||LJLJIF7FJ- | |
| ##L---JF-JLJIIIIFJLJJ7 |
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
| # pip install flask | |
| # pip install pycryptodome | |
| from flask import Flask | |
| from flask import request | |
| from Crypto.Cipher import AES | |
| import os | |
| import base64 | |
| import json | |
| import urllib |
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 python3 | |
| from Crypto.Cipher import AES | |
| from Crypto.Util.Padding import pad, unpad | |
| import os | |
| class PaddingOracle: | |
| def __init__(self, key=None, iv=None): | |
| if key is None: key = os.urandom(32) | |
| if iv is None: iv = os.urandom(16) | |
| self._key = key |
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 numpy as np | |
| def gen_stochastic(size): | |
| m = np.random.random(size) | |
| for i in range(size[0]): | |
| m[i,:] = m[i,:] / np.sum(m[i,:]) | |
| return m | |
| def row_sums(m): | |
| return np.array([ |
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 numpy as np | |
| import matplotlib.pyplot as plt | |
| x = np.linspace(-6, 6, 1000) | |
| def gauss(x,h): | |
| x = x / h | |
| return (1/h) * (1/np.sqrt(2 * np.pi)) * np.exp(-.5 * (x**2)) | |
| plt.plot(x, gauss(x, 1), label="h=1") |
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
| from Crypto.Cipher import AES | |
| from binascii import hexlify | |
| # Arbitrary key and random IV | |
| key = b'sixteen byte key' | |
| iv = b'\xfc\x86I\xd8a\x16\x10\xf9a_4\xb5\xd72\xd7\xeb' # random | |
| # Message is already 32 bytes | |
| msg = b"It's Crypto 2: Electric Boogaloo" |
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 | |
| import pyautogui | |
| import pyperclip | |
| import time | |
| print("Generating board...") | |
| SIZE = (25, 25) | |
| IDEAL_RATIO = 0.18 | |
| NUM_MINES = 115 #int(SIZE[0] * SIZE[1] * IDEAL_RATIO) |
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
| package bc19; | |
| // NOTE: THIS DOES NOT WORK! For some reason, the transpilation does something weird | |
| // to the logic (presumably not treating the values as 32-bit integers). This is NOT | |
| // suitable as a random function, please just use Math.random | |
| public class MyRobot extends BCAbstractRobot { | |
| int x_LCG; | |
| /** |
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
| from z3 import * | |
| questions = [[Bool('Q%dA' % i), Bool('Q%dB' % i)] for i in range(1,11)] | |
| # Returns expression that evaluates to True only when | |
| # the answers to questions q1 and q2 are the same | |
| def QEq(q1, q2): | |
| return And(questions[q1-1][0] == questions[q2-1][0], | |
| questions[q1-1][1] == questions[q2-1][1]) |
NewerOlder