<p>I’m interested in competing in local programming competitions (ACM) but I have no clue as to how to solve problems such as these:</p>
<p><a href=“*Fudge”>url=http://fudge.fit.edu/Problems/Archive/Box<em>of</em>Bricks</a>.Problems[“Box of Bricks”]</p>
<p>How do I solve/code these problems and what can I do during the summer to prepare myself to compete in these competitions?</p>
<p>(If I posted this in the wrong section, then sorry.)</p>
<p>There might be more straight-forward approaches, but I would just start intuitively: if I were to rearrange the blocks manually, how would I do it? You can start playing around with different arrangements of blocks until you see a pattern. Once you have an algorithm in your head, you only need to code it, which should be fairly straight-forward with some programming experience.</p>
<p>Part of the problem, of course, is handling the input and output. That should be straightforward if you’ve had a semester in programming.</p>
<p>You need to find the target size of the stacks. This should be easy to do (there’s a nice hint in the problem on this).</p>
<p>Now do you need to move any bricks from columns that are under the target?
How many bricks do you need to move from columns that are over the target?</p>
<p>There’s a clickable solution if you want to see how other solved it.</p>
<hr>
<p>On learning how to solve problems:</p>
<ul>
<li>Find simple problems and try to solve them and then work on harder problems</li>
<li>Read programming textbooks. They usually have examples of programming problems and their solutions.</li>
</ul>
<p>The Deitel and Deitel books are good for learning programming languages and problem-solving.</p>
<ul>
<li><p>More advanced problems can be solved if you understand more difficult algorithms. For example the 8 queens problem (place 8 queens on a chessboard so that no queen is attacking another queen) is usually solved using a backtracking algorithm. Fundamentals of Algorithmics by Brassard and Bratley is a good though compact text.</p></li>
<li><p>Many problems can be solved with the knowledge of data structures - typically a one-semester college course.</p></li>
<li><p>Berkeley has course videos for CS61A, B, C and you might find the A and B courses useful. C is more assembler which probably wouldn’t help you with what you want to do.</p></li>
</ul>
<p>Thanks!! </p>
<p>So my main motive would be to learn the basics of C++ first, right?</p>
<p>Usually C, Java or C++ are good for problem-solving. It might be easier to learn C before C++ if you want to go that route.</p>