(IJ sequence 4) Why is my Python code giving Runtime error in the URI Online Judge?

Asked

Viewed 940 times

-1

I managed to run the program on my computer, however, when I submit to the online test cases it accuses 'Runtime error' and I am not able to circumvent the error.

The problem is (Sequence IJ 4), the link: https://www.urionlinejudge.com.br/judge/pt/problems/view/1098

inserir a descrição da imagem aqui

My last submitted code is below

# Name of the problem: Sequencia IJ 4
# Link: https://www.urionlinejudge.com.br/judge/pt/problems/view/1098

import numpy

for i in numpy.arange(0.0, 2.2, 0.2):
  for j in range(1, 4):

    i_print = round(i,1)
    i_print = str(i_print)
    i_int, i_dec = i_print.split(".")

    j_print = round(j+i,1)
    j_print = str(j_print)
    j_int, j_dec = j_print.split(".")

    if(i_dec == '0'):
            print('I='+i_int, end = " ")
    else:
            print('I='+i_int+'.'+i_dec, end = " ")

    if(j_dec == '0'):
            print('J='+j_int)
    else:
            print('J='+j_int+'.'+j_dec)
  • This is because during runtime some Exception is being lifted. Have you tried testing all of the uDebug cases? Moreover, your solution seems little performative, given the simplicity of the problem... Try to take a better look at the logic you should build! If you can raise Exception, update the post here.

  • There are no test cases in this problem. Just print the logical sequence correctly at the time you put the code to run. A guy on facebook showed me the code he had done for the same problem (also gave Runtime Error here), I asked him to see if his code (https://bitbucket.org/galego/uri_online_judge_python/src/master/beginner/1098_sequencia_ij_4_solucao_2.py?fbclid=IwAR01PgUxH-OkoONlrikcEdURM_9aADnAnUFYmxvNqolfRaBqpXgzgSnceM) was accepted. The URI platform could be in some kind of trouble, I don’t know ... an assumption.

  • 1

    This question makes no sense and you literally need a crystal ball to add what exactly is the output he expects. Probably the error occurs because it is using the Numpy library and the platform does not have it available.

  • I couldn’t understand the reason for Runtime Error, probably the use of the Numpy library itself. Regarding the problem, a guy on Facebook helped me to find a solution using the Decimal library (I didn’t know it, because I’m starting now in Python). I have solved the problem, I will answer my own question to add an answer here.

1 answer

0

This question refers to the number problem "1098", whose title is "Sequence IJ 4", made available by Uri Online Judge (Online Programming Marathon).

See here the entirety of the statement.

In this regard, it is asked to create a program that presents the sequence according to the exemplo presented.

To solve this question we can use the following algorithm...

# Número do problema: 1098
# Título do problema: Sequência IJ 4
# Categoria: Iniciante
# Disponibilizado por: https://www.urionlinejudge.com.br/judge/pt/problems/view/1098

i = 0
j = 1
acrescimo = (0.2)
n = 0
while i <= 2:
    for c in range(1, 4):
        if i > 2.19:
            print('I={:.0f} J={:.0f}'.format(2, j))
        if i == 1.0 or i == 0.0 or i > 1.8:
            print('I={:.0f} J={:.0f}'.format(i, j))
        elif i < 2:
            print('I={:.1f} J={:.1f}'.format(i, j))
        j = j + 1
    i = i + acrescimo
    j = 1 + i

See how the algorithm works on repl it..

This algorithm has already been testado, submetido and properly aprovado on the website Uri, under programming language Python 3.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.