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
# N*[MATH]=[HTAM] | |
# MATH -> ABCD | |
# N(1000A+100B+10C+D)=1000D+100C+10B+A | |
# (1000N-1)A+10(10N-1)B=10(10-N)C+(1000-N)D | |
count = [0] * 9 | |
for N in range(1, 10): | |
for A in range(10): | |
for B in range(10): | |
for C in range(10): | |
for D in range(10): |
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
# Inefficient resistor solver | |
# it's also incomplete | |
# Licensed under GPL 3 | |
# settings | |
target = 9960 | |
tolerance = target * 0.005 | |
depth = 3 | |
available_resistors = [ |
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
#include <stdio.h> | |
#define MAXSEARCHLEN 9 | |
#define FAST 0 | |
const char next_state[] = { | |
2, 2, 2, 5, 6, 2, 2, 0, | |
1, 3, 4, 3, 3, 4, 4, 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
# States | |
Q = frozenset('abcdef') | |
# Alphabet (input symbols) | |
Sigma = frozenset([0, 1]) | |
# Transition Function (Q x Sigma -> Q) | |
delta = { | |
('a', 0): 'b', | |
('a', 1): 'c', | |
('b', 0): 'a', | |
('b', 1): 'd', |
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
<?php | |
// fix CloudFlare/Varnish IPs | |
function transform_cf(&$ip){ | |
if(!isset($_SERVER['HTTP_CF_CONNECTING_IP'])) | |
return; | |
$cf_cidrs = array( | |
"103.21.244.0/22", | |
"103.22.200.0/22", | |
"103.31.4.0/22", |
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 urllib.request | |
FILES_TO_DOWNLOAD = """ | |
google.com | |
example.com | |
""" | |
for line in FILES_TO_DOWNLOAD.splitlines(): | |
if not line: | |
continue |
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 python | |
# Random PNG generator | |
__copyright__ = "Copyright (C) 2016 Victor Zheng" | |
__licence__ = "GNU GPL v3" | |
# This program is free software: you can redistribute it and/or modify | |
# it under the terms of the GNU General Public License as published by | |
# the Free Software Foundation, either version 3 of the License, or | |
# (at your option) any later version. |
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 python | |
# Maximum PNG generator | |
__copyright__ = "Copyright (C) 2016 Victor Zheng" | |
__licence__ = "GNU GPL v3" | |
# This program is free software: you can redistribute it and/or modify | |
# it under the terms of the GNU General Public License as published by | |
# the Free Software Foundation, either version 3 of the License, or | |
# (at your option) any later version. |
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 python | |
# Duplicate File Detection | |
__copyright__ = "Copyright (C) 2016 Victor Zheng" | |
__licence__ = "GNU GPL v3" | |
# Based on https://github.com/IanLee1521/utilities/blob/master/utilities/find_duplicates.py | |
# This program is free software: you can redistribute it and/or modify | |
# it under the terms of the GNU General Public License as published by | |
# the Free Software Foundation, either version 3 of the License, or |