Skip to content

Instantly share code, notes, and snippets.

@yuizumi
yuizumi / Main.java
Created December 31, 2014 06:30
20141231 and 20150101 are consecutive primes?
// A program to see if 20141231 and 20150101 are consecutive prime numbers.
// Answer: Nope, neither is a prime, and there are lots of primes in between!
class Main
{
private static int minFactor(int n)
{
assert (n >= 3) && (n % 2 != 0);
for (int j = 3; j * j <= n; j += 2) {
@yuizumi
yuizumi / easy_scanner.py
Created December 9, 2013 14:57
A poor-man's Scanner in Python, provided as a function that takes a file object and returns an iterator whose next() works like Java's Scanner.next().
def EasyScanner(reader):
return (word for line in reader for word in line.split())
# License: CC0 1.0 Universal
# http://creativecommons.org/publicdomain/zero/1.0/