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.119 tracks/c/exercises/queen-attack/src/example.c
trackler-2.2.1.118 tracks/c/exercises/queen-attack/src/example.c
trackler-2.2.1.117 tracks/c/exercises/queen-attack/src/example.c
trackler-2.2.1.116 tracks/c/exercises/queen-attack/src/example.c
trackler-2.2.1.115 tracks/c/exercises/queen-attack/src/example.c
trackler-2.2.1.114 tracks/c/exercises/queen-attack/src/example.c
trackler-2.2.1.113 tracks/c/exercises/queen-attack/src/example.c
trackler-2.2.1.111 tracks/c/exercises/queen-attack/src/example.c
trackler-2.2.1.110 tracks/c/exercises/queen-attack/src/example.c
trackler-2.2.1.109 tracks/c/exercises/queen-attack/src/example.c
trackler-2.2.1.108 tracks/c/exercises/queen-attack/src/example.c
trackler-2.2.1.107 tracks/c/exercises/queen-attack/src/example.c
trackler-2.2.1.106 tracks/c/exercises/queen-attack/src/example.c
trackler-2.2.1.105 tracks/c/exercises/queen-attack/src/example.c
trackler-2.2.1.104 tracks/c/exercises/queen-attack/src/example.c
trackler-2.2.1.103 tracks/c/exercises/queen-attack/src/example.c
trackler-2.2.1.102 tracks/c/exercises/queen-attack/src/example.c
trackler-2.2.1.101 tracks/c/exercises/queen-attack/src/example.c
trackler-2.2.1.100 tracks/c/exercises/queen-attack/src/example.c
trackler-2.2.1.99 tracks/c/exercises/queen-attack/src/example.c