Chobilet | 2 years ago | on: Ask HN: Who is hiring? (February 2024)
Chobilet's comments
Chobilet | 2 years ago | on: Ask HN: Who is hiring? (February 2024)
Chobilet | 2 years ago | on: Advent of Code 2023 is nigh
Chobilet | 2 years ago | on: Advent of Code 2023 is nigh
Abstractly I do this:
read_file()
lines = read_lines()
sum = 0
while lines:
left = get_first_num_forwards(line)
right = get_first_num_backwards(line)
sum += integer(left+right)
return sum
I define get_first_num() something like this: get_first_num(line):
lowest_index_pair = None
for key,val in dict.values():
get_index_of_key_if_exists()
if_exists: update_lowest_index_pair()
index,num find_first_instance_num() //just gets the first num that appears
update_lowest_index_pair()
return lowest_index_pair[1]//just returns the number
Basically the idea is very similar to yours. We parse each line 11 times in both direction(10 per the word_vals dict and once more to find the index of the first numerical) which is only 22 parses. Then we grab the minimum index from this list and concat with the opposite side.I just don't do any replacements at the cost of a longer run time. But I figure the cost of 11 parses was low enough that it wouldnt impact the run time significantly for this exercise.
The key point is that overlaps are not an issue because we check for string comparisons in the methods
Chobilet | 2 years ago | on: Advent of Code 2023 is nigh
What jumped to me is the problem statement indicated a finite number of states and I crafted a solution based on that information. But its really cool to see how we all jump to different implementations.
I see you guys have closed off candidates in your job posting. You all do seem like a lovely crowd. I myself am a bit too junior(though not inexperienced) to be a founding/senior member(I read the job title incorrectly the first time), but if you guys end up opening another position, I would definitely love to apply.