merely-useful / py-rse

Research Software Engineering with Python course material
http://third-bit.com/py-rse/
Other
247 stars 64 forks source link

Issue with exercise 3.8.7 #594

Closed sida-wang closed 3 years ago

sida-wang commented 3 years ago

Given titles.txt as

Sense and Sensibility,1811
Frankenstein,1818
Jane Eyre,1847
Wuthering Heights,1847
Moby Dick,1851
The Adventures of Sherlock Holmes,1892
The Time Machine,1895
Dracula,1897
The Invisible Man,1897

from exercise 3.8.5, options 3 and 4 (listed below) from exercise 3.8.7 give the same answer. Here the goal is to generate a frequency table of publishing year.

  1. cut -d, -f 2 titles.txt | uniq -c
  2. cut -d, -f 2 titles.txt | sort | uniq -c

However the solutions state that 3 is incorrect. The main issue here is that titles.txt is already sorted by year which means the sort in option 4 has no effect. Instead of updating the solution, it seems more appropriate to sort titles.txt alphabetically which would make option 3 incorrect.

DamienIrving commented 3 years ago

Thanks, @sida-wang! I like your suggestion of simply sorting titles.txt alphabetically. I've done that in #595.