Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Main {
- public static void main(String[] args) {
- int count= 0;
- Perm perm = new Perm(3);
- int[] d;
- while ((d = perm.getNext()) != null) {
- int[]c = d.clone();
- for(int o=0;o<c.length;o++)
- c[o] +=1;
- permLoop:
- for (int i = 0; i < c.length - 2; i++) {
- if (i <= c.length / 2) {
- double lr = (((double)c[i] + (double)c[c.length-1 - i]) / 2);
- if (!containsBet(i, c.length-1 - i, c, lr))
- break permLoop;
- }
- double l = ((double)c[0] + (double)c[c.length-1 - i]) / 2;
- if (!containsBet(0, c.length-1 - i, c, l))
- break permLoop;
- double r = ((double)c[i] + (double)c[c.length-1]) / 2;
- if (!containsBet(i, c.length-1, c, r))
- break permLoop;
- System.out.println(Arrays.toString(c));
- count++;
- }
- }
- System.out.println(count);
- }
- public static boolean containsBet(int st,int end,int[] c, double val)
- {
- for(int j=st+1;j<= end-1;j++)
- {
- if(c[j]==val)
- return false;
- }
- return true;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement