This repository was archived by the owner on Jun 19, 2020. It is now read-only.
File tree 3 files changed +82
-0
lines changed
src/countingElement/MissingInteger 3 files changed +82
-0
lines changed Original file line number Diff line number Diff line change
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 >
Original file line number Diff line number Diff line change
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
+ }
Original file line number Diff line number Diff line change
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
+ }
You can’t perform that action at this time.
0 commit comments