r/learnjava • • Sep 18 '20

Always use pen and paper when stuck with algorithm...

I've been days wasting my time trying to solve something easy as fuck just because I didn't use pen and paper to see things clearly. Consider this if you don't have a magic mind able to visualize Hell.

153 Upvotes

22 comments sorted by

3

u/xRageNugget Sep 18 '20

And don't forget to explain your probelm in detail to your rubberduck. Literally employee of the month

4

u/[deleted] Sep 18 '20

Feynman is proud.

24

u/oniicornn Sep 18 '20

This. I also like to do debugging on paper XD

9

u/potatopotaatopututu Sep 18 '20

When things aren't easy...replace the pen with pencil sharpener and eraser.

4

u/hugthemachines Sep 18 '20

I am sure it can work well. I like walking away from the screen. Sitting in complete silence or with something like trance music etc mapping out the flow in my head.

3

u/bananamadafaka Sep 18 '20

Absolutely. Drawing structures really helps.

2

u/UVJunglist Sep 18 '20

Spent a while trying to figure out why my queue methods weren't working and when I drew the nodes on a whiteboard it became obvious.

3

u/[deleted] Sep 18 '20

This can help depending on the situation. My usual approach is to break big problems down into smaller parts until they become simple ones.

7

u/[deleted] Sep 18 '20

That is programming 101, people don't do this?

1

u/[deleted] Sep 19 '20

You would be surprised. I've worked with many people over the years. Who have approached problems by sitting down with pen and paper and produced pages of flow charts. They then go on to write massively complex code that they don't fully understand, but kinda works.

1

u/haribharathi97 Sep 18 '20

When I’m having pen in my hand, ideas will come spontaneously.

1

u/LunarLorkhan Sep 18 '20

Ditto OP. I tend to get cocky and think I have a good idea of what I need to lay out but it’s easy to get lost in the code if you haven’t mapped out it’s entire scope logically. I’ll admit I can really struggle with abstraction and programming is nothing but abstraction, so being a visual learner and thinker, drawing it out is a big help for me.

1

u/[deleted] Sep 18 '20

agreed.

1

u/[deleted] Sep 18 '20

Good sentiment.

I have a huge whiteboard near my desk for exactly this reason.

1

u/Vertinova Sep 18 '20

Would you guys say this is okay to do during job interviews? (When a white board is not provided, such as virtual interviews)

3

u/Prince_John Sep 18 '20

I would ask, to be polite, but can't imagine demonstrating an analytical process could be taken negatively, as long as you keep explaining your thought process.

1

u/MkMyBnkAcctGrtAgn Sep 19 '20

Save trees, get a whiteboard

2

u/John_The_3rd Sep 26 '20

Don’t know if your being serious but assuming you are, paper is a renewable resource, and I would argue that one of the best things you could do to preserve forests is to by paper products because it provides a financial incentive to the paper companies to preserve the forests so they can keep selling you paper.

1

u/Vi0lentByt3 Sep 18 '20

All good code starts on paper

0

u/[deleted] Sep 18 '20

[deleted]

87

u/[deleted] Sep 18 '20

He wasted days trying to solve something easy as fuck because he didn't use a pen and paper.

11

u/oddwhirled Sep 18 '20

Quality comment

7

u/PabloDavico Sep 18 '20

I'm putting my bets on a dynamic programming algorithm