From 0e3e3a3e51c9f03076cbfcea8619e73e9ba3b548 Mon Sep 17 00:00:00 2001 From: Daniel Date: Mon, 18 Sep 2023 12:28:24 -0400 Subject: [PATCH 1/2] push --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9e06d2e2..dd072e26 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ problems posted on https://projecteuler.net/archives which is another interestin programming problems. You might also recognize that the multiples of 3 and 5 problem from last week came from there. If you are looking for challenges, definitely check it out. -The partial cake recipes are courtesy ChatGPT. +the partial cake recipes are courtesy ChatGPT. # TASK 0: Fork this repo From a473a55d91a88462dc3f8c4a6b2b5e12969721ee Mon Sep 17 00:00:00 2001 From: Daniel Date: Mon, 18 Sep 2023 12:55:54 -0400 Subject: [PATCH 2/2] push --- README.md | 2 +- src/DataTypes.java | 8 ++++++-- test/DataTypesTest.java | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index dd072e26..9e06d2e2 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ problems posted on https://projecteuler.net/archives which is another interestin programming problems. You might also recognize that the multiples of 3 and 5 problem from last week came from there. If you are looking for challenges, definitely check it out. -the partial cake recipes are courtesy ChatGPT. +The partial cake recipes are courtesy ChatGPT. # TASK 0: Fork this repo diff --git a/src/DataTypes.java b/src/DataTypes.java index 4f807c1f..f831f96f 100644 --- a/src/DataTypes.java +++ b/src/DataTypes.java @@ -1,14 +1,18 @@ +import java.util.ArrayList; +import java.util.Arrays; import java.util.List; public class DataTypes { - // TODO TASK 1: fix this code so that it passes the test in DataTypesTest.java + public static long sum(List numbers) { - int s = 0; + long s = 0; // below is a "foreach" loop which iterates through numbers for (int x : numbers) { s += x; } return s; + } } + diff --git a/test/DataTypesTest.java b/test/DataTypesTest.java index e53951fe..03c395ea 100644 --- a/test/DataTypesTest.java +++ b/test/DataTypesTest.java @@ -24,6 +24,6 @@ public void largeSumTest() { for (int i = 1; i <= 1_000_000; i++) { lst.add(i); } - assertEquals("sum form 1 to 1 million should be " + x, x, DataTypes.sum(lst)); + assertEquals("sum from 1 to 1 million should be " + x, x, DataTypes.sum(lst)); } } \ No newline at end of file