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
import random | |
import re | |
import timeit | |
import matplotlib.pyplot as plt | |
from collections import Counter | |
def sum_digits_math(n): | |
"""from https://stackoverflow.com/a/14940026/674039""" | |
r = 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
def duel(a, b): | |
fa = 16807 | |
fb = 48271 | |
d = 0x7fffffff | |
count1 = 0 | |
a4 = 5000000*[0] | |
b8 = 5000000*[0] | |
na = nb = 0 | |
for i in range(40000000): | |
a = (a * fa) % d |
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 duel(a, b): | |
fa = 16807 | |
fb = 48271 | |
d = 0x7fffffff | |
count1 = 0 | |
a4 = [] | |
b8 = [] | |
for i in range(40000000): | |
a = (a * fa) % d | |
b = (b * fb) % d |
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
# timing of pkgutil and importlib.resources loaders from https://github.com/wimglenn/resources-example | |
# Python 3.8.5 on linux | |
>>> from myapp.example2 import func as pkgutil_loader | |
>>> from myapp.example4 import func as importlib_resources_loader | |
>>> timeit importlib_resources_loader() | |
392 µs ± 329 ns per loop (mean ± std. dev. of 7 runs, 1000 loops each) | |
>>> timeit pkgutil_loader() | |
200 µs ± 230 ns per loop (mean ± std. dev. of 7 runs, 1000 loops each) | |
>>> timeit importlib_resources_loader() |
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
AoC 2019 day 9 quine: 109,1,204,-1,1001,100,1,100,1008,100,16,101,1006,101,0,99 | |
0 op_offset ip=0 opcode=00109 offset=0 args=[1] {0: 109, 1: 1, 2: 204, 3: -1, 4: 1001, 5: 100, 6: 1, 7: 100, 8: 1008, 9: 100, 10: 16, 11: 101, 12: 1006, 13: 101, 14: 0, 15: 99} | |
1 op_output ip=2 opcode=00204 offset=1 args=[0] {0: 109, 1: 1, 2: 204, 3: -1, 4: 1001, 5: 100, 6: 1, 7: 100, 8: 1008, 9: 100, 10: 16, 11: 101, 12: 1006, 13: 101, 14: 0, 15: 99} | |
2 op_add ip=4 opcode=01001 offset=1 args=[100, 6, 100] {0: 109, 1: 1, 2: 204, 3: -1, 4: 1001, 5: 100, 6: 1, 7: 100, 8: 1008, 9: 100, 10: 16, 11: 101, 12: 1006, 13: 101, 14: 0, 15: 99} | |
3 op_eq ip=8 opcode=01008 offset=1 args=[100, 10, 101] {0: 109, 1: 1, 2: 204, 3: -1, 4: 1001, 5: 100, 6: 1, 7: 100, 8: 1008, 9: 100, 10: 16, 11: 101, 12: 1006, 13: 101, 14: 0, 15: 99, 100: 1} | |
4 op_jump_f ip=12 opcode=01006 offset=1 args=[101, 14] {0: 109, 1: 1, 2: 204, 3: -1, 4: 1001, 5: 100, 6: |
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
import logging | |
from collections import defaultdict | |
from collections import deque | |
# logging.basicConfig(level=logging.INFO, format=" %(message)s") | |
log = logging.getLogger(__name__) | |
# "parameter modes" | |
POSITION = 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
>>> import numpy as np | |
>>> import builtins | |
>>> np.random.randn(3,3) | |
array([[-0.24401213, -0.19773938, 0.47278806], | |
[-0.6083566 , -0.65160561, 0.78145811], | |
[ 0.14546934, -0.86849935, 2.07570471]]) | |
>>> np.empty((3,3)) # sign loss | |
array([[0.24401213, 0.19773938, 0.47278806], | |
[0.6083566 , 0.65160561, 0.78145811], | |
[0.14546934, 0.86849935, 2.07570471]]) |
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
{ | |
"c#": 595, | |
"java": 531, | |
"javascript": 447, | |
"python": 422, | |
"c++": 404, | |
"php": 272, | |
"android": 268, | |
"jquery": 247, | |
"c": 175, |
NewerOlder