15 Replies
And this is the main bfs function.
Why is it running slow? I know because it is actually an assessment and it is failing because of time limit exceeded.
Hmm, it was because of my "implementation" of the dummyQueue via list. I wonder why is it so slow though? There's not many items as the board is only 8x8. But it is significantly slower than the normal Queue class.
do you have a minimal reproduction that we can test?
Here is the main func
what does
bfs
stand for?Breadth-First Search
It's a modified Breadth-First Search algorithm to find shortest path for a KING on a board with given start, end and obstacles.
oh you have a syntax error here btw
or, not error
but a HUGE mistake
What's that?
you have a semicolon at the end of your last
if
which means the code in the block gets executed, no matter what the result of that evaluation isOh yea, I think I spotted that right after I copied it here, but somehow forgot to remove it here.
took me forever to find an issue, but here are my benchmark results;
i don't know if you're locked into .net framework for some reason, but if you're able, just upgrade to .net 7
Hmm, I used .NET Core 6.0
ah. you're not any modern features, that's why i assumed
But I see you made some nice optimalisations to my code which probably sped things up a lot.
Like the usage of hashset and Queue. I think the main problem in my app was that I "implemented" queue using the List<>
Where I did
.removeAt(0)
to pop an item from the list
That might have been the bottleneck<:think_eyes:879685758917701642>
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.