waterflow: Solve the Waterflow Problem

Description Usage Arguments Details Examples

Description

This R6 Class provides methods to calculate the total number of squares which will fill with water and to plot the walls and filled valleys.

Usage

1
2
3
4
  p <- waterflow$new(wall = NULL)
  p$total()
  p$plot()
  p$print()

Arguments

p

A waterflow object.

wall

A numeric vector of wall heights

Details

$new() calculates the amount of water the valleys will be filled with.

$total() returns the total amount of water the valleys will be filled with.

$plot() plots the walls filled with water.

$print() returns the data.frame of wall and water heights.

Examples

1
2
3
4
5
x <- c(2, 5, 1, 2, 3, 4, 7, 7, 6)
p <- waterflow$new(x)
p$total()
p$plot()
p$print()

nathaneastwood/waterflow documentation built on May 18, 2019, 9:18 p.m.