Skip to content
Discussion options

You must be logged in to vote

Hi @code-chai,

Thanks for the kind words! This exercise is a little tricky (and probably not a great fit for an awk one-liner haha)

If I modify your code to output the denominator, I see it's always 4234, whereas we want the denominator to be different for every burrito, since we want to know the percentage of burritos of each type that contain guac (i.e. denom will also need to be an array).

awk -F "\t" '\
{if($3 ~/Burrito/ && $4 ~/Guacamole/) counts[$3] += 1;\
else denom += 1}\
END {for(k in counts) print(k, denom)}' orders.tsv

Steak Burrito 4234
Veggie Burrito 4234
Barbacoa Burrito 4234
Chicken Burrito 4234
Burrito 4234
Carnitas Burrito 4234

Also, you'll want to always increment the d…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Answer selected by robertaboukhalil
Comment options

You must be logged in to vote
1 reply
@cnzed99
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants