DMPG '15 B3 - Picking Berries

View as PDF

Submit solution

Points: 3 (partial)
Time limit: 2.0s
Memory limit: 32M

Author:
Problem type

Bob sees a bush with some delicious looking berries beside his campsite. Unfortunately, he never goes outside, and can't tell leaves and berries apart, let alone edible berries and poisonous ones. He wishes to pick all the edible berries, and as a courteous gesture, pick all the poisonous ones too so nobody accidentally eats them. Can you help him?

Bob likes representing things visually. Each bush can be represented by some ASCII characters. with a # representing a leaf, an o representing an edible berry, and a * representing a poisonous berry. A space indicates that neither a leaf or berry is present. Help Bob pick the berries by replacing the berries in the bush with a space.

Input Specification

The first line will contain two integers W (1 \le W \le 100) and H (1 \le H \le 100), separated by a space, which will represent the width and height of the bush respectively. The next H lines will contain W characters that represent the bush. Leading and trailing spaces will be given so that every line is W characters long.

Output Specification

The first H lines will contain W characters, an ASCII representation of the picked bush. Leading and trailing spaces should be printed. This will be followed by another line with all of the edible berries from the bush.

Sample Input

8 4
  #o##  
 #*##*# 
##o##o##
 ###### 

Sample Output

  # ##  
 # ## # 
## ## ##
 ###### 
ooo

Comments

There are no comments at the moment.