uva online judge self describing sequence problem solution python | uva 10049

The self describing sequence problem  (uva 10049) is also very straight forward and easy programming challenge in competitive programming once understood well. Which can be stated as (from online judge) Solomon Golomb’s self–describing sequence ⟨f(1),f(2),f(3),...⟩ is the only nondecreasing sequence of positive integers with the property that it contains exactly f(k) occurrences of k for each k. A few moments thought reveals that the sequence must begin as follows: n 1 2 3 4 5 6 7 8 9 10 11   12 f(n) 1 2 2 3 3 4 4 4 5 5 5 6 In this problem you are expected to write a program that calculates the value of f(n) given the value of n. Sample Input 100  9999  123456  1000000000  0 Sample Output 21  356  1684  438744 Programming Explanation This is very simple problem states that for given range of n as input (as shown in above image), we have

uva online judge automated judge script problem solution python | uva 10188

The automated judge script problem (uva 10188) is sequence checker programming challenge in competitive programming. Which can be stated as (from online judge)

write an automated judge script to judge solution runs from teams all over the world. All you have to do is write a program which receives the standard solution and a team output and gives as answer one of the following messages: “Accepted”, “Presentation Error” or “Wrong Answer”. We define each one as:

Accepted: Give ‘Accepted’ as answer if the team output matches the standard solution integrally. That is, ALL characters must match and must be in the same order.

Presentation Error: We want you to give ‘Presentation Error’ if all NUMERIC characters match (and in the same order) but there is at least one non-numeric character wrong (or in wrong order). For instance, ‘15 0’ and ‘150’ would receive a ‘Presentation Error’, whereas ‘15 0’ and ‘1 0’ would not (it would receive ‘Wrong Answer’, see bellow).

Wrong Answer: If the team output could not be classified as any of the two above, then you have no option but to give ‘Wrong Answer’ as an answer!

The problem is pretty straight, here we just have to look for sequence of numbers in strings. We do not consider any alphabetical character. If all numbers sequence matches then print "Accepted", if sequence not match but every number present in both strings then print "Presentation error" else print "Wrong Answer"

Sample Input

The answer is: 10 
The answer is: 5 
The answer is: 10 
The answer is: 5 

The answer is: 10 
The answer is: 5 
The answer is: 10 
The answer is: 15  

Input Set #1: YES 
Input Set #2: NO 
Input Set #3: NO 
Input Set #0: YES 
Input Set #1: NO 
Input Set #2: NO 

1 0 1 0 
1010 

The judges are mean! 
The judges are good! 
0

Sample Output

Run #1: Accepted 
Run #2: Wrong Answer 
Run #3: Wrong Answer 
Run #4: Presentation Error 
Run #5: Presentation Error                

Explanation

We just have to check character(numbers) matching in two strings if no then check for presence of all characters(numbers) from two strings in both strings else print as 'wrong answer'.

Code

import re

Final_answer, std, obt = list(), list(), list()
str1 = str()

def Split(a):
    temp = str()
    try:
        int(a[0])
        start = 0
    except:
        start = 1
        
    if(len(a) > 2):
        for i in range(start, len(a), 2):
              temp += a[i]
    else:
        temp = a
    return temp

def CheckPresentation(A, B, count):
    
    for i in range(0, count):
        a = re.split('(\d+)',A[i])
        b = re.split('(\d+)',B[i])
        
        a = Split(a[1:len(a)-1])
        b = Split(b[1:len(b)-1])
      
        if(len(a) == len(b)):
            for i in range(0, len(a)):
                if(a[i] == b[i]):
                    continue
                else:
                    return False
            else:
                continue
    else:
        return True
            
    

while(True):
    count = 1
    temp = int(input())
    if(temp<=0):
        break
    if(temp == 2):
        str1 = 'The answer is: '
    else:
        str1 = 'Input Set #'
        
    for i in range(0,temp):
        std.append(input(str1))

    temp1 = int(input())

    if(temp != temp1):
        break
    
    for i in range(0,temp1):
        obt.append(input(str1))

    if(std == obt):
        Final_answer.append("Run #"+str(count)+": Accepted")
    else:
        
        if(CheckPresentation(std, obt, temp) == True):
            Final_answer.append("Run #"+str(count)+": Presentation Error")
        else:
            Final_answer.append("Run #"+str(count)+": Wrong Answer")
    count+=1

print(Final_answer)

After taking two strings as input from user, we just compare them using equality operator, if it return true "Accepted" will be printed, else call check_presentation() function to check presence of characters(numbers) in both strings, if it return true then print "Presentation error" else print "Wrong answer".

Since, in example 5 where no matching numerical found our algorithm will return "presentation error".

Hope, this article found helpful to you, thank you.


Related keywords: automated judge script, automated judge script problem, automated judge script programming challenge, automated judge script uva, automated judge script online judge, automated judge script explanation, automated judge script solution, automated judge script source code, automated judge script python, uva 10188, uva 10188 problem, uva 10188 explanation.

Comments

Popular posts from this blog

uva online judge vito's family problem solution python | uva 10041

uva online judge australian voting problem solution python | uva 10142

uva online judge common permutation problem solution python | uva 10252