Sha256: 4bf0f97105c0c5699999a53b5a8bc92e6253a1b3fd1652af5868dc18f83da6a6

Contents?: true

Size: 790 Bytes

Versions: 124

Compression:

Stored size: 790 Bytes

Contents

#include "queen_attack.h"

#define ROW_COUNT 8
#define COLUMN_COUNT 8

attack_status_t can_attack(position_t white_queen, position_t black_queen)
{
   if ((white_queen.column == black_queen.column
        && white_queen.row == black_queen.row) || white_queen.row >= ROW_COUNT
       || white_queen.column >= COLUMN_COUNT || black_queen.row >= ROW_COUNT
       || black_queen.column >= COLUMN_COUNT) {
      return INVALID_POSITION;
   }

   if (white_queen.column == black_queen.column ||
       white_queen.row == black_queen.row ||
       (white_queen.row - black_queen.row ==
        white_queen.column - black_queen.column)
       || (white_queen.row - black_queen.row ==
           black_queen.column - white_queen.column)) {
      return CAN_ATTACK;
   }

   return CAN_NOT_ATTACK;
}

Version data entries

124 entries across 124 versions & 1 rubygems

Version Path
trackler-2.2.1.180 tracks/c/exercises/queen-attack/src/example.c
trackler-2.2.1.179 tracks/c/exercises/queen-attack/src/example.c
trackler-2.2.1.178 tracks/c/exercises/queen-attack/src/example.c
trackler-2.2.1.177 tracks/c/exercises/queen-attack/src/example.c
trackler-2.2.1.176 tracks/c/exercises/queen-attack/src/example.c
trackler-2.2.1.175 tracks/c/exercises/queen-attack/src/example.c
trackler-2.2.1.174 tracks/c/exercises/queen-attack/src/example.c
trackler-2.2.1.173 tracks/c/exercises/queen-attack/src/example.c
trackler-2.2.1.172 tracks/c/exercises/queen-attack/src/example.c
trackler-2.2.1.171 tracks/c/exercises/queen-attack/src/example.c
trackler-2.2.1.170 tracks/c/exercises/queen-attack/src/example.c
trackler-2.2.1.169 tracks/c/exercises/queen-attack/src/example.c
trackler-2.2.1.167 tracks/c/exercises/queen-attack/src/example.c
trackler-2.2.1.166 tracks/c/exercises/queen-attack/src/example.c
trackler-2.2.1.165 tracks/c/exercises/queen-attack/src/example.c
trackler-2.2.1.164 tracks/c/exercises/queen-attack/src/example.c
trackler-2.2.1.163 tracks/c/exercises/queen-attack/src/example.c
trackler-2.2.1.162 tracks/c/exercises/queen-attack/src/example.c
trackler-2.2.1.161 tracks/c/exercises/queen-attack/src/example.c
trackler-2.2.1.160 tracks/c/exercises/queen-attack/src/example.c