File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+
2+ public class BoardPath {
3+ public static long startTime;
4+ public static long endTime;
5+ public static void startAlgo() {
6+ startTime=System.currentTimeMillis();
7+ }
8+ public static long endAlgo() {
9+ endTime=System.currentTimeMillis();
10+ return endTime-startTime;
11+ }
12+ public static int bpR(int start,int end){
13+ if(start==end) {
14+ return 1;
15+ }
16+ else if(start>end)
17+ return 0;
18+ int count=0;
19+ for(int dice=1;dice<=6;dice++) {
20+ count+=bpR(start+dice,end);
21+ }
22+ return count;
23+ }
24+ public static int bpRS(int curr,int end,int strg[]){
25+ if(curr==end) {
26+ return 1;
27+ }
28+ else if(curr>end)
29+ return 0;
30+ if(strg[curr]!=0)
31+ return strg[curr];
32+ int count=0;
33+ for(int dice=1;dice<=6;dice++) {
34+ count+=bpRS(curr+dice,end,strg);
35+ }
36+ strg[curr]=count;
37+ return count;
38+ }
39+ public static int bpIS(int curr,int end,int[]strg){
40+ strg[end]=1;
41+ for(int i=end-1;i>=0;i--) {
42+ int count=0;
43+ for(int dice=1;dice<=6&&dice+i<strg.length;dice++) {
44+ count+=strg[i+dice];
45+ }
46+ strg[i]=count;
47+ }
48+ return strg[0];
49+ }
50+
51+
52+ }
You can’t perform that action at this time.
0 commit comments