Help me in solving KCPROG4 problem

My issue

cannot solve the problem

My code

#include <stdio.h>
#include <stdlib.h>
#include <string.h>



int main() {
    
            printf("Name: Bob Ticket num: 9182\n");
            
            printf("\n");
            
            printf("Data found, Enjoy the movie\n");
            
            printf("\n");
            
            printf("Name: Jonny Ticket num: 8219\n");
    
            printf("\n");
    
            printf("Ticket ID not found, re-register\n");

    return 0;
}

Problem Link: Code Queue Practice Coding Problem - CodeChef

Your conserns are legit. I hard tried this myself, and I reeeally think @admin should read this.
Let’s break down some points.

The most common way to define a code is “A limited set of defined steps aimed at achieving an objective, with defined beginning and end”. My first red flag was that the problem does not clearly states when the problem begins nor when it ends. It’s cryptic. It says:

During the input, the customer name and tickets are to be uploaded, and further in the program, the user shall enter its name and ticket number which is to be checked in the database and the required message is to displayed.

  • When does “input” end?
  • When does “further” starts and end?
  • What database? Does this come from the supposedly split two inputs?
  • What is the format in which each of both are worked?

Let’s assume that the examples brights a little out of this.

EXAMPLE-

Input:

Name: Bob Ticket num: 9182

Name: Jonny Ticket num: 4568

Data has been uploaded

Output:

Name: Bob Ticket num: 9182

Data found, Enjoy the movie

Name: Jonny Ticket num: 8219

Ticket ID not found, re-register

If we assume a batabase exists, how to call it?
If we assume that the first input is the database, how to split one from another?

We could assume that “Data has been uploaded” might be flag to end filling the database. But, nope. That arises another issue. How to know the second input end? With “Ticket ID not found, re-register”? Does it have to be undeterminated? Non are determinated in statements.

So, I tried this assuming the first ends with “Data has been uploaded” and second ends with “Ticket ID not found, re-register” (because assuming undefinedness is senseless.

So, I tried this:

info = []

while (True):
    
    S = input()
    if (S == "Data has been uploaded"):
        break
    S = S.split()
    names.append((S[1],S[4]))

while (True):
    
    S = input()
    if (S == "Ticket ID not found, re-register"):
        print("Ticket ID not found, re-register")
        break
    
    S = S.split()
    pair = (S[1],S[4])
    
    if pair in info:
        print("Data found, Enjoy the movie")
    else:
        print("Ticket ID not found, re-register")
        break

Many things could be outputed this, but surprisingly, it was this:

Traceback (most recent call last):
  File "/mnt/sol.py", line 8, in <module>
    S = input()
        ^^^^^^^
EOFError: EOF when reading a line

What? An EOF line? Maybe I missed something. So I tried debugging, printing everything it is thrown. Guess what?

With this code, I got the same output:

try:
    S = input()
    print(S)
except EOFError:
    print("End of file reached.")
except:
    print("Something when very wrong")

Not even a single output before the execution dies.


My conserns rised when I checked up the right submissions and when this problem was posted.

It was posted almost 4 years ago

image

Not a single right submit

I guess it’s a setting issue.

  • When do inputs begin and end?
  • What is to be stored?
  • When does the program start and end?
  • What is the result after an escenario?
  • Why a simple input throws EOF?

This is an problem from an external contest. That is, it is totally untested by codechef. Where did you get the link to this problem from?
We’d recommend only solving problems which are linked to from Practice or Learn, which are either problems from our rated contests, or prepared for Learn by the codechef team.