#Queen Atack
53 messages · Page 1 of 1 (latest)
Hello 👋
If you post the code, you already wrote, in a code block it is much, much easier to read 😉
FYI: Code blocks are 3x backticks before and after the code
what??😭
If you have code you can paste it like this
int a = 5
by wrapping the text in 3x backticks (one set of 3 before and one set of 3 after the text)
I do not see the contribution with the error of my code 😅
Increase your chance of getting help and look like a pro by sharing codeblocks not images. For example, you can type the following. Note, the ``` must be on their own line.
```
for number in range(10):
total += number;
```
Discord will render that as so:
for number in range(10):
total += number;
Click here to learn more about codeblocks, including how to indicate the programming language: https://exercism.org/docs/community/being-a-good-community-member/writing-support-requests and http://bit.ly/howto-ask
There are people here using screen readers who cannot view images
See if you post the code just as a screenshot I'd have to make a ton of assumptions what your code does. Like which values the constants have and such. If you paste the entire code it is much easier to find out what went wrong 🙂
It's also pretty hard to copy/paste your code to test it out when it's an image 😉 Code is text. Share text as text
And, preferably, the whole file
attack_status_t can_attack(position_t queen_1, position_t queen_2) {
if (queen_1.row > 7 || queen_1.column > 7 || queen_2.row > 7 || queen_2.column > 7) {
return INVALID_POSITION;
}
int diff_row = (int)queen_1.row - (int)queen_2.row;
int diff_column = (int)queen_1.column - (int)queen_2.column;
if (diff_row < 0) diff_row = -diff_row;
if (diff_column < 0) diff_column = -diff_column;
if (queen_1.row == queen_2.row || queen_1.column == queen_2.column || diff_row == diff_column) {
return CAN_ATTACK;
} else {
return CAN_NOT_ATTACK;
}
} ```
If you apply the formating via code blocks the discord formating of || won't make spoilers 🙂
Can you edit your last post and put a ``` before and after your code, @eager flare ?
like that*
Yes! Thank you. Could you also share the header file?
The code references values not defined in the file 🙂
#define QUEEN_ATTACK_H
#include <stdint.h>
typedef enum { CAN_NOT_ATTACK, CAN_ATTACK, INVALID_POSITION } attack_status_t;
typedef struct {
uint8_t row;
uint8_t column;
} position_t;
attack_status_t can_attack(position_t queen_1, position_t queen_2);
#endif
Awesome. How about the failing test details, also in a codeblock?
test 1:Test Failure
Expected 2 Was 1
Your Output
./
Cool. Do you understand that Expected line?
he wants CAN_ATTACK to return 2 while the one returns 1
this corresponds to the value in my enum attack_status_t
Right
So ... do you understand what's wrong here?
The test name has a hint as to what is being tested
yes it sent CAN_NOT_ATTACK back instead ofCAN_ATTACK
What's 1 and 2 in the enum?
Apart from what Isaac is saying, another hint is to look at the name of the failing test. It usually specifies what is being tested.
ow, Isaac already said that 🙂
@eager flare ?
yes but I really don’t see the mistake
What's 1 and 2 in the enum?
CAN_NOT_ATTACK, CAN_ATTACK
That sounds more correct
So what is the test expecting and what is your code returning?
I have to get back :iNVALID_POSITION and my code return :CAN_ATTACK
Right. Did you see the test name? Do you understand what case is being tested and why it is invalid?
Yess I understand
No 🦧🦧
I have to get back :iNVALID_POSITION and my code return :CAN_ATTACK
- Do you understand what is being tested?
- Do you understand why
iNVALID_POSITIONis the expected value? - Do you understand why your code returns
CAN_ATTACK?
I know why but I don't see the error in my code
The name of the failing test is "invalid_if_on_same_position"
You understand all three of those?
Why do the tests expect invalid? Why doesn't the code return invalid? Can you fix that?
I understood what was asked of me, but I don't see where the mistake is.
