golfathon/cell-voronoi
2024-06-03 14:16:32 +00:00
..
a.cpp More solutions 2024-06-03 14:16:32 +00:00
a.in More solutions 2024-06-03 14:16:32 +00:00
a.out More solutions 2024-06-03 14:16:32 +00:00
b.in More solutions 2024-06-03 14:16:32 +00:00
README Do the golfathon in a 1777 folder instead of over Git 2024-06-02 20:18:06 +00:00

// inspired by gpn-tron

## Rule Part 1

On a uniform 2D grid, where distance is calculated by taxicab distance (normal snake game moves)
For every grid point, the capital letter (snake head) that is closest to it owns it.
In case of a tie, no one owns that grid point.

The grid is rectangular.

## Problem Statement 1 

Given the grid size, and the coordinates of each capital letter,
calculate for each capital letter, how many grid points does it own.

## Example 1

Below, you have a 3x1 grid. `.` is an empty grid point.

A . B

A and B are on grid points.

A and B each own 1 grid point.

The middle grid point has a tie, so it is owned by no one.

### input
3 1
2
A 0 0
B 2 0

### output
A 1
B 1

## Example 2

Below, you have a 4x1 grid.

A . . B

A and B are on grid points.

A and B each own 2 grid point.

### input
4 1
2
A 0 0
B 3 0

### output
A 2
B 2

## Rule Part 2

As it turns out, the grid wraps around like a torus.

The Problem remains the same.

## Rule Part 3

Oh now we have walls. Distance calculation becomes a bit tricky here. Distance calculations don't go through walls.

`#` represent walls.

A # .
. # B
. . .

### input
3 3
4
A 0 0
B 2 1
# 1 0
# 1 1

### output
A 2
B 2


For your viewing pleasure:

A # .
. # B
a . b

## Checking your answers
idk. i don't have ready-to-be-used examples.
if you write a random grid layout generator, edit this section to mention it.
if the grid is as small as 5x5, you can count the numbers by hand. that's how i can verify my algorithms.