Dave

Results 79 comments of Dave

Relax dude, this one is not easy. This is a **math** problem so forget about trying to solve it the same way you would solve a CS problem. Here's a...

^try spending a few days on above. You're very smart if you can solve it. If you're stuck still I'll give you another tip ;)

@foobar112358 what is your output for s = 20, h = 12, w = 12?

@foobar112358 it should be: 971953409253967307369509738307813402491316**79073592360856141700148734207997877978005419735822878768821088343977969209139721682171487959967012286474628978470487193051591840** You might be losing precision somewhere. This should help you determine where: 22300745198531341817894657615847583802746155678399565967993124561615436149415899871380763938002071429362749343044868906014253019900488985895312634973607213920301808604240055624427110400000 **divided by** 229442532802560000

@foobar112358 For 3x5 with 20 states your output is correct. I'll give you a few more samples for debugging purpose: ``` (4,4,20) -> 1137863754106723400 (5,5,20) -> 23301834615661488487765745000 (6,6,20) -> 132560781153101038829213988789736592649360...

Hi Shantanu, Are you submitting the code into Foobar or running it on your machine? I just ran it on compilejava.net with no problem. If you're submitting it to foobar...

I'm looking at the code right now and nothing comes to mind :) either I've changed something last minute before I submitted the code or they've changed their test cases....

There's no mention of the map being square on the description. Wouldn't matter either, how can you improve it if it's square only?

Yup, we can safely terminate if we get h+w. The algorithm is very similar to Djikstra, I'm traversing the graph once starting from (0,0) and once from (h,w), keeping a...

You can find all pairs with 20 difference in O(n): add them to both hash list & array, check if +-20 of each one is included in the hash. However...