-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Day 1 Part 1 * day one part two * remove ci test
- Loading branch information
Showing
28 changed files
with
2,280 additions
and
114 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) ); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} |
Oops, something went wrong.