Line Drawing Algorithm

Back to General discussions forum

simonhugo     2023-03-02 18:48:24
User avatar

I always get the answer: Your answer contains spaces. Perhaps some garbage in the output!

I have tried multiple input combinations in the ranges x1,x2: 0-255 and y1,y2 : 0-191 (horizontal, vertical, inclined in both directions with different angles), and I always get an answer without spaces and with a correct graphical representation.

zelevin     2023-03-02 21:48:55

What happens if you put a semicolon ; at the end of your print statement to tell the interpreter not to insert a newline?

simonhugo     2023-03-02 23:16:39
User avatar

With a semicolon at the end of the print command, what I get is a single line without blank spaces, and a correct graphical representation of the coordinates that I enter.

But the answer is always: "Your answer contains spaces. Perhaps some garbage in the output!"

zelevin     2023-03-02 23:27:58

With the semicolon, your output (and the code) looks correct to me. Not sure I can suggest anything else at the moment.

simonhugo     2023-03-03 13:29:00
User avatar

I already found the error. It has nothing to do with the displayed message. I realized when solving the "Circle Drawing Algorithm", that it indicated to me, here yes correctly, that the INT function is not allowed.

By removing the INT function from "coc=int(dec/16)", the program gives OK

Thank you, zelevin

simonhugo     2023-03-03 14:53:11
User avatar

But someone has had to touch something in the emulator.

Both programs (Line and Circle) have given ok when eliminating the cast to INT, and they gave an error with it.

However, I have now returned them to the emulator and without the cast to INT neither of them work. It's as if before the emulator was in integer arithmetic mode and someone has now changed the mode.

Please login and solve 5 problems to be able to post at forum