The goal of the exercise is to write a program that generates a report given a CSV file.
The CSV file has the following columns: website, impressions, revenue
- impressions: number of times an ad has been displayed on the website
- revenue: total revenue generated by the impressions on the website
The user of the program wants to see:
- the website with the highest impressions
- the website with the highest revenue
- the website with the highest cpm (1)
- the cpm (1) for each website, rounded to 2 decimals, sorted by cpm in descendant order
(1) cpm is the cost per thousand impressions (technically, “cost per mille”). cpm = (revenue / impressions) * 1000
The class of the program must output the report formatted in plain text, followed by the report in HTML
bash $> gem install csv
bash $> ruby solution.rb
##############
# PLAIN TEXT #
##############
*** Winners ***
The website with the highest revenue is: ubuntu.com
The website with the highest impressions is: microsoft.com
The website with the highest cpm is: google.com
*** cpm ***
- google.com: 0.56
- ubuntu.com: 0.18
- microsoft.com: 0.1
- apple.com: 0.09
########
# HTML #
########
<h1>Winners</h1>
<ul>
<li>The website with the highest revenue is: ubuntu.com</li>
<li>The website with the highest impressions is: microsoft.com</li>
<li>The website with the highest cpm is: google.com</li>
</ul>
<h1>cpm</h1>
<ul>
<li>google.com: 0.56</li>
<li>ubuntu.com: 0.18</li>
<li>microsoft.com: 0.1</li>
<li>apple.com: 0.09</li>
</ul>