Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I think "competitive" (i.e. solving algorithmic challenges for fun) coding really gives you some insight into how to write code that's short and to the point. The user with the most reputation on LeetCode, for example, consistently posts solutions that are surprisingly short, efficient, and readable.

https://discuss.leetcode.com/user/stefanpochmann

(some random examples)

https://discuss.leetcode.com/topic/18731/7-lines-c-c

https://discuss.leetcode.com/topic/16988/7-lines-3-easy-solu...

https://discuss.leetcode.com/topic/33430/6-lines-o-log-min-m...



Stefan Pochmann is also the inventor of two different methods for blindfolded Rubik's Cube solving. Classic Pochmann is a quite elegant solution as it effectively deals with one piece at a time, where previous methods generally separated orientation and permutation into separate steps, and deal with more pieces at once. M2 is 'tasty' in a different way - there are many more edge cases to handle but it replaces the 14-move swap sequence in Classic Pochmann with a single move. Perhaps I'm stretching a bit but it seems like an example of the same kind of thinking.

Side note - blindfold Rubik's Cube is way easier than you think. If you're a programmer and can already solve one sighted, I'd imagine you could learn Classic Pochmann in a week.


Well, I went over there, looked at the list of recently-active topics, and contributed exactly one boring solution to one of them. Now to never post there again.


The code might be short and to the point, but it definitely is not easy for me to understand!

The code feels like a bit like clever perl one-liners.


Or you could just loop n-1 times and adjust the array indices in the loop body, so that each statement only deals with one corner.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: