FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
ProjectEuler-Java/Sol15.java at master · JoshP/ProjectEuler-Java · GitHub
JoshP
ProjectEuler-Java
Repository navigation
Code
Issues
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
ProjectEuler-Java
/
Sol15.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
29 lines (25 loc) · 816 Bytes
Breadcrumbs
ProjectEuler-Java
/
Sol15.java
Copy path
File metadata and controls
29 lines (25 loc) · 816 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import
java
.
math
.*;
public
class
Sol15
extends
BaseSolution
{
public
void
runSolution
() {
int
gridSize
=
20
;
Long
[][]
countArray
=
new
Long
[
gridSize
+
1
][
gridSize
+
1
];
System
.
out
.
println
(
findRoutes
(
0
,
0
,
gridSize
,
countArray
));
}
public
long
findRoutes
(
int
x
,
int
y
,
int
max
,
Long
[][]
countArray
) {
if
(
x
==
max
&&
y
==
max
) {
return
1
;
}
if
(
countArray
[
x
][
y
] !=
null
) {
return
countArray
[
x
][
y
];
}
long
count
=
0
;
if
(
x
<
max
) {
count
+=
findRoutes
(
x
+
1
,
y
,
max
,
countArray
);
}
if
(
y
<
max
) {
count
+=
findRoutes
(
x
,
y
+
1
,
max
,
countArray
);
}
countArray
[
x
][
y
] =
count
;
return
count
;
}
}
Back
|
FazBrowse Home
|
New Git URL