Skip to content

Commit

Permalink
Day one (#12)
Browse files Browse the repository at this point in the history
* Day 1 Part 1

* day one part two

* remove ci test
  • Loading branch information
Criyl authored Dec 2, 2023
1 parent 391bf48 commit 0e3439a
Show file tree
Hide file tree
Showing 28 changed files with 2,280 additions and 114 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ async def run_day(year, day, day_dir, taskgroup):
entries = await day_dir.entries()
for language, strategy in SUPPORTED_LANGUAGE.items():
if language not in entries or strategy is None:
break
continue
working_dir = day_dir.directory(f"{language}")
strategy = SUPPORTED_LANGUAGE[language](year, day, language)
global DAY_REPORTS
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ jobs:
run: curl -L https://dl.dagger.io/dagger/install.sh | sh && mkdir dist
- name: Run Dagger CLI
run: ./bin/dagger run python .github/workflows/ci.py >> dist/result.log
- name: Test CI failure test
run: ./bin/dagger run python .github/workflows/ci_test.py
- name: Archive artifacts
if: github.ref == 'refs/heads/main'
uses: actions/upload-artifact@v3
Expand Down
14 changes: 0 additions & 14 deletions .github/workflows/ci_test.py

This file was deleted.

10 changes: 0 additions & 10 deletions AoC0000/bad_day_00/golang/main.go

This file was deleted.

10 changes: 0 additions & 10 deletions AoC0000/bad_day_00/golang/main_test.go

This file was deleted.

9 changes: 0 additions & 9 deletions AoC0000/bad_day_00/java/main/java/Main.java

This file was deleted.

8 changes: 0 additions & 8 deletions AoC0000/bad_day_00/java/main/java/Solver.java

This file was deleted.

12 changes: 0 additions & 12 deletions AoC0000/bad_day_00/java/test/java/SolverTest.java

This file was deleted.

3 changes: 0 additions & 3 deletions AoC0000/bad_day_00/js/index.js

This file was deleted.

4 changes: 0 additions & 4 deletions AoC0000/bad_day_00/js/solve.js

This file was deleted.

7 changes: 0 additions & 7 deletions AoC0000/bad_day_00/js/solve.test.js

This file was deleted.

5 changes: 0 additions & 5 deletions AoC0000/bad_day_00/python/main.py

This file was deleted.

7 changes: 0 additions & 7 deletions AoC0000/bad_day_00/python/test_main.py

This file was deleted.

18 changes: 0 additions & 18 deletions AoC0000/bad_day_00/rust/main.rs

This file was deleted.

11 changes: 11 additions & 0 deletions AoC2023/day_01_01/java/main/java/solve/Main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package solve;

class Main {
public static void main(String[] args) {

Utils utils = new Utils();
String content = utils.getResourceFileAsString("input.txt");

System.out.println( Solver.solve(content) );
}
}
33 changes: 33 additions & 0 deletions AoC2023/day_01_01/java/main/java/solve/Solver.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package solve;

import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Solver {

public static String solve_case(String input) {

String regex = "([0-9])";

Matcher first = Pattern.compile(regex + ".*").matcher(input);
Matcher last = Pattern.compile(".*" + regex).matcher(input);

first.find();
last.find();

String firstValue = first.group(1);
String lastValue = last.group(1);

return "" + firstValue + "" + lastValue;
}

public static String solve(String input) {
int count = 0;
for (String line : input.split("\n")) {
count += Integer.parseInt(solve_case(line));
}
return "" + count;
}
}
28 changes: 28 additions & 0 deletions AoC2023/day_01_01/java/main/java/solve/Utils.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package solve;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.nio.charset.StandardCharsets;

public class Utils {
public String getResourceFileAsString(String fileName) {
InputStream inputStream = getClass().getClassLoader().getResourceAsStream(fileName);

StringBuilder textBuilder = new StringBuilder();

try (
Reader reader = new BufferedReader(
new InputStreamReader(inputStream, StandardCharsets.UTF_8)
)
) {
int c = 0;
while ((c = reader.read()) != -1) {
textBuilder.append((char) c);
}
}catch(Exception e){
System.err.println(e);
}
return textBuilder.toString();
}
}
Loading

0 comments on commit 0e3439a

Please sign in to comment.