Instantly share code, notes, and snippets.

# Felix Pahljoriki

• Sort options
Last active Oct 12, 2019
Extract results of FIDE Grand Swiss Tournament 2019 in Wikipedia table format
View GrandSwissResultExtracter.java
 package games.chess.fide; import java.io.IOException; import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Set; import org.jsoup.Jsoup; import org.jsoup.nodes.Document;
Created Jun 17, 2019
Allocate seats according to Sainte-Laguë
View SainteLaguë.java
 package jetzt.bewegung; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.stream.Collectors; public class SainteLaguë { // Sitzzuteilung an die Landeslisten der CDU zur Europawahl 2019
Created Sep 20, 2018
Count the number of chains that can be made from the river tiles in Carcassonne; see https://math.stackexchange.com/questions/2923530.
View Question2923530.java
 public class Question2923530 { static boolean [] [] used = new boolean [23] [23]; public static void main (String [] args) { long count = 0; used [11] [11] = true; for (int bits = 0;bits < 1 << 10;bits++) { int bitCount = 0; for (int i = 0;i < 10;i++) if ((bits & (1 << i)) != 0)
Created Sep 6, 2018
Confirm that the probability for a random line in a square to be the diagonal of a square contained in the square is 2/3; see https://math.stackexchange.com/questions/2906823.
View Question2906823.java
 public class Question2906823 { final static int ntrials = 100000000; public static void main (String [] args) { int count = 0; for (int n = 0;n < ntrials;n++) { double x1 = Math.random (); double y1 = Math.random (); double x2 = Math.random (); double y2 = Math.random ();
Created Sep 5, 2018
Compute the probability for a two-dimensional random walk with duplication and vanishing to produce at least one duplicate at the origin; see https://math.stackexchange.com/questions/2906613.
View Question2906613.java
 public class Question2906613 { final static int maxn = 1026; final static int [] [] ds = { {0,1}, {-1,0}, {0,-1}, {1,0} }; public static void main (String [] args) { double [] [] a = new double [maxn + 1] [maxn + 1];
Created Aug 29, 2018
Estimate the probability for a number with independently uniformly randomly chosen decimal digits to appear periodic at some point; see https://math.stackexchange.com/questions/2898079.
View Question2898079.java
 public class Question2898079 { public static void main (String [] args) { long count = 0; long power = 1; for (int n = 1;;n++) { power *= 10; outer: for (long k = 0;k < power;k++) { String s = String.valueOf (k); while (s.length () < n)
Created Aug 8, 2018
Estimate the expected number of draws without replacement required to draw three balls of the same colour from 64 balls with 8 balls each of 8 colours; see https://math.stackexchange.com/questions/2875705.
View Question2875705.java
 import java.util.Arrays; import java.util.Random; public class Question2875705 { final static Random random = new Random (); final static int ntrials = 100000000; public static void main (String [] args) { long total = 0; int [] counts = new int [8];
Last active Jul 22, 2018
Count the number of ways that binary entropy can be at least 7 in a file of 256 characters chosen from 256 symbols; see https://math.stackexchange.com/questions/2858152.
View Question2858152.java
 import java.math.BigInteger; public class Question2858152 { final static int ncharacters = 256; final static int nsymbols = 256; final static int max = Math.max (nsymbols,ncharacters) + 1; final static BigInteger [] integers = new BigInteger [max]; final static BigInteger [] powers = new BigInteger [max];
Last active Jul 4, 2018
Calculate and check the probability for at least one of m buckets to contain at least k of n uniformly randomly placed balls; see https://math.stackexchange.com/questions/2839811.
View Question2839811.java
 import java.math.BigInteger; public class Question2839811 { final static int n = 180; final static int m = 10; final static int k = 24; // XOR shift pseudorandom number generator because Java's built-in generator has regularities that mess up the result static long x = 4; static long cache;
Created Jul 2, 2018
Calculate the probability for the lamp at the origin to be lit after n steps of a random walk on the lamplighter group; see https://math.stackexchange.com/questions/2837955.
View Question2837955.java
 import java.math.BigInteger; import java.util.HashMap; import java.util.Map; public class Question2837955 { static class State { boolean lamp; int x; public State () {}
You can’t perform that action at this time.