-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWC_2_3_MarbleChallenge.java
More file actions
49 lines (41 loc) · 1.05 KB
/
WC_2_3_MarbleChallenge.java
File metadata and controls
49 lines (41 loc) · 1.05 KB
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import java.util.Scanner;
public class WC_2_3_MarbleChallenge {
static void findStates(int position[])
{
position[0] = 0;
position[1] = 1;
position[2] = 1;
position[3] = 0;
position[4] = 1;
position[5] = 1;
position[6] = 0;
position[7] = 1;
for (int i = 8; i < 100; i++) {
if (i % 3 == 0)
{
position[i] = 0;
}
if ((i - 1) % 3 == 0) {
position[i] = 1;
}
if ((i - 2) % 3 == 0) {
position[i] = 1;
}
}
}
public static void main (String[] args)
{
int testCase[]={22,45,26,75};
int position[]=new int[100];
findStates(position);
int sum=0;
for(int i=0;i<4;i++)
{
if(position[testCase[i]]==1)
sum+=1;
else if(position[testCase[i]]==0)
sum+=2;
}
System.out.println(sum);
}
}