# Cave

> Shade the rock around one connected cave; each number counts the cave cells it can see.

Also called: Corral, Bag

Kind of puzzle: Shading

Web page: https://inkit.games/puzzles/cave

## Origin

Gesaku invented it as Bag, a loop puzzle that first ran in Nikoli's magazine in 1996 and is called Corral in English, and Cave is the same puzzle solved by shading.

## Credit

- Inventor: Gesaku (1996)
- Popularized by: Nikoli
- Source: [WPC wiki](https://wpcunofficial.miraheze.org/wiki/Cave)

## Rules

1. The white cells form one connected cave.
   - ✓ Right: One cave
   - ✗ Wrong: Cut in two
2. Every group of shaded cells touches the edge of the grid.
   - ✗ Wrong: Rock floats inside
3. A number counts the white cells it can see along its row and column, itself included. Shaded cells block the view.
   - ✓ Right: Sees 4
   - ✗ Wrong: Doesn't see 5

## Worked example: Grotto

A 6×6 Cave puzzle, with exactly one solution.

The givens, as inkit's puzzle engine writes them (cells are [row, column] from 0 at the top left):

```json
[{"at":"cell","cell":[3,3],"kind":"number","value":3},{"at":"cell","cell":[0,0],"kind":"number","value":7},{"at":"cell","cell":[4,2],"kind":"number","value":4},{"at":"cell","cell":[3,4],"kind":"number","value":7},{"at":"cell","cell":[1,5],"kind":"number","value":3},{"at":"cell","cell":[4,1],"kind":"number","value":4},{"at":"cell","cell":[0,2],"kind":"number","value":7},{"at":"cell","cell":[5,4],"kind":"number","value":7},{"at":"cell","cell":[1,2],"kind":"number","value":2}]
```

The solution, a line per row (`#` is a marked cell (shaded, or whatever this type places in a cell), `.` is left empty):

```
......
.#.#..
####.#
###..#
#....#
####..
```

Play it: https://inkit.games/g/cave-1

## Playing on inkit

Tap a cell to shade it, again for a dot (cave), again to clear.
