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
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 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
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 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 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 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
[{ | |
"inputs": [], | |
"payable": false, | |
"stateMutability": "nonpayable", | |
"type": "constructor" | |
}, { | |
"anonymous": false, | |
"inputs": [{ | |
"indexed": false, | |
"internalType": "string", |
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_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 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 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 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
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): |
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
grid_size = 1001 | |
num = grid_size ** 2 | |
sum_diagonals = num | |
for i in range(grid_size - 1, 0, -2): | |
for _ in range(4): | |
num -= i | |
sum_diagonals += num | |
print(sum_diagonals) |
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 sqrt | |
MAX = 999999 | |
sieve = [True] * (MAX + 1) | |
sieve[0], sieve[1] = False, False | |
for i in range(2, int(sqrt(MAX)) + 1): | |
if sieve[i] is True: | |
for j in range(2 * i, MAX, i): |
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
largest_num = 1000 | |
largest_divisor = 3 | |
longest_cycle = 1 | |
rdigits = '' | |
def get_divide_result(i): | |
seen_remainders = [False] * i | |
remainder = 10 % i | |
cycle_count = 0 | |
while remainder!= 0 and seen_remainders[remainder] is False: |