October LunchTime UNofficial Editorials (First two problems) Revised

Thanks for the explanation :slight_smile:
Can you help me debugging my code for 2nd problem please? LINK

hey taran can u share your fb profile link or can you send me req.? Needed to talk to you personally. :slight_smile:

1 Like
t = int(input())
while t>0 :
    n = input()
    i = len(n)
    flag = 0
    li = []
    while i>0:
        copy = int(n[:i-1] + n[i:])
        if copy%6 == 0:
            li.append(copy)
            flag = 1
        i -= 1
    if flag == 1:
        print(str(max(li)).rjust(len(n)-1, "0"))
    else:
        print("-1")
    t = t-1

I don’t know why it was giving TLE although you have also used nested loops and hence O(n^2)… please help me?

https://www.codechef.com/viewsolution/16001364
Can you help me debugging my code please?

I’m getting WA in the second subtask in BUGCAL… Why?

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

My solution is in O(number of digits). I don’t know why it is giving TLE. This is my solution.
It is in Python. My logic is I calculate the number if I remove one digit, and check if it is divisible by 6 and greater than previously held value and replace it. Then append zeroes according to input if the first digit is removed.

e.g:- 3268398 is input,
num will hold the values (268398, 368398, 328398, 326398, 326898, 326838, 326839) in each iteration respectively.
Will check if it is divisible by 6 and greater than previously divisible value.

Thanks in advance.

I don’t know why i am getting RE(NZEC)?
this is my solution CodeChef: Practical coding for everyone

My code gives wrong ans.Any test case where it may fail?
link:CodeChef: Practical coding for everyone

for the second question ,every test case i checked is satisfied still i am getting a wrong answer please help me out pointing out just 1 test case that this code cannot run ??

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

@taran_1407 can you give some testcases for 2nd question.

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

What is wrong in this code for BUGCAL? PLease help. Everything handled!

@shivam2296 When you are swapping a&b then you should also swap the length also.

Taran, Can you help me debug my code? It seems like I’m missing some corner cases.

Edit: I’m sorry. The link was wrong. This is link to solution. CodeChef: Practical coding for everyone

Hey taran I am getting wa for the 2nd subtask in the problem BUGCAL. Any testcase where I might fail. Here’s the link to my solution - link text

Hey @taran_1407, did you solve the third problem i.e. Optimal Subset?
I have a conventional O(n^2) DP approach and optimizing it seems way too difficult to me and I can’t even think of any other way to approach that problem too.
Any suggestions on that?

Loving your explanations dude.

well done C.A :stuck_out_tongue: as your institute suggests

code , can you please help me out why it is giving wrong answer.

@taran_1407
I am getting run-time error. I tried too much to find where i am getting this but failed.
please help me.
this is my code–>
https://www.codechef.com/viewsolution/15994545
thank you

Can anyone give me a test case where my code fails? It’s working well for all the test cases I checked.

PLEASE HELP ME!!!

I’m storing the digits in an array from one’s place. Then I am iterating through all the digits and finding the new number by removing that particular digit. Now, I’m checking whether it is divisible by 6 or not and if it is then I check whether it is largest number possible which I initially set to -1. At last I’m printing the new number with k-1 digits where k is the total number of digits in the initial number. Leading zeros will be printed since I used %0*d and passed k-1 and maxnum to it. LINK:-My Solution

Taran, sorry for posting that link which didn’t work. I updated it. Can you help me?