Skip to content

Instantly share code, notes, and snippets.

@mehdimehdi
Created January 17, 2014 22:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mehdimehdi/8482929 to your computer and use it in GitHub Desktop.
Save mehdimehdi/8482929 to your computer and use it in GitHub Desktop.
Histogram exercise
Build a command line tool which takes a CSV file-like input, and creates an histogram in ASCII
data = [(0,1),
(2, 4),
(4, 2),
(3, 3)]
Each row in the CSV is data which helps build the histogram. The first value is the column #, the second value is the value of bar in the histogram.
There can be more than one row for one column in the CSV
mehdi$ python histogram.py
*
**
***
* ***
01234<- no need to print this, but this is just to explain the columns
#for column 0, there is 1 star, which represent the value of (0,1) in the data list.
#for column 1, there are 0 stars, because there is no tupe (1,)
#for column 2, there are 4 stars, because there is (4,2) in the data list
#for column 3, there are 3 stars, because there is (3,3) in the data list
#for column 4, there are 2 stars, because there is (4,2) in the data list
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment