Proof You Can Become a Better Programmer
new2code.com
Proof You Can Become a Better Programmer
1–10 of 26 posts
Re: Proof You Can Become a Better Programmer
#2I slightly prefer the 'worse' solution for the second problem, at least in terms of substance, not necessarily style. The trick the 'improved' version does with uniq seems a little hacky to me, somehow.
The first problem has a clear improvement.
I just checked ruby doc and 'reduce' and 'inject' seem to be synonyms, as far as I can tell.
Re: Proof You Can Become a Better Programmer
#3in another two years you will be back to writing stupidly simple code again. Because it often perform better and is easier to maintain.
Re: Proof You Can Become a Better Programmer
#4Has someone ever said you can't improve as a programmer? I might live in a bubble of positivism, but I don't think I've ever heard that a programmer can't improve.
Re: Proof You Can Become a Better Programmer
#5What on earth does he mean by saying that "the reduce method [instead of inject] is performance friendly and a more "Ruby way" of doing things"? `reduce` is an alias for `inject`...
Re: Proof You Can Become a Better Programmer
#6I've never used Ruby before, but I learned something interesting when Googling what I thought was a weakness in his preferred solution to the first problem: Apparently, in Ruby, integer types have two internal representations that are flexibly switched between as needed. One representation uses a fixed size (analogous to long/int64 in other languages) and the other representation, Bignum, has an arbitrary size (analogous to Java's BigDecimal). So the simple (1..n).reduce(:lcm) approach should work for n of arbitrary size, though I don't think it's the most efficient approach.
Re: Proof You Can Become a Better Programmer
#7Here is a recipe for a successful shitpost on hacker news:
1. Write a blog post about your experience with X. Your description shall not be complete nor correct.
2. Wrap it around with a thesis on a random topic, which is semi-related to your experience, and which is by no means proven by your description.
3. ??
4. profit!
Re: Proof You Can Become a Better Programmer
#8What on earth does he mean by saying that "the reduce method [instead of inject] is performance friendly and a more "Ruby way" of doing things"? `reduce` is an alias for `inject`...
Based on the linked github page[1], it looks like that comment was an extrapolation from a guideline in Airbnb's Ruby Style Guide, where Airbnb prefers the use of `reduce` instead of `inject`:
- Prefer `reduce` over `inject`.
I haven't seen any other evidence to show reduce is more performance friendly.
Re: Proof You Can Become a Better Programmer
#9I'd love to see more on how he manages his "to learn" pile using Evernote. My current strategy is to let things I want to read live in open browser tabs until my browser crashes. Rinse & repeat.
Re: Proof You Can Become a Better Programmer
#10Problem 2 is underspecified so both answers might be wrong. Should the output on the string "aaaabbbaa" be "a4b3a2" or "a6b3"? Or is that invalid input? I don't think you can reasonably answer the problem without an example like this.