From 0cd3e580d16c527e2e396e814ebb136b98346c3d Mon Sep 17 00:00:00 2001 From: Adam Perkowski Date: Mon, 16 Dec 2024 11:39:01 +0100 Subject: [PATCH] remove c++ BLOAT --- _2024/_01/01.jule | 11 ++++------- _2024/_01/helper.hpp | 19 ------------------- 2 files changed, 4 insertions(+), 26 deletions(-) delete mode 100644 _2024/_01/helper.hpp diff --git a/_2024/_01/01.jule b/_2024/_01/01.jule index b9c73ee..259731e 100644 --- a/_2024/_01/01.jule +++ b/_2024/_01/01.jule @@ -2,15 +2,12 @@ // https://github.com/adamperkowski/aoc_jule // https://adventofcode.com/2024/day/1 +use "std/conv" use "std/math" use "std/os" use "std/slices" use "std/strings" -cpp use "helper.hpp" - -cpp fn readIntegers(line: str, do_right: bool): int - fn calculateMetrics(input: []byte): [2]int { lines := strings::SplitAll(str(input), "\n") @@ -18,9 +15,9 @@ fn calculateMetrics(input: []byte): [2]int { let mut list_right: []int for _, line_b in lines { - line := str(line_b) - list_left = append(list_left, cpp.readIntegers(line, false)) - list_right = append(list_right, cpp.readIntegers(line, true)) + line := strings::SplitAll(str(line_b), " ") + list_left = append(list_left, conv::Atoi(line[0])!) + list_right = append(list_right, conv::Atoi(line[1])!) } slices::Sort(list_left) diff --git a/_2024/_01/helper.hpp b/_2024/_01/helper.hpp deleted file mode 100644 index 1a525d5..0000000 --- a/_2024/_01/helper.hpp +++ /dev/null @@ -1,19 +0,0 @@ -using namespace jule; - -#include -#include -#include - -int readIntegers(const std::string& line, bool do_right) { - std::istringstream iss(line); - int left, right; - if (iss >> left >> right) { - if (do_right) { - return right; - } else { - return left; - } - } else { - std::cerr << "Error reading line: " << line << std::endl; - } -}