That's absolutely not OOP, here ;) More like functional (except for the cache paart).
Overengineering is fun, yeah (I like that too). But one has to stay reasonnable. Reinventing a string iterator is pointless, for example (aka, exit gen_digits)
All programs have constraints on input. In this case, there can only be two distinct values in the array. We can certainly program a solution to return an array of any number of unique values; but that's a different problem and the solution to that problem will be less efficient when applied to this problem.
sqr
->sqr_as_str
gen_digits
)for juniors, to get known about new syntaxes and thoughts.
for seniors, to warm up and recap their knowledge at the start of the day.
for me, i used OOP method. im junior tho, but want to get used on OOP.
great answer. thank you
Because it wants you to return the first greatest word.
Use spoiler flag next time, please.
This comment is hidden because it contains spoiler information about the solution
All programs have constraints on input. In this case, there can only be two distinct values in the array. We can certainly program a solution to return an array of any number of unique values; but that's a different problem and the solution to that problem will be less efficient when applied to this problem.
this is python 2 code.
n/2
->n//2