Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
985f0b3
first commit.
jenarp Jul 21, 2021
ce08871
Hello World! This is my first commit while actually "knowing" what I …
jenarp Jul 22, 2021
f29f6b1
I added the code to puzzle day 2 (both parts) in Day02.java. Addition…
jenarp Jul 27, 2021
aacb06f
I added the code to puzzle day 2 (both parts) in Day02.java. Addition…
jenarp Jul 27, 2021
e53d121
Apply suggestions from code review
jenarp Aug 2, 2021
31af216
- I added the code to puzzle day 3 (both parts) in Day03.java.
jenarp Aug 5, 2021
cda2e9d
I added the code to puzzle day 4 (both parts) in Day04.java. Addition…
jenarp Aug 25, 2021
030aa36
I added the code to puzzle day 4 (both parts) in Day04.java. Addition…
jenarp Aug 25, 2021
6014d16
Day04: I changed some modifiers.
jenarp Aug 25, 2021
5059941
I added the code to puzzle day 2 (both parts) in Day02.java. Addition…
jenarp Aug 25, 2021
734c4fc
Adding data input to resources folder.
jenarp Aug 25, 2021
02cb28c
Delete "filereader"
jenarp Aug 25, 2021
99e7d62
Some changes for heroku
jenarp Aug 25, 2021
1a9be50
Some changes for heroku
jenarp Aug 25, 2021
87d0b79
Heroku stuff
jenarp Aug 25, 2021
6a42e54
heroku stuff
jenarp Aug 25, 2021
140bae3
add logging
jenarp Aug 25, 2021
88a65d2
add logging
jenarp Aug 25, 2021
4491ab2
Heroku: changed method to read in data: now via "getClass().getResour…
jenarp Aug 27, 2021
5356565
heroku
jenarp Aug 29, 2021
84f5510
Changed parameter day and part in AdventOfCodeController to Integers …
jenarp Sep 2, 2021
d206be1
Heroku: I added a default value by @RequestParam line 56 at AdventofC…
jenarp Sep 6, 2021
40c477e
Heroku: Bug Fix in Day01 (read in data)
jenarp Sep 6, 2021
6930948
Heroku: AdventOfCodeServiceTest.java: modified outout to my day01 out…
jenarp Sep 6, 2021
4ee8d1b
Heroku: add ne FE tests fix (Michelles repo)
jenarp Sep 6, 2021
51b0655
Heroku: add ne FE tests fix (Michelles repo)
jenarp Sep 6, 2021
abd51b7
Answer to puzzle day05: I added data in the resources folder (day05),…
jenarp Sep 13, 2021
39d57bb
Answer to puzzle day05: Formatting of Day05.java and Day05Test.java. …
jenarp Sep 14, 2021
157027f
Code formatting
jenarp Sep 14, 2021
71ed213
day01, day02, day03, day04: using utility class to read in raw Data, …
jenarp Sep 17, 2021
423f0d2
day01, day02, day03, day04, day05: using utility class to read in raw…
jenarp Sep 20, 2021
4f17909
Create mock Objects of DataLoader for all testing scripts
jenarp Sep 22, 2021
30be563
Test script CheckStringIsEmpty.java. Test boundary condition, i.e. (S…
jenarp Sep 22, 2021
e826aea
Added Documentation to CheckStringIsEmpty.java
jenarp Sep 22, 2021
341718b
Split: test data is only used in Test scripts and input Data only for…
jenarp Sep 22, 2021
c2e70bf
Last changes
jenarp Sep 24, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -74,16 +74,22 @@ dependencies {
implementation 'org.postgresql:postgresql:42.2.1'
implementation 'org.liquibase:liquibase-core'
implementation 'com.google.code.findbugs:jsr305:1.3.9'
implementation 'org.apache.commons:commons-lang3:3.12.0'
implementation 'org.junit.jupiter:junit-jupiter:5.7.0'
implementation 'org.junit.jupiter:junit-jupiter:5.7.0'
asciidoctor 'org.springframework.restdocs:spring-restdocs-asciidoctor'
testImplementation("org.springframework.restdocs:spring-restdocs-mockmvc")
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'junit:junit'
// testImplementation 'junit:junit'
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.3.1'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.3.1'
testImplementation 'org.mockito:mockito-inline:2.8.9'
testImplementation 'com.tngtech.archunit:archunit:0.9.3'
}

test {
outputs.dir snippetsDir
useJUnitPlatform()
}

asciidoctor {
Expand Down
6,983 changes: 5,235 additions & 1,748 deletions frontend/package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"http-proxy-middleware": "^0.20.0",
"react": "^16.12.0",
"react-dom": "^16.12.0",
"react-native": "^0.61.5",
"react-native": "^0.65.1",
"react-router-dom": "^5.1.2",
"react-scripts": "^3.3.0"
},
Expand Down
26 changes: 13 additions & 13 deletions frontend/src/components/App.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ describe("App", () => {
const actualPuzzleCards = component.instance().addPuzzleCards();

expect(
actualPuzzleCards.map(card => card.props.result)
actualPuzzleCards.map(card => card.props.result)
).to.have.all.members(expectedResults);

expect(
actualPuzzleCards.map(card => card.props.cardType)
actualPuzzleCards.map(card => card.props.cardType)
).to.have.all.members(["puzzleCard", "puzzleCard", "puzzleCard"]);

expect(actualPuzzleCards.map(card => card.props.day)).to.have.all.members([
Expand All @@ -47,22 +47,22 @@ describe("App", () => {
expect(component.children().getElements().length).to.equal(2);

expect(component.childAt(0).name()).to.equal(
"WithStyles(PrimarySearchAppBar)"
"WithStyles(PrimarySearchAppBar)"
);
expect(component.childAt(1).name()).to.equal("WithStyles(ForwardRef(Grid))");

expect(
component
.childAt(1)
.children()
.getElements().length
).to.equal(3);
component
.childAt(1)
.children()
.getElements().length
).to.equal(1);

expect(
component
.childAt(1)
.childAt(0)
.name()
component
.childAt(1)
.childAt(0)
.name()
).to.equal("WithStyles(CardTemplate)");
});

Expand All @@ -71,4 +71,4 @@ describe("App", () => {
ReactDOM.render(<App />, div);
ReactDOM.unmountComponentAtNode(div);
});
});
});
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Sat Jan 12 18:02:33 CET 2019
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10-all.zip
1 change: 1 addition & 0 deletions src/main/java/org/haffson/adventofcode/Application.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ public class Application {

public static void main(String[] args) {
SpringApplication.run(Application.class, args);

}
}
12 changes: 9 additions & 3 deletions src/main/java/org/haffson/adventofcode/ProblemStatusEnum.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,18 @@
* @author Michelle Fernandez Bieber
*/
public enum ProblemStatusEnum {
/** if the puzzle has been solved */
/**
* if the puzzle has been solved
*/
SOLVED,

/** if the puzzle is being worked on */
/**
* if the puzzle is being worked on
*/
IN_PROGRESS,

/** if the puzzle hasn't been started yet */
/**
* if the puzzle hasn't been started yet
*/
UNSOLVED
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ public AdventOfCodeController(AdventOfCodeService adventOfCodeService) {
* @return a HATEOAS-{@code Resource<>} with the corresponding solution
*/
@GetMapping
public Resource getResultForASpecificDayAndPuzzlePart(@RequestParam(value = "day", defaultValue = "") String day, @RequestParam(value = "part", defaultValue = "") String part) {
public Resource getResultForASpecificDayAndPuzzlePart(@RequestParam(value = "day", defaultValue = "1") Integer day,
@RequestParam(value = "part", defaultValue = "1") Integer part){

logger.info("The results for day " + day + ", part " + part + " have been requested.");

Expand Down Expand Up @@ -81,4 +82,21 @@ public Resources daysImplemented() {
linkTo(methodOn(AdventOfCodeController.class).daysImplemented()).withSelfRel()
);
}

@GetMapping("/test")
public String test () {

logger.info("A list of implemented days has been requested.");

return "Hallo";
}

@GetMapping("/test11")
public String test11 () {

logger.info("A list of implemented days has been requested.");

return "Hallo11";
}

}
5 changes: 3 additions & 2 deletions src/main/java/org/haffson/adventofcode/days/Days.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

import org.haffson.adventofcode.ProblemStatusEnum;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
* An interface for the individual puzzles,
Expand Down Expand Up @@ -38,5 +39,5 @@ public interface Days {
*
* @return the status of each part
*/
HashMap<String, ProblemStatusEnum> getProblemStatus();
Map<Integer, ProblemStatusEnum> getProblemStatus();
}
83 changes: 60 additions & 23 deletions src/main/java/org/haffson/adventofcode/days/day01/Day01.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,35 @@

import org.haffson.adventofcode.ProblemStatusEnum;
import org.haffson.adventofcode.days.Days;
import org.haffson.adventofcode.utils.FileReaders;
import org.springframework.beans.factory.annotation.Autowired;
import org.haffson.adventofcode.utils.DataLoader;
import org.haffson.adventofcode.utils.ProblemStatus;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;


/**
* Implementation for <i>Day 1: Chronal Calibration</i>.
*/
@Component
public class Day01 implements Days {

/** The puzzle status {@code HashMap} */
private final HashMap<String, ProblemStatusEnum> problemStatus;
private final Map<Integer, ProblemStatusEnum> problemStatus;
private final List<Integer> numbers;

/**
* Causes the input file to be parsed into the frequencies array ({@code frequencies}).
*
* @param fileReaders {@code @Autowired} fileReader //TODO: inject what you need
*/
@Autowired
Day01(FileReaders fileReaders) {
this.problemStatus = new HashMap<>();
this.problemStatus.put("1", ProblemStatusEnum.UNSOLVED);
this.problemStatus.put("2", ProblemStatusEnum.UNSOLVED);
public Day01(DataLoader dataLoader) {
// get data
this.numbers = dataLoader.getDataDay01();
// set ProblemStatus
this.problemStatus = ProblemStatus.getProblemStatusMap(1, 2,
ProblemStatusEnum.SOLVED, ProblemStatusEnum.SOLVED);
}

public List<Integer> getNumbers() {
return numbers;
}

@Override
Expand All @@ -35,27 +39,60 @@ public int getDay() {
}

@Override
public HashMap<String, ProblemStatusEnum> getProblemStatus() {
public Map<Integer, ProblemStatusEnum> getProblemStatus() {
return problemStatus;
}

@Override
public String firstPart() {
return "Part 1 - Frequency: " + calculateFrequency();
return "Product 1: " + calculateProduct_Part1(numbers);
}

@Override
public String secondPart() {
return null;
return "Product 2: " + calculateProduct_Part2(numbers);
}

/**
* utility method: subtract numbers from 2020
*/
private List<Integer> getSubtractedFrom2020(List<Integer> numbers) {
return numbers.stream()
.map(value -> 2020 - value)
.collect(Collectors.toList());
}

/**
* Primary method for Day 1, Part 1.
* Calculates the final frequency as the sum of all frequencies.
* Calculates the product of two specific numbers from a list
*
* @return the product
*/
private int calculateProduct_Part1(final List<Integer> numbers) {
// check for intersection of two lists
numbers.retainAll(getSubtractedFrom2020(numbers));
// product of "intersected" values is the puzzle's answer!
return numbers.get(0) * numbers.get(1);
}

/**
* Primary method for Day 1, Part 2.
* Calculates the product of two specific numbers from a list
*
* @return the final frequency
* @return the product
*/
private int calculateFrequency() {
return 0;
private int calculateProduct_Part2(final List<Integer> numbers) {
List<Integer> numbersSubtractedBy2020 = getSubtractedFrom2020(numbers);

List<Integer> tempData = new ArrayList<>();
for (int k = 0; k < numbers.size(); k++) {
for (Integer datum : numbers) {
tempData.add(numbers.get(k) + datum);
}
}
// check for intersection of two lists
numbersSubtractedBy2020.retainAll(tempData);
// product of "intersected" values is the puzzle's answer!
return (2020 - numbersSubtractedBy2020.get(0)) * (2020 - numbersSubtractedBy2020.get(1)) * (2020 - numbersSubtractedBy2020.get(2));
}
}
}
Loading