ovi_ivo's blog

By ovi_ivo, history, 5 years ago, In English

Hi, a newbie here, did all the google work and found some ideas about solving my problem but a few good soul might help better.

How do you approach solving a problem that has too many constraints to remember? Or how do you approach to solve a problem that requires memorizing a lot variables, ranges and constraints which usually makes it harder for a newbie?

How did you overcome this? What was your approach?

Your answer will also help Robiul001, khandokersabbirsabbir and Bug_Debug. Thanks.

  • Vote: I like it
  • -5
  • Vote: I do not like it

| Write comment?
»
5 years ago, # |
  Vote: I like it +20 Vote: I do not like it

Can you give an example of a problem with a lot of constraints?

  • »
    »
    5 years ago, # ^ |
    Rev. 3   Vote: I like it 0 Vote: I do not like it

    Hey Redux, One of my friends sent me this problem (GameRank on Kattis) to solve and I find it too much neuron work for me (I'm no brain lazy) to remember all the constrains but I feel the problem is easy.

    • »
      »
      »
      5 years ago, # ^ |
        Vote: I like it +8 Vote: I do not like it

      So that problem definitely has lots of edge cases. I find it easier to deal with these types of problems through a series of steps that sound common sense, but are easy to skip.

      Define your state. In this case it would be number of stars, level, and streak.

      Write lots of simple functions that call each other that compute changes to state. For this problem, you'd need a win function and a lose function. I'd probably have my win function call an isBonus function.

      Figure out how to thread these simple parts together.

      Finally, like you mentioned below, practice! You get more comfortable with breaking down problems as you do more of them.

    • »
      »
      »
      5 years ago, # ^ |
      Rev. 2   Vote: I like it +5 Vote: I do not like it

      Great example of a question that's not algorithmically challenging, but annoying to implement.

      I'll try to break it down into parts for you, so that maybe you can see how to do it for future questions (or maybe it won't help at all since I'm just repeating a lot of what the statement says. ¯\_(ツ)_/¯).

      Walkthrough

      For this problem, there's not much you can do besides take your time with it and deal with the cases one at a time while trying to not get too frustrated or confused. If it's too much to keep in your head (brain lazy), then it's ok write it out, or draw diagrams. (I personally like writing some pseudocode in my IDE to help outline my thoughts). Take your time and you'll reach a solution eventually. It might be slow at first, but you'll get faster as you practice more.

      I hope that helps.

      edit: I didn't see arknave's comment as I was writing mine, but I'd recommend writing your solution in the way he suggests as it sounds easier to understand and debug.

»
5 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Organize your thoughts on paper (write out every case/edges cases). That way you don't have to rely on something unreliable like periphery memory.

Also, you might be surprised/see some pattern after writing some stuff on paper.