percolate_fill: Board Percolation Single Iteration

Description Usage Arguments Value Examples

View source: R/percolate.R

Description

For each entry on the current board, percolate a single step (up, down, left, right) if the entry contains water. This is a helper function of percolate.board

Usage

1
percolate_fill(curr_board)

Arguments

curr_board

A board with the latest board state.

Value

An updated board by performing a single percolation step on each entry of the inputted board. If no more water could be filled into the board, the returned board should be identical to the inputted board.

Examples

1
2
3
4
5
6
7
curr_result_board <- board()
updated_result_board <- percolate_fill(curr_result_board)
if (sum(updated_result_board != curr_result_board) == 0){
   cat("Percolation completed!")
} else {
   cat("More percolation steps required to fill the board!")
}

lilinhonglexie/percolate documentation built on Nov. 4, 2019, 4:32 p.m.