[cs615asa] Wrong Answers

Zhitao Chen zchen69 at stevens.edu
Fri Apr 6 19:22:36 EDT 2018


I cannot open the link(
http://ec2-54-145-67-75.compute-1.amazonaws.com/cgi-bin/hw5-1.cgi) to
submit answer now, is there anyone has the same problem?

On Fri, Apr 6, 2018 at 6:04 PM, Jan Schaumann <jschauma at stevens.edu> wrote:

> Since I want to avoid all of you wasting time, here are the answers that
> I came up with.  You can use those as a basis to check your method (many
> other ways of finding the answers exist) or to discuss which one is the
> right answer:
>
> Jason G Ajmo <jajmo at stevens.edu> wrote:
>
> > 1:
> > # gzcat data.gz | grep "^en[\. ]" | wc -l
> >  2233318
>
> That's correct.  I don't know why I had the wrong answer, but chances
> are it has to do with me trying to reconstruct the assignment and ending
> up using a different dataset.  I'm sorry about that.
>
> FYI: You can save yourself a few extra processes by using a single grep
> command:
>
> zgrep -c "^en[\. ]" pagecounts-20160803-090000.gz
>
> > 2:
> > # gzcat data.gz | grep "^en[\. ]" | awk '{ print $2 " " $(NF - 1) }' |
> sort -nrk 2 | head -n 1
> > en 3127515
>
> I think that answer should be right, too.  I ended up doing:
>
> gzcat data.gz | awk '/^en[\. ]/ { print $(NF - 1) " " $0 }' | sort -n |
> tail -1
>
> By using / matching in awk, I'm avoiding an extra grep(1) process.  If
> you want, you can do the whole thing in awk, too, including the sorting
> and extraction, but it becomes less pipe-liney that way.
>
>
> For #3, I (now) ended up with:
>
> gzcat data.gz | awk '/^en[\. ]/ { sum += $NF; } END { print sum ; }'
>
> yielding '260243085755'.
>
>
> For #4:
>
> $ gzcat data.gz | awk '/^en[\. ]/ { sum += $(NF - 1); } END { print sum /
> 3600 ; }'
> 3256.12
>
> For #5:
>
> $ gzcat data.gz | awk '/^en[\. ]/ {s = $NF / $(NF - 1);
>         if (s > l) { l = s; largest = $2; }}
>         END { print largest; }'
> Module:Syrian_and_Iraqi_insurgency_detailed_map/doc
>
>
> The important lesson in this first part of the assignment is to always
> seek clarification, ask questions, and to not blindly trust that your
> instructor (or the test framework you are using, as which I function
> here) is necessarily correct.
>
> Keep that in mind for the second and third part of the assignment...
>
> -Jan
> _______________________________________________
> cs615asa mailing list
> cs615asa at lists.stevens.edu
> https://lists.stevens.edu/mailman/listinfo/cs615asa
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.stevens.edu/pipermail/cs615asa/attachments/20180406/504efc04/attachment.html>


More information about the cs615asa mailing list