awk-hack-the-planet icon indicating copy to clipboard operation
awk-hack-the-planet copied to clipboard

make solutions more compact

Open setop opened this issue 2 years ago • 2 comments

  • variable are implicitly initialized to 0 or ""
  • NR == 1 represents the header line

setop avatar Apr 12 '23 11:04 setop

Awesome solutions. The changes look great! However, since this repository is geared towards learners, I appreciate the more verbose nature of the current version in master to provide additional context and clarity.

For some of the advanced solutions I would need more explanation :D

I also appreciate your solution for 16b (median, "extra credit"), which -- despite incomplete definition, has the correct solution in this case. You get the number of values plus the header which works for an uneven number of values, however, for an even number of values n you would have take the average of the middle numbers: (value[n/2] + value[(n/2)+1] )/2 It's up for discussion if it's enough to have the solution for the data at hand or if a general solution is needed. IMO it's better to have an incomplete solution than none at all ;)

fxj9a avatar Apr 12 '23 23:04 fxj9a

Thanks for the reply.

However, since this repository is geared towards learners, I appreciate the more verbose nature of the current version in master to provide additional context and clarity.

Totally agree.

For the story, I was looking for advanced AWK material when I come to this repo. AWK saved my life as an engineer so many times ...

For some of the advanced solutions I would need more explanation

Sure, with pleasure ! Which ones ?

however, for an even number of values n you would have take the average of the middle numbers

Ah, nerd trap ! Now I have to fix this :)

setop avatar Apr 14 '23 08:04 setop