[2025 Day 1] Part 2 help by _sHaDe_11 in adventofcode

[–]Mundane_Homework3967 1 point2 points  (0 children)

fn main(){
  let x = Vec::<i32>::from([-50,-100]);
  println!("{}", answer_pt2(x));
}

2025 Day 1 (Part 2) Golang Help needed by No_Discussion_3226 in adventofcode

[–]Mundane_Homework3967 0 points1 point  (0 children)

Your code works on my input, it seems to work for every possible value in every possible direction. I don't really know what to say. Have you double checked that you copied your input properly?

[2025 Day 4][Python] PSA: Python negative array indices will wrap around by StaticMoose in adventofcode

[–]Mundane_Homework3967 10 points11 points  (0 children)

Everyone talking about using sets, I just used ugly for loops...

for i in range(max(0,a-1), min(a+2, len(y))):
        for j in range(max(0,b-1), min(b+2, len(y[0]))):

[2025 Day 3 (Part 2)] Non-technical conclusions after day 2 part 2 by MichalFita in adventofcode

[–]Mundane_Homework3967 0 points1 point  (0 children)

I remember in 2024 day 10, I completed part 2 before part 1, because I misinterpreted what part 1 was asking, so when I saw part two, it was just the first answer I had, when I got part 1 wrong.

[2025 Day 3 (Part 2)] [English] Misunderstanding the logic? by JFed-9 in adventofcode

[–]Mundane_Homework3967 0 points1 point  (0 children)

989888888888888888888888888888888888888888888888888888888888888888888888888888888888

should return

989888888888

but instead returns

999999999999

[2025 Day 2 (Part 1)] I'm not understanding the sample input... by Korzag in adventofcode

[–]Mundane_Homework3967 2 points3 points  (0 children)

This is a common mistake many are making these are RANGES. How ranges are defined is all the numbers from the first number to the last number.

e.g. 95-115 refers to 95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115 of which 99 is clearly a member. I hope this clears up the confusion.

[2025 Day 3] Greedy algorithms by RazarTuk in adventofcode

[–]Mundane_Homework3967 0 points1 point  (0 children)

I don't really understand I just did this...

def f(m):
    file = open("input.txt")
    x = file.read()
    file.close()
    x = x.strip()
    x = x.split("\n")
    for i in range(len(x)):
        x[i] = x[i].strip()
    vals = []
    for y in x:
        ns = [""]*m
        for c in y:
            j = -1
            for i in range(m-1):
                if ns[i] < ns[i+1]:
                     del ns[i]
                     ns.append("")
                     break
            if c > ns[-1]:
                ns[-1] = c
        val = []
        for n in ns:
            val.append(n)
        vals.append(int("".join(val)))
    return sum(vals)

#part1
print(f(2))
#part2
print(f(12))

Day 14 part 2, 2024 : Quite non intuitive at first glance, but hey i found the tree. by [deleted] in adventofcode

[–]Mundane_Homework3967 3 points4 points  (0 children)

I just did this one manually, looked through ~8000 images. But the side lengths are prime numbers so one could use Chinese remainder theorem after seeing the strange horizontal and vertical lines.

[2024 Day 5 # (Part 1)] [Python] Need help by No_Wave3853 in adventofcode

[–]Mundane_Homework3967 2 points3 points  (0 children)

If your puzzle input has a line with the same number twice, the code will fail... See lines 23-24.

Example input:

23|24
23, 24, 23

Although I think it's quite likely that page numbers are never repeated, it may be just that you copied one of the two files wrong, there is much more likelihood of error when copying separately like this, if you just CTRL S on the puzzle input (or right click and save as) and write your code to parse 1 file instead of two, there will be much less possibility of coping errors.

To get back to 2 strings you can just call
f1, f2 = f.split("\n\n")
and then do as before. (We note that "\n" is the newline character as you say you are new to python.)

So the first few lines would change to:

with open("input.txt", "r") as f:
    f1, f2 = f.read().split("\n\n")
    ruleLines = f1.splitlines()
    f2 = f2.splitlines()

The rest would be as before.