Created
December 8, 2016 18:41
-
-
Save mojenmojen/1d855f3fb47813d850d63238104fb54a to your computer and use it in GitHub Desktop.
Count Possible Clusters
This file contains 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 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