~vladh/aoc-2023

23a5fd3cf6b22b518addce677a1b1c2c298ea2b0 — Vlad-Stefan Harbuz 6 months ago c046028
remove exports
4 files changed, 11 insertions(+), 15 deletions(-)

M 01-1.ha
M 01-2.ha
M 02-1.ha
M 02-2.ha
M 01-1.ha => 01-1.ha +3 -4
@@ 8,10 8,9 @@ use strings;
use types;


export fn get_digit(iter: strings::iterator) int = {
fn get_digit(iter: strings::iterator) int = {
	for (true) {
		const next = strings::next(&iter);
		match (next) {
		match (strings::next(&iter)) {
		case void =>
			return 0;
		case let r: rune =>


@@ 24,7 23,7 @@ export fn get_digit(iter: strings::iterator) int = {
};


export fn get_line_value(line: str) int = {
fn get_line_value(line: str) int = {
	let iter = strings::iter(line);
	let first_digit = get_digit(iter);
	let riter = strings::riter(line);

M 01-2.ha => 01-2.ha +6 -9
@@ 8,12 8,9 @@ use strings;
use types;


export fn get_digit(iter: strings::iterator, line: str, reverse: bool) int = {
	let next_idx = 0z;
	for (true) {
		const next = strings::next(&iter);
		next_idx += 1;
		match (next) {
fn get_digit(iter: strings::iterator, line: str, reverse: bool) int = {
	for (let idx = 0z; true; idx += 1) {
		match (strings::next(&iter)) {
		case void =>
			return 0;
		case let r: rune =>


@@ 22,9 19,9 @@ export fn get_digit(iter: strings::iterator, line: str, reverse: bool) int = {
				return strconv::stoi(s)!;
			};
			const sub = if (reverse) {
				yield strings::sub(line, len(line) - next_idx - 1, strings::end);
				yield strings::sub(line, len(line) - idx, strings::end);
			} else {
				yield strings::sub(line, next_idx - 1, strings::end);
				yield strings::sub(line, idx, strings::end);
			};
			if (strings::hasprefix(sub, "one"))   { return 1; };
			if (strings::hasprefix(sub, "two"))   { return 2; };


@@ 40,7 37,7 @@ export fn get_digit(iter: strings::iterator, line: str, reverse: bool) int = {
};


export fn get_line_value(line: str) int = {
fn get_line_value(line: str) int = {
	let iter = strings::iter(line);
	let first_digit = get_digit(iter, line, false);
	let riter = strings::riter(line);

M 02-1.ha => 02-1.ha +1 -1
@@ 12,7 12,7 @@ def MAX_GREEN: size = 13z;
def MAX_BLUE: size = 14z;


export fn get_game_value(line: str) size = {
fn get_game_value(line: str) size = {
	let is_possible = true;

	const tok_header = strings::tokenize(line, ": ");

M 02-2.ha => 02-2.ha +1 -1
@@ 8,7 8,7 @@ use strings;
use types;


export fn get_game_value(line: str) size = {
fn get_game_value(line: str) size = {
	let is_possible = true;
	let max_red = 0z;
	let max_green = 0z;