The road from Roosevelt Arch to Mammoth teems with animals, but you can only see some of them. You can only see animals that are surrounded by grass and only those animals that are taller than the grass around them. There are some animals you can never see, because they blend into the grass.
You can see elk, bison, wolves, pronghorn, moose, cranes, and bears. You can’t see any other animals, like bobcats and coyotes.
A single input string describes all the animals and their surroundings. The input string contains strings like this:
Surroundings (examples):
(grass,14)
Grass that is 14 inches high.(tree)
or (tree,25)
A tree.(rock)
or (rock,5)
A rock.Animals (examples):
(elk,65)
An elk that is 65 inches high.(bison,60)
A bison that is 60 inches high.(wolf,30)
A bison that is 60 inches high.(pronghorn,48)
A pronghorn that is 48 inches high.(moose,72)
A moose that is 72 inches high.(crane,36)
A crane that is 36 inches high.(bear,40)
A bear that is 40 inches high.(bobcat,18)
A bobcat that is 18 inches high.For example, you can see these animals:
(grass,14)(bison,40)(grass,36)
: The bison is surrounded by grass, and the bison is taller than all the grass.(grass,44)(moose,72)(grass,60)
: The moose is surrounded by grass, and the moose is taller than all the grass.For example, you can’t see these animals:
(grass,15)(wolf,30)(tree)
: The wolf is not surrounded by grass.(grass,10)(coyote,20)(grass,15)
: You can’t see coyotes.(grass,48)(crane,30)(grass,25)
: The crane isn’t taller than all the grass that surrounds it.In this example input, you a see a bison and a moose:
(tree,21)(rock,35)(grass,28)(rock)(bobcats,37)(tree)(grass,36)(rock,30)(tree,31)(tree)(otter,39)(tree)(tree,6)(rock,27)(tree,38)(grass,9)(moose,27)(grass,24)(rock,47)(tree,18)(rock,31)(tree)(sheep,28)(rock)(grass,43)(rock,43)(tree,18)(rock)(bobcats,39)(rock)(rock,30)(grass,42)(grass,7)(rock)(coyote,23)(rock)(tree,26)(grass,23)(tree,20)(tree)(bear,27)(tree)(rock,29)(rock,31)(grass,29)(tree)(crane,47)(grass,6)(grass,14)(grass,36)(grass,27)(grass,32)(sheep,47)(tree)(grass,34)(grass,8)(grass,20)(grass,17)(bison,44)(grass,43)(grass,8)(grass,26)(rock,39)(tree,15)(tree,14)
How many animals can you see?Copyright 2022 Robin A. Reynolds-Haertle