Skip to content

Commit

Permalink
refactor: refactor day 8
Browse files Browse the repository at this point in the history
  • Loading branch information
Flashky committed Dec 8, 2024
1 parent bbf1efe commit 00df560
Showing 1 changed file with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;

import java.util.List;
import java.util.Map;
import java.util.Set;
Expand Down Expand Up @@ -39,15 +40,16 @@ public ResonantCollinearity(char[][] input) {
public int solve(boolean countHarmonics) {
Set<Vector2> antinodeLocations = new HashSet<>();

for(Character frequency : antennasPerFrequency.keySet()) {
List<Vector2> antennas = antennasPerFrequency.get(frequency);
for(Map.Entry<Character,List<Vector2>> frequency : antennasPerFrequency.entrySet()) {

List<Vector2> antennas = frequency.getValue();

for(int i = 0; i < antennas.size(); i++) {
for(int j = 1; j < antennas.size(); j++) {
for (int i = 0; i < antennas.size(); i++) {
for (int j = 1; j < antennas.size(); j++) {
Vector2 antenna1 = antennas.get(i);
Vector2 antenna2 = antennas.get(j);

if(antenna1.equals(antenna2)) {
if (antenna1.equals(antenna2)) {
continue;
}

Expand Down Expand Up @@ -81,5 +83,4 @@ private boolean isInbounds(Vector2 antinodePos) {
return antinodePos.getY() >= 0 && antinodePos.getY() < rows && antinodePos.getX() >= 0 && antinodePos.getX() < cols;
}


}

0 comments on commit 00df560

Please sign in to comment.