From c0e5b79abf196aa24b10115ecaa5875fc5770915 Mon Sep 17 00:00:00 2001 From: mdejournett2 <mdejournett2@huskers.unl.edu> Date: Fri, 9 Dec 2022 19:58:58 -0600 Subject: [PATCH] Adding shorter day 1 code --- Day1/day1code | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 Day1/day1code diff --git a/Day1/day1code b/Day1/day1code new file mode 100644 index 0000000..241d1e1 --- /dev/null +++ b/Day1/day1code @@ -0,0 +1,15 @@ +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); +} +} -- GitLab