Created
December 10, 2012 05:35
-
-
Save hc5/4248610 to your computer and use it in GitHub Desktop.
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
public class Test { | |
private static final int dim = 100; | |
static int[][] graph = new int[dim][dim]; | |
static boolean[] color = new boolean[dim]; | |
private static int trials = 1000; | |
public static void main(String[] args) { | |
double triCount = 0; | |
int totalCount = 0; | |
for (int t = 0; t < trials; t++) { | |
for (int i = 0; i < dim; i++) { | |
for (int j = 0; j < dim; j++) { | |
graph[i][j] = j; | |
color[i] = (int) (Math.random() * 1000) % 2 == 1; | |
} | |
} | |
for (int i = 0; i < dim; i++) { | |
for (int j = i + 1; j < dim; j++) { | |
for (int k = j + 1; k < dim; k++) { | |
if (t == 0) { | |
totalCount++; | |
} | |
if (tri(i, j, k)) { | |
triCount += 1; | |
} | |
} | |
} | |
} | |
} | |
triCount /= trials; | |
System.out.println(totalCount); | |
System.out.println(triCount); | |
} | |
static boolean tri(int a, int b, int c) { | |
return color[a] == color[b] && color[b] == color[c]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment