import java.util.Random; import java.util.Scanner; public class Calc { public static int[][] connection=new int[1024][10]; private static int[] shuffle= new int[51]; /** * Decimal to String conversion.Used to convert 10 edges to 10-bit * binary number varying from 0 to 1023. */ public static String decToString(int number,int length){ String ans=null; try{ int a= number; String tem="0000000000"; String b=Integer.toBinaryString(a); ans=b; int len=b.length(); if (len < length) ans = tem.substring(0, length-len).concat(ans); else ans = ans.substring(len - 10); }catch(Exception e){ System.out.println("plz enter integer value"); } return ans; } /** * 10 links can have 2^10 states. We convert it to 10 bit binary and store it in an * array of lenth 10. So we need a 2D array. */ public static int[][] connect(int[][] connection){ for(int i=0;i<1024;i++){ String temp=decToString(i,10); for(int j=0;j<10;j++){ String we=temp.charAt(j)+""; int a=Integer.parseInt(we); connection[i][j]=a; } } return connection; } /** * Method used to print a 2D array. Used the func. * to check intermiate values. * @param arr */ public static void prinfTwoDarr(int[][] arr){ int jlen=arr[0].length; int iLen=arr.length; for(int i = 0; i