1

I've finally completed my fifteen.c.

It can pass both 3x3.txt and 4x4.txt.

But something weird happened, can someone help?

enter image description here https://sandbox.cs50.net/checks/3c97d49e00f14d3e8f1abc1939419105 enter image description here

FullCode: https://gist.github.com/twdreamer/a996fa11852704d990c1

1 Answer 1

2

This is interesting! And possibly one of the most unique problems I've seen to date. Assuming that the error was in your code, I tried debugging it. I tried swapping my functions for yours into your overall program, and vice versa. I narrowed it down to the move() function, and it got interesting.

To make a long story short, I don't know if your move() function is good or bad (I didn't actually debug it), but then I had an idea. I added the following line to the top of my program, #include <math.h> and duplicated your result perfectly!

This is a unique case, in that I don't think there's a problem with your code (since move works fine when tested in the IDE), but I think that there's an adverse interaction between the math.h library and the check50 server environment.

In order to get your code to pass, you might want to rewrite your move() function in a way that doesn't require the math.h library.

If this answers your question, please click on the check mark to accept. Let's keep up on forum maintenance. ;-)

3
  • As Cliff said, there is a conflict between a definition in 2 libraries you've included. It appears you are using sqrt to come up with an absolute value difference. Know that the function abs() exists in stdlib.h that might do what you want.
    – curiouskiwi
    Commented Feb 23, 2016 at 19:12
  • Thanks for your answer. It kindof answer my confusion about the library issue. I've chosen another approach to solve this issue. i.imgur.com/CXdVF0x.png
    – TwDreamer
    Commented Feb 24, 2016 at 8:53
  • Not so unique now :) Got the same problem and the same solution acording to you instructions.
    – user11213
    Commented Apr 4, 2016 at 2:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .