Anishluke92 / RubySolution

Problem solving using Ruby programming language
0 stars 1 forks source link

Percentage of Box Filled In #1

Closed danielpaul closed 3 years ago

danielpaul commented 4 years ago

Create a function that calculates what percentage of the box is filled in. Give your answer as a string percentage rounded to the nearest integer.

Examples

percent_filled([
  "####",
  "#  #",
  "#o #",
  "####"
]) ➞ "25%"

# One element out of four spaces.

percent_filled([
  "#######",
  "#o oo #",
  "#######"
]) ➞ "60%"

# Three elements out of five spaces.

percent_filled([
  "######",
  "#ooo #",
  "#oo  #",
  "#    #",
  "#    #",
  "######"
]) ➞ "31%"

# Five elements out of sixteen spaces.

Notes