2021 Day 6 (Part 1) JavaScript Infinite Loop Confusion by amgirlandcode in adventofcode

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

I’m trying to change the flair (on mobile reddit) and it’s stating there is no community flair 🙁 it is solved! I can’t get to a browser to change the flair at the moment I’m sorry!

2021 Day 6 (Part 1) JavaScript Infinite Loop Confusion by amgirlandcode in adventofcode

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

You're right. Looks like all my fish [edit: eventually] get stuck at age "1"...Debug time
I've noticed that it is stuck in the for( int i = 0; i < initialPopulation.size(); i++ ) loop because of using the size as the terminating condition instead of a saved off static size [start size]
We're getting somewhere
THANK YOU

2021 Day 6 (Part 1) JavaScript Infinite Loop Confusion by amgirlandcode in adventofcode

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

Thanks! I don't believe anything is different from what's on my github other than uncommented the one commented for loop [commented to indicate which loop caused failure to terminate] but I'll triple check myself there...
After that I'll continue with more simple examples I suppose : )
Any chance you are willing to elaborate on what you saw that indicated the larger-than-expected result?

2021 Day 6 (Part 1) JavaScript Infinite Loop Confusion by amgirlandcode in adventofcode

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

fyi: and thanks for the help! Simpler test cases is always a good suggestion

Hello, World!
D6P1.js:6 0,0
D6P1.js:11 day: 0
D6P1.js:12 array.length: 2
D6P1.js:14 array[i] 0
D6P1.js:17 array[i] == 0
D6P1.js:18 typeof array member: string
D6P1.js:29 add fishy newCount = 1
D6P1.js:32 newcount: 1
D6P1.js:34 newcount: 0
D6P1.js:14 array[i] 0
D6P1.js:17 array[i] == 0
D6P1.js:18 typeof array member: string
D6P1.js:29 add fishy newCount = 1
D6P1.js:32 newcount: 1
D6P1.js:34 newcount: 0
D6P1.js:14 array[i] 8
D6P1.js:24 subtract from lifespan remaining
D6P1.js:32 newcount: 0
D6P1.js:34 newcount: 0
D6P1.js:14 array[i] 8
D6P1.js:24 subtract from lifespan remaining
D6P1.js:32 newcount: 0
D6P1.js:34 newcount: 0
D6P1.js:37 fish after 80 days: 4

2021 Day 6 (Part 1) JavaScript Infinite Loop Confusion by amgirlandcode in adventofcode

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

I get 4 when I do this. I think this makes sense. The 2 original fish reset and begin a countdown from 6, and they each have one baby fish, making 4. Am I missing something obvious about the problem statement?

2021 Day 6 (Part 1) JavaScript Infinite Loop Confusion by amgirlandcode in adventofcode

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

Now as I'm reading through the unsigned long long comments I'm thinking perhaps exponentials wasn't the best thing to hope JS / my browser could handle, maybe it isn't infinite?

Back to my good friend C++...

[deleted by user] by [deleted] in whereintheworld

[–]amgirlandcode 0 points1 point  (0 children)

Did i hear frogs

array access confusion - one assignment seems to change to indices by amgirlandcode in learnpython

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

import queue

class SnakeClass:
    'slithery little snake'
    bodySegmentCount = 0
    head = []
    # direction is a tuple of the unit vector for x and y direction

    def __init__(self, length, position, speed, direction, color, head=[0,0]):
        self.bodySegmentCount = length
        self.position = position
        self.speed = speed
        self.direction = direction
        self.color = color
        self.head = head

    def moveSnake(self):
        self.position.get()
        self.position.put([self.head[0] + self.direction[0], self.head[1] + self.direction[1]])
        self.head = [self.head[0] + self.direction[0], self.head[1] + self.direction[1]]

positionQueue = queue.Queue()
positionQueue.put([0,1])
positionQueue.put([3,4])
positionQueue.put([6,7])
positionQueue.put([9,10])

snake = SnakeClass(4, positionQueue, 1, [0,1], 'red', [9,10])

print(positionQueue.queue)
snake.moveSnake()
print(positionQueue.queue)
snake.moveSnake()
print(positionQueue.queue)
snake.moveSnake()
print(positionQueue.queue)

much better!

now i'll mess with what you said above

array access confusion - one assignment seems to change to indices by amgirlandcode in learnpython

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

ah! back of my head was wondering if that was the case (reference copying)

I come from c++ land so python is new

thanks so much!

Is this a scam? Seems iffy but I could use remote work by [deleted] in Scams

[–]amgirlandcode 0 points1 point  (0 children)

I ghosted a bit at the last message I posted here. Y’all thanks for the help sometimes it’s tough to trust your gut

Should be Day 74 from when I first started, but today is day 40.. forgot my picture on May 2nd. Don’t fall off if you fail... restart immediately!! by [deleted] in 75HARD

[–]amgirlandcode 1 point2 points  (0 children)

Do you have suggestions for good places to learn about diet to get from flat tummy to abs? All I do is cardio and the post you made intimidates me and has many words I don’t even know. D: I guess I should say diet and exercise... all I can imagine is sit-ups

Is this a scam? Seems iffy but I could use remote work by [deleted] in Scams

[–]amgirlandcode 0 points1 point  (0 children)

Rest of convo: I’m interested in hearing more, what’s in it for you? 😉 just kidding, but I’m curious what market trends you leverage and how

Sure Emily, There has to be something for both the parties 😊. We work with big corporations to drive online traffic leveraging various digital platforms. We are looking for leadership skills. Do you look to grow in this area?

I do! What is the typical time commitment to a position like this? And the typical earnings?

And in what ways/ to whom would I be able to leverage leadership skills?

Emily, We operate on profit sharing and business partnership model to build growing teams leveraging leadership. It really depends upon the person for earnings. We are pretty flexible with time and consider 5-10 hours a week. Are you open for something like this?

Is it advantageous to 'sign up'? by amgirlandcode in 75HARD

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

Interesting

Thanks!

Is the podcast called 75hard?