Skip to content
This repository was archived by the owner on Jun 19, 2020. It is now read-only.

Commit 8eb9f38

Browse files
authored
Merge pull request #26 from ohahohah/ohahohah
master 설정파일 merge
2 parents 8d50cbc + 94c2ec7 commit 8eb9f38

File tree

3 files changed

+82
-0
lines changed

3 files changed

+82
-0
lines changed

codilty/codilty.iml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<module type="JAVA_MODULE" version="4">
3+
<component name="NewModuleRootManager" inherit-compiler-output="true">
4+
<exclude-output />
5+
<content url="file://$MODULE_DIR$">
6+
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
7+
</content>
8+
<orderEntry type="inheritedJdk" />
9+
<orderEntry type="sourceFolder" forTests="false" />
10+
</component>
11+
</module>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package codility;
2+
3+
public class DoSolution {
4+
5+
private static final int DUMMY_VALUE = -1;
6+
7+
public static void main(String[] args){
8+
Solution sol = new Solution();
9+
//Only for run solution - DUMMY_VALUE doesn't affect anything
10+
int result = sol.solution(DUMMY_VALUE);
11+
}
12+
}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
package codility;
2+
3+
class Solution {
4+
5+
public int solution(int A) {
6+
if (isLocal()) {
7+
runTestCase();
8+
runExceptionCase();
9+
runMaxCase();
10+
runMinCase();
11+
} else {
12+
// TODO refactoring function name
13+
something(A);
14+
}
15+
return 0;
16+
}
17+
18+
public int something(int s) {
19+
//stub
20+
return -1;
21+
}
22+
23+
private void assertResult(int input, int expected) {
24+
int actual = something(input);
25+
if (actual != expected) {
26+
System.out.println(
27+
"not equals for input " + input + ", expected=" + expected + ", actual=" + actual);
28+
}
29+
}
30+
31+
private void runTestCase() {
32+
assertResult(1, 0);
33+
assertResult(2, 1);
34+
assertResult(3, 3);
35+
assertResult(4, 6);
36+
assertResult(5, 10);
37+
assertResult(6, 15);
38+
assertResult(7, 21);
39+
}
40+
41+
private void runExceptionCase() {
42+
assertResult(0, -1);
43+
}
44+
45+
private void runMaxCase() {
46+
assertResult(4999, 0);
47+
}
48+
49+
private void runMinCase() {
50+
assertResult(-4999, 0);
51+
}
52+
53+
private boolean isLocal() {
54+
String current_path = System.getProperty("user.dir");
55+
//TODO change localActualPath
56+
String localActualPath = "/Users/mac";
57+
return current_path.startsWith(localActualPath);
58+
}
59+
}

0 commit comments

Comments
 (0)