Skip to content
Snippets Groups Projects
Commit c0e5b79a authored by mdejournett2's avatar mdejournett2
Browse files

Adding shorter day 1 code

parent e265c18b
No related branches found
No related tags found
No related merge requests found
public class day1code{
public static void main(String[] args){
String[] items = "1000 2000 3000 \n4000 5000 6000 \n7000 8000 9000 \n10000".split(" \n");
int maxCalorieCount = 0;
for (int counter=0;counter<items.length;counter++){
int currentCalorieCount =0 ;
String[] eachItem = items[counter].split(" ");
for(int innerCounter =0;innerCounter<eachItem.length;innerCounter++){
currentCalorieCount = currentCalorieCount+Integer.parseInt(eachItem[innerCounter]);
}
if (currentCalorieCount>maxCalorieCount)maxCalorieCount=currentCalorieCount;
}
System.out.println(maxCalorieCount);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment