Skip to content

Instantly share code, notes, and snippets.

@mojenmojen
Created December 8, 2016 18:41
Show Gist options
  • Save mojenmojen/1d855f3fb47813d850d63238104fb54a to your computer and use it in GitHub Desktop.
Save mojenmojen/1d855f3fb47813d850d63238104fb54a to your computer and use it in GitHub Desktop.
Count Possible Clusters
public static int CountPossibleClusters( int totalRelics, int checkNum ) {
int next_checkNum = 0;
switch (checkNum) {
case 6:
next_checkNum = 5;
break;
case 5:
next_checkNum = 4;
break;
case 4:
next_checkNum = 3;
break;
case 3:
next_checkNum = 2;
break;
case 2:
next_checkNum = 1;
break;
case 1:
return 1;
}
int clusters = 0;
for (int i = 0; i * checkNum <= totalRelics; i++) {
clusters += CountPossibleClusters( totalRelics - i * checkNum, next_checkNum);
}
return clusters;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment