chef and sign sequence

HELLO community!

i m getting WA in 2 testcases! hereis my submission

https://www.codechef.com/viewsolution/14495088

please help me find my mistake!
thanks in advance!:slight_smile:

you are complicating things too much , its just to count the consecutive < or > whicheva is max :slight_smile:

i know and i think i m doing the same thing.but somehow these two testfiles are giving WA.i tried every test case i could think and they all are giving right answer.please help!

One pretty crude but reliable way to debug your code is to generate random test cases (which is easy in this case). Just download an AC code and throw random tests at your code while comparing against the AC output. In the case where you don’t have an AC code, you can (sometimes) write a brute force solution to check for small inputs.

Another way is to question your assumptions rigorously. This is harder to do than the first one but this is the only way when all other debugging alternatives have been exhausted. Try to write down every assumption that you used in your logic. Then question if each one will definitely be true. If there exist any counterexamples, then you need to rethink your logic.

Last but not least, for this problem specifically, you might want to print the actual values of the sequence which you used to satisfy the inequality. For example, if the sequence is “<<”, your code should output 1 < 2 < 3 not 0 < 1 < 2 or some other illegal sequence. If you see some strange value appear, then your logic definitely went wrong somewhere.

i had compared my code with AC one.but i was unable to spot any logical error in my code.:frowning:

Debug using this case-

Input
1
<<><<<<><<<>>>>>
Your Output
5
Correct Output
6 (last bracket has length 5)

Your initial count1 and count 2 (which count number of “<” and “>”) have no purpose, as you can see in this test case.

thank u so much! i got my mistake now…

Hey dear, for any question you ask, please dont use “Award point” feature as this gives YOUR karma to the user, and you need 20 karma to freely ask as many Q as you want. Instead, use “Accept answer” feature by clicking on “tick in circle below thumbs down button”. That will give decided points to the asnwerer, adn some karma to you as well for going through answers and successfully accepting the correct one. Thats the standard way the community grows ^^

that was my first question on forum,didn’t knew that! :frowning:

You can always accept the answers which rightly answered your query. That way you can get enough reputation soon for asking Q yourself. :slight_smile:

Np, many people get confused in their first time, even i was :slight_smile: