Why puzzles in programming?


by jd12345
Tags: programming, puzzles
jd12345
jd12345 is offline
#1
Jan10-13, 03:19 AM
P: 260
I have been solving some programming questions and all are some sort of puzzles?
What are they trying to teach us with puzzles? What skills are they trying to develop by solving puzzles?
Phys.Org News Partner Science news on Phys.org
Cougars' diverse diet helped them survive the Pleistocene mass extinction
Cyber risks can cause disruption on scale of 2008 crisis, study says
Mantis shrimp stronger than airplanes
Borek
Borek is offline
#2
Jan10-13, 04:27 AM
Admin
Borek's Avatar
P: 22,708
Logical thinking.
jd12345
jd12345 is offline
#3
Jan10-13, 07:01 AM
P: 260
What logical thinking is required in software development and other stuff?

NemoReally
NemoReally is offline
#4
Jan10-13, 07:28 AM
P: 194

Why puzzles in programming?


The puzzles aim to let you develop your ability to analyze a problem and develop one or effective strategies for solving them and translating those strategies into algorithms and then implement those algorithms in code. Programming puzzles may target particular data structures or programming methods (eg, matrix algebra or optimization)
AlephZero
AlephZero is offline
#5
Jan10-13, 10:49 AM
Engineering
Sci Advisor
HW Helper
Thanks
P: 6,385
Quote Quote by jd12345 View Post
What logical thinking is required in software development and other stuff?
When you see some of the code written by "professionals", you might think the answer as "none whatever" ....

But seriously, the puzzles may also be testing that you REALLY understand what the programming language means, as well as your "logical thinking" skills.

For example
void swapsigns{int i, int j}
{
  if (i = j)
    i = -i;
    j = -j;
}
Is a perfectly legal C function, but it probably doesn't do what its author intended, for at least three reasons.
cofrecearinaf
cofrecearinaf is offline
#6
Jan11-13, 02:21 AM
P: 2
A possible advantage is that the answer doesn't always lie an internet search away. If you want to make your students think to eventually get the programming mindset needed, you can easily make up an original question that must be thought out instead of copied from some programming forum.

The same can't be done with practical questions because by definition practical questions are common and therefore answers to such questions can easily be found online.

Finally, be thankful. In practice, everyday programming is often tedious and boring whereas puzzles are fun.
Adyssa
Adyssa is offline
#7
Jan11-13, 04:07 PM
P: 186
Puzzles are a good way to make sure that not only do you find a correct solution, but you find a solution that is computable in a reasonable amount of time. Often with puzzles of any significant size, there are solutions that might as well be incorrect because they are so horribly inefficient. The (time / space) complexity of a solution is an important thing to know.

I play around at Project Euler a lot :)
jd12345
jd12345 is offline
#8
Jan29-13, 07:46 AM
P: 260
Sorry for the late reply
ok so puzzles improve my logical thinking. But logical thinking is required in every field of science and maths. Why computer science course focuses so much on logic building?
Mark44
Mark44 is offline
#9
Jan29-13, 09:48 AM
Mentor
P: 21,063
Quote Quote by jd12345 View Post
Sorry for the late reply
ok so puzzles improve my logical thinking. But logical thinking is required in every field of science and maths. Why computer science course focuses so much on logic building?
Because when you write a program, you are writing a sequence of statements in a certain order to anticipate all possible values that a program user might enter. Unless you are writing a very trivial program, your program needs to do one thing if the user enters a certain value, but do something else if the user enters a different value, and so on. Also, the program needs to be able to react in some graceful way if the user enters invalid data.

Writing a program that deals with these occurrences requires a lot of logical thinking on the part of the programmer.
mfb
mfb is offline
#10
Jan29-13, 10:32 AM
Mentor
P: 10,846
Quote Quote by jd12345 View Post
ok so puzzles improve my logical thinking. But logical thinking is required in every field of science and maths.
And as a consequence, most science and math problems are puzzles as well.
jd12345
jd12345 is offline
#11
Jan29-13, 10:39 AM
P: 260
Quote Quote by mfb View Post
And as a consequence, most science and math problems are puzzles as well.
True. Didnt really think about it. Anyways thank you


Register to reply

Related Discussions
Recommended programming language (and texts) for middle-school beginner programming Programming & Computer Science 9
Picture Puzzles. Brain Teasers 60
Logic Puzzles Fun, Photos & Games 0
For Those of You Who Enjoy Puzzles General Math 4
odd word out puzzles General Discussion 11