
Ask HN: Im a programmer who feels deficient at solving puzzles. How to improve? - UpMyAlgoGame
Hi HN,<p>I&#x27;ve been programming my whole life (and, professionally, for 6 years).<p>However, I feel very deficient in solving puzzles and algorithms.<p>The things I feel deficient at are problems that sound like: &#x27;given an array of prices for a certain stock in a single day, how would you find the maximum profit from one trade?&#x27;.<p>This manifests as being an excellent (even a &#x27;senior&#x27;) day-to-day programmer, but flunking during the hard parts of a technical coding interview like, say, at a Google interview.<p>What can I do to improve this area of my thinking? Are there any recommended &#x27;daily puzzle&#x27; or &#x27;school&#x27; sites that focus on this?<p>Thanks for your help!
======
Nadya
Create an example of your problem. Solve for specifics before variables. Then
generalize it and replace those specifics with variables. Skipping the first
step can be confusing because many people struggle to conceptualize abstract
data.

Studying algorithms and their use cases can be helpful as well:
[http://blog.notdot.net/tag/damn-cool-
algorithms](http://blog.notdot.net/tag/damn-cool-algorithms)

When you have to search something to solve it. Make sure you aren't searching
for the answer to solve the answer but are searching the answer to understand
the answer. Take some time to study the solution to your problem and make sure
you understand what it is doing and how it works so that next time a similar
problem arises you might be able to solve it because the solution worked for
you in the past.

------
CocaKoala
Solving project euler problems did a lot to teach me about efficient use of
algorithms and using algorithms to solve problems.

------
anigbrowl
_The things I feel deficient at are problems that sound like: 'given an array
of prices for a certain stock in a single day, how would you find the maximum
profit from one trade?'._

My naive answer to that is ignore the absolute prices, but iterate over the
array to get an array of price movements, and then weight those by volume data
(if that is available) or select the largest (if not). Could you expand on
what it is you find problematic about that sort of question, eg lay out what
your thought process is and where it gets blocked?

In terms of suggestions, maybe it would be worth your while considering
problems a bit outside the programming domain, and working on them someplace
other than your desk, on the theory that a change is as good as rest. Martin
Gardner's 'Mathematical Recreations' columns for Scientific American were
collected into one or more books, and I think some of Ian Stewarts' as well.
These are great because they comprise fairly abtruse problems along with a
discussion of strategies for dealing with them.

There are of course lots of 'math pouzzle of the week' sites from various
universities, and books of math puzzles. but you should definitely pick up
'How to solve it' by Georg Polya, which is considered a classic education
text. [http://www.amazon.com/How-Solve-It-Mathematical-
Princeton/dp...](http://www.amazon.com/How-Solve-It-Mathematical-
Princeton/dp/069111966X) This is over half a century old but it's a great
book, it's like having a patient mathematics teacher that wants to help you
succeed at your side. Again, study these things away from your desk - find
some other study space, even a park, and practice working with paper and in
your head. You will retain things better by changing your environment for
study.

Another thing that strikes me about your post is that your abilities are
affected by the situation - you feel confident of your ability to get things
done when allowed space to think, but you don't deal well with high-pressure
environments like interviews. This is normal. Build up a good idea of where
your intellectual strengths and weaknesses are and what your best strategies
for dealing with them are. Don't be afraid to say in an interview 'I'm good at
this sort of problem, I'm always slow at that sort so my first response will
be a few brain farts...' Remember too that in a good interview, you're not
just being rated for your raw intellectual ability, but on how you deal with
your limitations and how you go about decomposing a problem. Nobody knows
everything!

Lastly, don't assume you must do it in isolation. Maybe part of the stress at
interviews is not the questions themselves but the social context. If you can
afford it, consider hiring a graduate student in math or CS at a local
university to tutor you a few hours a week. A person with an academic leaning
will be better equipped to assess and direct your learning ability than
someone who is trying to solve the 'puzzle' of filling an open position at a
company and who can only provide limited feedback on your performance.

