|
|
|
|
|
by level3
3619 days ago
|
|
As a golfer, that code would have already been golfed down to: num.to_s.chars.map &:hex So digits only saves 14 characters (22 if reverse is really necessary). But usually we would actually be doing something with the digits instead of just getting them, so the method may save even less. For example, for finding digit sums, the new digits and sum methods give us the efficient: num.digits.sum But for numbers up to 5 digits (or digit sums up to 47) we can already do: num.to_s.sum%48 which is just 1 character longer. |
|