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.159 tracks/c/exercises/queen-attack/src/example.c
trackler-2.2.1.158 tracks/c/exercises/queen-attack/src/example.c
trackler-2.2.1.157 tracks/c/exercises/queen-attack/src/example.c
trackler-2.2.1.156 tracks/c/exercises/queen-attack/src/example.c
trackler-2.2.1.155 tracks/c/exercises/queen-attack/src/example.c
trackler-2.2.1.154 tracks/c/exercises/queen-attack/src/example.c
trackler-2.2.1.153 tracks/c/exercises/queen-attack/src/example.c
trackler-2.2.1.152 tracks/c/exercises/queen-attack/src/example.c
trackler-2.2.1.151 tracks/c/exercises/queen-attack/src/example.c
trackler-2.2.1.150 tracks/c/exercises/queen-attack/src/example.c
trackler-2.2.1.149 tracks/c/exercises/queen-attack/src/example.c
trackler-2.2.1.148 tracks/c/exercises/queen-attack/src/example.c
trackler-2.2.1.147 tracks/c/exercises/queen-attack/src/example.c
trackler-2.2.1.146 tracks/c/exercises/queen-attack/src/example.c
trackler-2.2.1.145 tracks/c/exercises/queen-attack/src/example.c
trackler-2.2.1.144 tracks/c/exercises/queen-attack/src/example.c
trackler-2.2.1.143 tracks/c/exercises/queen-attack/src/example.c
trackler-2.2.1.142 tracks/c/exercises/queen-attack/src/example.c
trackler-2.2.1.141 tracks/c/exercises/queen-attack/src/example.c
trackler-2.2.1.140 tracks/c/exercises/queen-attack/src/example.c