init, day 1
This commit is contained in:
parent
97c4931e01
commit
cb49e2b00d
|
@ -0,0 +1 @@
|
||||||
|
.vscode
|
|
@ -0,0 +1,41 @@
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
|
||||||
|
import org.json.JSONArray;
|
||||||
|
import org.json.JSONTokener;
|
||||||
|
|
||||||
|
class increaseCounter{
|
||||||
|
public static void main(String[] args){
|
||||||
|
File input = new File("input.json");
|
||||||
|
|
||||||
|
try{
|
||||||
|
InputStream fileIn = new FileInputStream(input);
|
||||||
|
JSONTokener inputJson = new JSONTokener(fileIn);
|
||||||
|
JSONArray values = (JSONArray)inputJson.nextValue();
|
||||||
|
//System.out.println(inputArray.toString());
|
||||||
|
|
||||||
|
// Get the amount of times it increases
|
||||||
|
int increaseCount = 0;
|
||||||
|
for(int i = 1; i < values.length(); i++)
|
||||||
|
if(values.getInt(i-1) < values.getInt(i))
|
||||||
|
increaseCount++;
|
||||||
|
System.out.println(increaseCount);
|
||||||
|
|
||||||
|
// Get the amount of times it increase by three-measure sliding increments
|
||||||
|
int increaseCount3 = 0;
|
||||||
|
for(int i = 3; i < values.length(); i++){
|
||||||
|
int winA = values.getInt(i - 3) + values.getInt(i - 2) + values.getInt(i - 1);
|
||||||
|
int winB = values.getInt(i - 2) + values.getInt(i - 1) + values.getInt(i);
|
||||||
|
if(winA < winB)
|
||||||
|
increaseCount3++;
|
||||||
|
}
|
||||||
|
System.out.println(increaseCount3);
|
||||||
|
|
||||||
|
} catch(FileNotFoundException e){
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue