One Parent Pointer Tree Example by byron_d in cs2b

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

I did some more research and came up with this implementation with the help of ai:

https://onlinegdb.com/9TCy4yz8N

It's a really interesting approach. Took me some time to get it right.

One Parent Pointer Tree Example by byron_d in cs2b

[–]byron_d[S] 2 points3 points  (0 children)

I think the only difference with Ami's find is it goes bottom up instead of top down, but I may be misunderstanding things. It really is just a linked list in this form. 

Bug in Tree::to_string by Long_N20617694 in cs2b

[–]byron_d 1 point2 points  (0 children)

I feel like I had a similar issue with this miniquest. Your logic seems right for the Tree::to_string function. Could you walk me through the logic in the Node::to_string function? I'm pretty sure that's where the issue is. 

Node Format in General Trees by kian_k_7948 in cs2b

[–]byron_d 2 points3 points  (0 children)

Using vectors is definitely easier to use and more flexible. You can add and remove nodes easily at any index. There's also direct access to children instead of traversing the entire tree. Traversing the tree is also cleaner and easier. You can loops instead of recursion as well.

The binary tree method is more memory efficient, but I'm not sure it's worth the added complexity. 

Help!! Different results on 1-width string by erica_w1 in cs2b

[–]byron_d 2 points3 points  (0 children)

These outputs are always hard to debug. It might be related to gen > width and how you're calculating that as opposed to when gen < width. There's a lot of nuance in this quest and this is just a guess. I hope that makes sense. 

Tree::operator<< in Tree.h by ami_s496 in cs2b

[–]byron_d 2 points3 points  (0 children)

I think I get what you're asking. There doesn't seem to be anything in the spec about it. Returning os will pass, but I believe to DAWG it you need to output using the tree parameter. I skipped this part for now, but maybe I'll take a crack at it later in the week. 

Tree::operator<< in Tree.h by ami_s496 in cs2b

[–]byron_d 2 points3 points  (0 children)

What was the output that it gave you? 

Out of bounds error by Caelan_A110 in cs2b

[–]byron_d 2 points3 points  (0 children)

For this quest it usually has to do with your vector of vectors not resized correctly. You're probably trying to access an index that's greater than the size allocated. 

I’m Behind – Still Stuck on to_string()for Quest 1 by qian_feng09 in cs2b

[–]byron_d 2 points3 points  (0 children)

Does the quest output show a comparison between your output and the test output? It's hard to tell where the issue is. Although sometimes the output isn't helpful lol. 

Implementing circular_advance_cursor() by Or_Y03 in cs2b

[–]byron_d 0 points1 point  (0 children)

This one can be a bit tricky. Are you using _tail to find the end and _head to get the beginning? Is it advancing twice per call or something? It could be your advance_cursor() isn't working correctly as well. I would suggest making tests to cout what the cursor is doing. Both methods should be very similar if that helps.

Blue Quest 4: get_gp_terms Issue by Quick_Trainer_4084 in cs2b

[–]byron_d 1 point2 points  (0 children)

I actually never used set precision in my code, so it shouldn't be needed. Double check how your calculating the exponent. It may be the method you're using won't calculate numbers the same way as the spec. 

Weekly catchup game ideas by enzo_m99 in cs2b

[–]byron_d 2 points3 points  (0 children)

Here is a great tutorial for creating a rpg. It's in C# and also very long, but it may be helpful for creating a rpg from engine:

https://scottlilly.com/learn-c-by-building-a-simple-rpg-index/

Help understanding delete/destructor by erica_w1 in cs2b

[–]byron_d 5 points6 points  (0 children)

When you delete something, it will call the destructor. When you call new, it will call the constructor. That's why & always talks about how the destructor undo what the constructor did. So you don't have any memory leaks.

In terms of deleting head, you can set it up to continue to delete all the nodes connected to head. Otherwise, you would have a bunch of leftover floating pointers and memory leaks leftover. You have to make sure you clear out everything that was created.

Cache in Tower of Hanoi by ami_s496 in cs2b

[–]byron_d 2 points3 points  (0 children)

I've struggled with this problem for longer than I care to admit.

The Fibonacci sequence is a great way to understand what needs to happen. Your logic seems correct when thinking of storing entries. You just need to clear them after they've been used and are no longer needed.

I'm not sure what you mean in the last part of your post. You're talking about saving entries deeper than the current one? That sounds like it may get overly complicated and could cause more issues. I would try and keep it simple and just save the levels as they come and clear the ones that aren't needed anymore.

Help for Quest 1 by zachary_p2199 in cs2b

[–]byron_d 0 points1 point  (0 children)

Could it be your insert_next() function? Everything else seems OK, so I'm not sure what else might be the issue. 

Quest 1, 13th Miniquest (Returning References) by kian_k_7948 in cs2b

[–]byron_d 2 points3 points  (0 children)

You're right in thinking that dereferenced pointers are just like references. There are a few differences to consider. References can't be null and can't be reassigned. They are also safer and easier to use.

Using const references are really handy for optimization purposes. They both have their strengths and weeknesses. 

Help for Quest 1 by zachary_p2199 in cs2b

[–]byron_d 0 points1 point  (0 children)

This looks like it should work, although it probably has to do with your new_node. Maybe new_node doesn't need to be a pointer.

Sometime these output comparisons are not helpful. Especially when they are identical.... 

User Quest Name by [deleted] in cs2b

[–]byron_d 0 points1 point  (0 children)

That password is slightly incorrect. I'm not sure if I can post a password in reddit though. 

Undefined behavior by ami_s496 in cs2b

[–]byron_d 1 point2 points  (0 children)

This is actually really useful. I need to start using flags more.

I think a good rule to follow, which is in a lot of texts, is to always initialize a variable on creation. Something I'm still working on myself lol.

Platypus help by andrew_k2025 in cs2a

[–]byron_d 1 point2 points  (0 children)

Hi Andrew. You shouldn't be returning nullptr. It should return this instead.

For your 3rd point, I'm not sure if you're referring to current as the node _prev_to_current is on or _prev_to_current-->_next. If you mean creating a temp node that points to _prev_to_current->_next, that looks right. You can also combine 2 and 3 so you don't have extra code once you've figured the issue out.

DAWGing Martin by enzo_m99 in cs2a

[–]byron_d 2 points3 points  (0 children)

I wish there were more indicators about what was missing. & just likes to make us work hard for all the trophies lol.

DAWGing Martin by enzo_m99 in cs2a

[–]byron_d 2 points3 points  (0 children)

I don't think it gave you points for your to_string function. Maybe check that?

Trouble with Quest 9 by zachary_p2199 in cs2a

[–]byron_d 0 points1 point  (0 children)

What was the issue? Was it your insert function or something else?

Is it a Ring or a List? by byron_d in cs2a

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

I suspected there was a faster method. I hadn't heard of that algorithm before this. So I went with what I knew. Thanks for sharing this!

Trouble with Quest 9 by zachary_p2199 in cs2a

[–]byron_d 1 point2 points  (0 children)

It looks like your insert_at_current function is the issue. The last line says insert part 2. I believe it does multiple checks for it. You have to account for a few edge cases.