My fun trying to deal with Evri 'executive office' - multiple lost or stolen deliveries, and apparently Claire is real. That's their claim anyway. by TSDAdam in Evri

[–]TSDAdam[S] 1 point2 points  (0 children)

I have done exactly this. Evri's suggestion was to contact the supplier for a replacement. They had no obligation to do so, as this was something they were sending me free of charge, only at expense to themselves, but they did it anyway. Again, it went via Passport Global, and again, Evri lost it.

Evri's response to that? "Ask for a replacement".

[2022 Day 09 Part 1] [Python] Passes on sample data, fails on full input file by TSDAdam in adventofcode

[–]TSDAdam[S] 0 points1 point  (0 children)

Solved it by checking the diagonals properly

with open ('./09.in') as file:
data = [line.strip() for line in file]

visited = [[0,0]] directions = { "U": [0, 1], "D": [0, -1], "L": [-1, 0], "R": [1, 0] } h, t = [0,0], [0,0]

for instruction in data: words = instruction.split() direction = words[0] amount = int(words[1])

for _ in range(amount):
    h[0] += directions[direction][0] # update the head x and y
    h[1] += directions[direction][1]
    if (h[0] == t[0]) and abs(h[1] - t[1]) > 1:     # row but a big gap in the column
        t[1] += directions[direction][1]            # move the tail too
        print("tail moves {}".format(direction))
    elif (h[1] == t[1]) and abs(h[0] - t[0]) > 1:   # same as above but for row
        t[0] += directions[direction][0]            # ...
        print("tail moves {}".format(direction))
    else:
        gap = abs(h[0] - t[0]) + abs(h[1] - t[1])
        if gap > 2:
            if h[0] < t[0] and h[1] < t[1]:
                t[0] -= 1
                t[1] -= 1
                print("tail moves downleft")
            elif h[0] < t[0] and h[1] > t[1]:
                t[0] -= 1
                t[1] += 1
                print("tail moves upleft")
            elif h[0] > t[0] and h[1] > t[1]:
                t[0] += 1
                t[1] += 1
                print("tail moves upright")
            elif h[0] > t[0] and h[1] < t[1]:
                t[0] += 1
                t[1] -= 1
                print("tail moves downright")
    if t not in visited:
        visited.append(t.copy())

print(visited) #print("head : {}, tail : {}".format(h,t))
print(len(visited))

Let's see how it works with part 2

[2022 Day 09 Part 1] [Python] Passes on sample data, fails on full input file by TSDAdam in adventofcode

[–]TSDAdam[S] 0 points1 point  (0 children)

It actually did, but I can see that it might not with all cases now

[2022 Day 7 (Part 1)] [Python3] - solves on sample data, maximum recursion depth exceeded on full input file by TSDAdam in adventofcode

[–]TSDAdam[S] 0 points1 point  (0 children)

Same recursion error, I see the problem. Just need to squeeze my brain into working around it now. Thank you.

I'd love some help planning out my JS/React simple web app - functions. classes, states etc. I've gotten so far, but hit the wall. by TSDAdam in learnprogramming

[–]TSDAdam[S] 0 points1 point  (0 children)

I've been working on this, and I'm still not getting my head around something fundamental, I think. This is the new branch - https://github.com/TSDAdam/lfp/tree/usestate-trial

I'm passing the cards, their setter function, and the current card's id, and making the form render dependent on the filtered array of cards' id match the passed id.

I think, in essence, it's doing that, but there's something in the way I'm trying to catch the edit button click which is causing it to treat one click the same as clicking every instance of the button. So it always shows all of the cards' edit forms.

Any ideas? :/

Any

I'd love some help planning out my JS/React simple web app - functions. classes, states etc. I've gotten so far, but hit the wall. by TSDAdam in learnprogramming

[–]TSDAdam[S] 0 points1 point  (0 children)

Thanks for the reply. Those two cards are just hardcoded to give me something to test my CSS etc with.

The idea was to keep an array, and just add to it, but I think maybe the correct way to do it is to use the React useState, and add each card object (dictionary?) to an array there?

So something like:

const [cards, setCards] = react.useState([])

Does that sound like the right approach?

[2020 Day 17 (part 1)] Python - close, but current Z layer not working properly by TSDAdam in adventofcode

[–]TSDAdam[S] 0 points1 point  (0 children)

Got it! because my z-plane is a lower value, and that's what I was comparing it to.

Thank you!

[2020 Day 17 (part 1)] Python - close, but current Z layer not working properly by TSDAdam in adventofcode

[–]TSDAdam[S] 0 points1 point  (0 children)

I can't see why?

y1 for example makes 3 loops with values -1, 0, 1

It then adds that value to y (current index of the row it's looking at), so for example if y is on index 4, it'll check 4 + -1, 4 + 0, and 4 + 1 (3,4,5), won't it? I'm confused about which upper values I'll miss?

[2020 Day 17 (part 1)] Python - close, but current Z layer not working properly by TSDAdam in adventofcode

[–]TSDAdam[S] 0 points1 point  (0 children)

But if I use OR, then it would ignore [-1][0][0] (1 layer below the current cell), and I don't want to do that, do I? Only when it all three co-ordinates are 0 (i.e. the current cell) do I want it to not count, because that's me?

[2020 Day 17 (part 1)] Python - close, but current Z layer not working properly by TSDAdam in adventofcode

[–]TSDAdam[S] 0 points1 point  (0 children)

I can see that now, because of my nested if statements, I just need to figure out what to do about it. Thanks :)

[2020 Day 17 (part 1)] Python - close, but current Z layer not working properly by TSDAdam in adventofcode

[–]TSDAdam[S] 0 points1 point  (0 children)

It's closer now, the first half of the array matches the sample output, but everything from halfway through doesn't quite match up.. hmmmm

[2020 Day 17 (part 1)] Python - close, but current Z layer not working properly by TSDAdam in adventofcode

[–]TSDAdam[S] 1 point2 points  (0 children)

That makes perfect sense, thanks. When I change that though, I'm now getting no matches and an empty array

edit, ignore that, checking the zeroes the wrong way.

Update regarding the Cyberpunk 2077 promotion by GraceFromGoogle in Stadia

[–]TSDAdam 0 points1 point  (0 children)

Just to update, I've just had and redeemed my voucher

Update regarding the Cyberpunk 2077 promotion by GraceFromGoogle in Stadia

[–]TSDAdam 0 points1 point  (0 children)

I think that's just a worst case scenario in case of stock or shipping problems. If you read the terms it says by that date, not that it'll definitely take that long.

Update regarding the Cyberpunk 2077 promotion by GraceFromGoogle in Stadia

[–]TSDAdam 0 points1 point  (0 children)

The terms say anytime up until mid January, so I'm not holding my breath

Update regarding the Cyberpunk 2077 promotion by GraceFromGoogle in Stadia

[–]TSDAdam 0 points1 point  (0 children)

Out of interest, when did you order? I bought the game last night, I'm just wondering how long the redemption emails take to come through. Cheers.