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
# Been a while since I made one of these. | |
# The last time I made one, I was in college. | |
def print_triangle(n: int): | |
for i in range(1, n + 1): | |
digits = len(str(n)) | |
print((" " * (digits + 1)) * (n - i) , end="") | |
for j in range(i): | |
print(" %s" % str(j + 1).rjust(digits, "0"), end="") | |
for j in range(i - 1): |
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
from eth_account import Account | |
from eth_tester.backends.pyevm.main import get_default_account_keys | |
acc = Account.from_key(get_default_account_keys()[0]) | |
print(acc.key) |
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
pragma solidity ^0.5.16; | |
contract DummyERC20 is ERC20 { | |
function withdraw() external { | |
uint256 amount = balances[msg.sender]; | |
// demo reentracy | |
require(msg.sender.call.value(amount)()); | |
balances[msg.sender] = 0; | |
} |
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
pps = [ | |
'1-5 k: kkkkhkkkkkkkkkk', | |
'5-7 k: blkqhtxfgktdkxzkksk', | |
'15-16 x: xxxxxxxxxxxxxxlf', | |
'3-5 j: fjpvj', | |
'17-20 x: zsxjrxkgxxxxxxxmxgxf', | |
'5-6 m: swjzmmmlx', | |
'2-4 v: vqdn', | |
'8-12 t: thllsbqtgdsf', | |
'10-17 h: vpbrjcbhnwqhhphxjk', |
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
from eth.vm.forks import ( | |
IstanbulVM, | |
) | |
from eth.vm import ( | |
opcode_values | |
) | |
from tests.core.opcodes.test_opcodes import ( | |
assemble, | |
CANONICAL_ADDRESS_B, |
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
[{ | |
"inputs": [], | |
"payable": false, | |
"stateMutability": "nonpayable", | |
"type": "constructor" | |
}, { | |
"anonymous": false, | |
"inputs": [{ | |
"indexed": false, | |
"internalType": "string", |
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_all_substrings(arr, index, subarr, record): | |
if index == len(arr): | |
if len(subarr) != 0: | |
record.append(''.join(subarr)) | |
else: | |
get_all_substrings(arr, index + 1, subarr, record) | |
get_all_substrings(arr, index + 1, subarr + [arr[index]], record) | |
return record |
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
class Solution(object): | |
def __init__(self, matrix, row, col): | |
self.matrix = matrix | |
self.row = row | |
self.col = col | |
def is_safe(self, i, j, visited): | |
return ( | |
0 <= i < self.row and |
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
final_target = 200 | |
possibilities = [0] * (final_target + 1) | |
possibilities[0] = 1 | |
# keeping the coins sorted is the key here | |
# we want to compute possibilities for lower coins first. | |
# This helps us to fix one particular coin and | |
# then find the other possibilites of the change needed | |
coins = [1, 2, 5, 10, 20, 50, 100, 200] | |
for coin in coins: | |
for current_target in range(coin, final_target + 1): |