[Community Puzzle] Blowing Fuse

It is hardware compatibility issue of the web design that I as a user have no control. I am not sure but you many try using the android version of Firefox or Opera.

The problem was an array overflow, VB has a check on these. Removing it didn’t help, but I created the problem from scratch with more proper variable names and got 100%. I think you should add “Arrays” to skills trained by this puzzle, managing them is the morst difficult part. Anyway, nice puzzle, and thanks for answering!

I tried to solve blowing fuse problem and 3 tests are passed out of 6. But for remaining 3 cases code is failing as max consumed power is mismatching with expected result. However, same logic working for last test case where max power consumption is same as expected. Do not understand why same code not giving max power as per expected result for other 3 cases. Is there solution available on website which I can refer?

When you have unexplained results, add debugging messages into your code to show every iteration of action (turn on/off which device) and the update status (current power consumption, max power consumption).
Manually cross-check the debug messages. You’ll soon find out what’s wrong.

1 Like

I am trying to solve this puzzle, but i found a difficulty in really understanding it . So do you mean that the first click turn On the first device in the pattern, then the second click turn OFF the first one and ON the second , third click turn ON first (since it is OFF), OFF second and ON third ? but if we take an example if there is x device in the first position and the same device on the 4th position (of the pattern) if the device was ON then this click would turn On this device but however they are the same device then we shouldn’t count it’s current usage … is that true? thank you

Line 1 says each devices has an ID, 1, 2, 3, 4, …n
Line 3 says there is a sequence of ID numbers you are going to click power buttons

So in Line 3, if you see 4 3 4…
You are going to click first on device of ID4, then on ID3, then on ID4 again. ID4 will be turned ON in the first click, and then turned OFF in the third click (assume the fuse is not blown yet).

An even more vivid example is that you walk into your room, click the light button (ID4) to turn on the light, then click the computer power button (ID3) to turn it on. After a while you click the light button (ID4) again to turn off the light while walking away, but leave the PC running by itself as a server…

Study the “Input” section several more times, word-by-word, carefully. All information you need are already written out, with no hidden trick.

Hi there, is there anyone that can help me understand the logic of this puzzle and what have i done wrong.

For the Second test my output was:
5 8 82
18 20 3 1 20
2 4 3 3 5 4 2 3
2 - 20 - ON CONSUMED = 20
4 - 1 - ON CONSUMED = 21
3 - 3 - ON CONSUMED = 24
3 - 3 - OFF CONSUMED = 21
5 - 20 - ON CONSUMED = 41
4 - 1 - OFF CONSUMED = 40
2 - 20 - OFF CONSUMED = 20
3 - 3 - ON CONSUMED = 23
Fuse was not blown.
Maximal consumed current was 23 A.
Failure
Found: Maximal consumed current was 23 A.
Expected: Maximal consumed current was 41 A.

The code is doing my understanding of the exercise.
So, what is wrong in result?

Thanks in advance

If the fuse did not blow, find the maximal consumed power by turned-on devices that occurred during the sequence.

not necessarily the last value

2 Likes

Thank you very much … Have to read with more attention :slight_smile:

Even i got the same answer and error…
Can someone explain?

Look at what java_coffee_cup wrote:

1 Like

I am also have the same problem.
My code passes all validators except the first one.

n,m,c=map(int,input().split())
    la=list(map(int,input().split()))
    op=list(map(int,input().split()))
    d={}
    ml=[]
    x=0
    fac=1
    for i in range(n):d[i+1]=0
    for i in op:
        if d[i]%2==0:x+=la[i-1];ml+=[x];d[i]+=1
        else:x-=la[i-1];ml+=[x];d[i]+=1
        if x>=c:print('Fuse was blown.');break
        else:fac='-1'
    if fac=='-1':print('Fuse was not blown.');print('Maximal consumed current was',max(ml),'A.')

What happens if the fuse doesn’t blow on the first operation but does on the second?

My code passes all testcase and validators except the first validator.

n,m,c=map(int,input().split())
    la=list(map(int,input().split()))
    op=list(map(int,input().split()))
    d={}
    ml=[]
    x=0
    fac=1
    for i in range(n):d[i+1]=0
    for i in op:
        if d[i]%2==0:x+=la[i-1];ml+=[x];d[i]+=1
        else:x-=la[i-1];ml+=[x];d[i]+=1
        if x>=c:print('Fuse was blown.');break
        else:fac='-1'
    if fac=='-1':print('Fuse was not blown.');print('Maximal consumed current was',max(ml),'A.')

Why are you writing the same message again?
@RoboStac already gave you an answer.
Test your program with a case where the fuse doesn’t blow in the first operation:

Input:

5 2 10
11 6 11 10 10
2 1

Expected Output:

Fuse was blown.

Output of your program:

Fuse was blown.
Fuse was not blown.
Maximal consumed current was 17 A.

sorry i didn’t understand the reply or that it was addressed to me…
Thanks for pointing my bug
I got it.Thanx

@java_coffee_cup Hey, i was just curious if you had an idea as to why I am failing the first validator. I passed every test case before submitting but after I submitted I got an error on validator 1, is there any inputs you cant think of to try so I could debug my program? Or is it just a bug causing it to error? Thank you.

1 Like

Set expert mode in option, then add this custom testcase and try to understand your result:

12 3 4
14 11 3 15 2 1 11 17 4 14 10 1
3 3 10

1 Like

Hi @java_coffee_cup , i know this topic is quite old but i pass all the test cases but fail the first Validator.
Can you please explain what the first validator does so i and others can understand our mistakes ? Thank you!

Similar to the first test case, the first validator has a relatively low value of c.
You also have to handle cases of pressing the same button multiple times in a row.

1 Like