forked from ShunxiWu/flood-fill
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreadme.txt
59 lines (45 loc) · 1.62 KB
/
readme.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# Flood Fill Algorithm
This project implements a Flood Fill algorithm in Python. The algorithm replaces old values with new values through a flood filling process, starting from the specified coordinates.
## Getting Started
These instructions will help you get a copy of the project up and running on your local machine.
### Prerequisites
- Python 3.x
### Installation
1. Clone the repository to your local machine.
2. Change your directory to the project folder.
### Usage
To use the Flood Fill algorithm, you can call the `flood_fill` function with the following parameters:
- `input_board`: A list of strings representing the initial board.
- `old`: The value to be replaced.
- `new`: The value that replaces the old.
- `x`: The X-coordinate of the flood start point.
- `y`: The Y-coordinate of the flood start point.
Example usage:
```python
from typing import List
# Define the board
board = [
"......................",
"......##########......",
"......#........#......",
"......#........#......",
"......#........#####..",
"....###............#..",
"....#............###..",
"....##############....",
]
# Call the flood_fill function
modified_board = flood_fill(input_board=board, old=".", new="~", x=5, y=12)
# Print the modified board
for row in modified_board:
print(row)
Expected Output
The above code will replace all occurrences of . with ~ through the flood filling process, starting from the specified coordinates.
......................
......##########......
......#~~~~~~~~#......
......#~~~~~~~~#......
......#~~~~~~~~#####..
....###~~~~~~~~~~~~#..
....#~~~~~~~~~~~~###..
....##############....