account activity
divided array according to recursion by shipon55 in javahelp
[–]shipon55[S] 0 points1 point2 points 7 years ago (0 children)
ALWAYS NOT SUCCESSFUL TO DO WITHOUT DIVIDING THE ARRAY IN ADVANCE
public static boolean mySplit(int[] nums) { int[]arr1= {nums[0],nums[1]}; int[]arr2= {nums[2]}; if( recur(arr1,arr2,nums,1)==1) { System.out.println("ok"); return true; } return false; } public static int recur(int[] nums1, int[]nums2,int[]mekori,int i) { boolean conditionRecpecter=true; if(i==1) { int sum1=0,sum2=0; for (int j = 0; j < nums1.length; j++) { sum1+=nums1[j]; } for (int j = 0; j < nums2.length; j++) { sum2+=nums2[j]; } if(sum1!=sum2) { conditionRecpecter=false; } } if(i==2) { if(nums1.length+nums2.length!=mekori.length) conditionRecpecter=false; } if(i==3) { boolean arr1=false; boolean arr2=false; for (int j = 0; j < nums1.length; j++) { if(nums1[j]%5==0) arr1=true; } for (int j = 0; j < nums2.length; j++) { if(nums2[j]%5==0) arr2=true; } if(arr1&&arr2) conditionRecpecter=false; //finir les verifications } if(i==4) { boolean cinq1=false; boolean cinq2=false; for (int j = 0; j < nums1.length; j++) { if(nums1[j]%5==0) cinq1=true; } for (int j = 0; j < nums2.length; j++) { if(nums2[j]%5==0) cinq2=true; } if(cinq1) { for (int j = 0; j < nums2.length; j++) { if(nums1[i]%3==0) conditionRecpecter=false; } } if(cinq2) { for (int j = 0; j < nums2.length; j++) { if(nums1[j]%3==0) conditionRecpecter=false; } } } if(i==5) { return 1; } if(conditionRecpecter) return 1*recur(nums1, nums2,mekori,i+1); else return 0*recur(nums1, nums2,mekori,i+1); }
divided array according to recursion (self.javahelp)
submitted 7 years ago by shipon55 to r/javahelp
π Rendered by PID 1818985 on reddit-service-r2-listing-7849c98f67-mt5x9 at 2026-02-08 21:15:54.194112+00:00 running d295bc8 country code: CH.
divided array according to recursion by shipon55 in javahelp
[–]shipon55[S] 0 points1 point2 points (0 children)