This commit is contained in:
2024-09-12 19:08:52 -04:00
commit 9c5889863d
4 changed files with 1098 additions and 0 deletions
+41
View File
@@ -0,0 +1,41 @@
import java.util.HashMap;
import java.util.Map;
public class CalibrationPartTwo {
public static void main(String[] args) {
String str = """
two1nine
eightwothree
abcone2threexyz
xtwone3four
4nineeightseven2
zoneight234
7pqrstsixteen
""";
HahsMap<String, String> elements = new HashMap<>();
elements.put("one", "1");
elements.put("two", "2");
elements.put("three", "3");
elements.put("four", "4");
elements.put("five", "5");
elements.put("six", "6");
elements.put("seven", "7");
elements.put("eight", "8");
elements.put("nine", "9");
try {
for (String line : str.split("\n")) {
for (Map.Entry<String, String> entry : elements.entrySet()) {
line.replace(entry.getKey(), entry.getValue());
int first = -1;
int last = -1;
}
for (String c : line.split("")) {
System.out.println(c);
}
}
} catch (Exception e) {
// TODO: handle exception
}
}
}