+8

How to analyze a problem?

Hello everyone! I'm a computer science student and programming is a subject I'm passionate about. However, I am having enormous difficulties in finding solutions to solve even the simplest problems (for example: write a program that reads a sequence of numbers and searches for the maximum value.) What could be the best technique to try to solve these types of problems or at least try to understand the problem? (At the moment I'm studying the FOR and While and Do While interaction cycles). (Sorry For my Bad english).

2/5/2020 5:02:06 PM

Computer_King20

50 Answers

New Answer

+13

I don't know if your curriculum allows for that, but solving problems by translating them to code... let me emphasize... *** has to be practiced, and there is no shortcut! *** The trick is to start with easy problems. There is no problem, that's to easy. If you can't solve a problem, look for dumber tasks. ;-) It doesn't remain this way. With every little problem you manage to solve... emphasis again... *** on your own, without rote memorization! *** ... you become a little bit stronger, and over time it adds up. There is no other way. You have to start at the point where you are at now, and train hard.

+7

That's quite a common problem with most of the beginners. All you should do is, take a paper and a pen and solve it mathematically. It doesn't have to be maths all the time but logic that you require to solve a problem. Coming to your question on maximum value search. You can do it in many ways- 1) Sort the array elements in ascending order and print the last element or you can do vice-versa. 2) declare a variable int x= 0. Use a for loop to iterate over the array elements and you can do- if(arr[i] > x){ x = arr[i]; } // print the value of x Consider an array- int arr[] = {4, 7, 2, 5}; Apply this to the above and you will get the result.

+7

Hi, go another way: Study solutions until you understand each step. Pencil and paper are your best friends at the moment. If you think, you understand fully, code the solution by heart . Try until you succeed. The situation is serious. But training does the job. The best chess player do it similarly.

+7

First break a problem down into smaller parts.

+6

Computer_King20 great!

+6

Computer_King20, alright then. Well, if you don't understand the explanations, you might believe me and start at a lower level. I'm someone who started without real aptitude myself (spent my life before with totally different stuff) and needed quite a bit of time until I figured out several things. And that voyage hasn't ended either. You can not force this! You won't grow muscles if you can't even lift the barbell. You need to start all the way at the bottom and work your way up. Take user input and print it backwards. Let the user enter a few numbers and add them. Make a simple Stone-Scissors-Rock game. Whatever it is, with every little exercise you will get better. Trying to force this understanding into your head will lead you nowhere, you'll just be spinning your wheels. We've seen that before here on Sololearn.

+5

To understand this, let us take an example. Understand that you have a lot of coins. The largest coin represents the biggest digit and the smallest coin represents the smallest digit. You have a hole through which you have to withdraw all that money. The size of the hole is equal to the size of the largest coin. This means that in order to identify the largest coin you have to remove all the small coins from that hole and the coin does not come out of that hole, it means that coin is the biggest digit and you get your answer here.

+5

Yeah, Computer_King20, and that's why I'm telling you: Look for a problem that you *can* solve, and postpone problems you can't figure out yet. After you have done ten easier problems, you may have improved enough to figure this one out as well. However, it would be of no use and a waste of a good task, if we just told you how to do it. That's not what these tasks are made for. You need to study the language and practice it enough until you start to naturally come up with ways to translate task to code.

+3

Computer_King20 maybe it will always be your weak point. Some brains are not made for it. But no way out. It is a must have

+3

HonFu Thanks for your suggestions. now I'm trying to recover starting from the problems that started at the beginning of the school year. Hopefully some light bulb will turn on in my mind.

+3

Too hard. Look for *way* simpler problems. And learn a bit of C first, you need to at least figure out the basic logic of input, output, data, loops and conditions.

+3

Sonic for example, how would you divide the exercise of the square into small parts that I said before?

+3

Computer_King20 it's all about positioning and knowing how many spaces to leave vertically and horizontally before the top left location of each square.

+2

Practice makes perfect. Look up coding practice or something similar on Google and you'll find plenty interesting quests.

+2

Blabla Blablabla unfortunately I do a lot of practice staying even a few hours to solve a problem of this type. But unfortunately I can't reason to find the solution. Sometimes I also manage to set it up well but then, at a certain point, I get stuck and I can no longer continue.

+2

HonFu Yes, I understood some things to solve this problem but the problem is to code it. If I draw on a sheet in 3 squares, I notice that some * coincide on the same line. Then I realized that I have to initialize a counter in a cycle for me to print the asterisks and spaces. But trying to code it, I have a hard time putting the asterisks on one end and putting the squares inside each other.

+2

Computer_King20 for example, you first determine the coordinates of the centre. Then, for each square, you know that the top, left starting position is going to be half of its side length above and to the left of the centre.

+2

Sonic in coding how can I write this reasoning?

+2

Sonic yesterday I tried different methods, the one that worked best, however, I printed the squares one below the other and not inside the bigger one

+2

Computer_King20 it looks like you are not spacing out the smaller squares.