Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sidjey-y/bomb-and-bills
The "Bombs and $100 Bills" problem is a grid-based puzzle where the objective is to maximize the number of $100 bills saved before bombs explode. The grid is an n x m matrix where each cell either contains a bomb (B) or a number from 1 to 9, representing the number of $100 bills in that cell.
https://github.com/sidjey-y/bomb-and-bills
Last synced: 6 days ago
JSON representation
The "Bombs and $100 Bills" problem is a grid-based puzzle where the objective is to maximize the number of $100 bills saved before bombs explode. The grid is an n x m matrix where each cell either contains a bomb (B) or a number from 1 to 9, representing the number of $100 bills in that cell.
- Host: GitHub
- URL: https://github.com/sidjey-y/bomb-and-bills
- Owner: sidjey-y
- Created: 2024-08-27T17:01:15.000Z (4 months ago)
- Default Branch: main
- Last Pushed: 2024-08-27T17:15:15.000Z (4 months ago)
- Last Synced: 2024-11-08T02:38:20.537Z (about 2 months ago)
- Language: C++
- Homepage:
- Size: 838 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Bombs and $100 Bills
## Overview
The "Bombs and $100 Bills" problem is a grid-based puzzle where the goal is to maximize the number of $100 bills saved before bombs explode. Each cell in the grid either contains a bomb or a number representing the number of $100 bills. When a bomb explodes, it incinerates all bills in its row and column. You can perform a limited number of swaps to optimize the number of bills saved.
## Problem Statement
Given an `n x m` grid with bombs and $100 bills, and a maximum of `k` swaps allowed:
- Each cell contains either a bomb (`B`) or a number from `1` to `9`, representing the number of $100 bills.
- Bombs incinerate all bills in their row and column when they explode.
- You are allowed to swap the positions of the bills up to `k` times to maximize the number of $100 bills saved.### Input
The input will be read from a file. The first line of the file contains:
- Three integers: `n`, `m`, and `k`:
- `n`: Number of rows
- `m`: Number of columns
- `k`: Maximum number of allowed swapsThe following `n` lines contain `m` characters each, representing the grid.
## How It Works
1. **Identify Safe Cells**: Determine cells that are not in the same row or column as any bomb.
2. **Calculate Initial Value**: Sum the values of $100 bills in safe cells.
3. **Optimize with Swaps**: If `k > 0`, strategically swap bill values to maximize the total saved before bombs explode.