Skip to content

Instantly share code, notes, and snippets.

# Infinite primes generator and quantum article check:
# https://www.quantamagazine.org/mathematicians-discover-prime-conspiracy-20160313/
from tests import miller_rabin
def primes_generator():
i = 2
while True:
if miller_rabin(i):
yield i
public static void cond_changer(long time_pause){
long start = System.currentTimeMillis();
System.out.println("start in cond_change");
while (System.currentTimeMillis() - start < time_pause * 1000) {
}
Main.condition = () -> true;
}
public static Callable<Boolean> cond_change() {
@lion137
lion137 / afs.py
Last active August 18, 2017 00:06
Blog
def afs(g, s):
bag = data_structure()
bag.add(s)
while bag is not empty:
tile = bag.pop()
if tile is not marked:
mark(tile)
for x in adj_list(tile):
bag.add(x)
@lion137
lion137 / ret_test.java
Last active June 5, 2017 08:55
return statement problem java
public BigInteger evaluateParseTreeBigInt(BinaryTree tree){
BinaryTree<T> leftT = tree.left;
BinaryTree<T> righT = tree.right;
boolean p = (leftT != null) && (righT != null);
if (p){
//cos tam, return jakis bigint
}
else return //jakis biginteger
}//IntelliJ IDEA sie pluje, ze brakuje return statemnt, sugeruje po else, ale to rozwala cala logike
@lion137
lion137 / bit_hacks.go
Last active February 11, 2017 23:20
Golang tests
//Golang optimizatoin tricks
// copyleft by lion137
// https://lion137.blogspot.co.uk/2017/02/bit-hacks-in-go.html
func average(x uint32, y uint32) uint32 {
return (x & y) + ((x ^ y) >> 1)
}
func iexp(x uint32, n uint32) uint32 {
if (n == 0) {
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.