+ 2

Simple Langauge

You are given a program written on Simple Language. There's only one variable called in this programming language. Initially, . The program consists of lines. Each line is one of the following: Given a program, your task is to remove some lines (possibly none or all of them) in such a way that the value of after running the resulting program will be the maximum. Find this maximum value. Complete the function maximumProgramValue which takes in an integer denoting the number of lines of the program and returns the maximum value. You will need to take the program's lines from the standard input. ----- Code ------ #!/bin/python3 import os import sys # # Complete the maximumProgramValue function below. # def maximumProgramValue(n): # # Write your code here. # if __name__ == '__main__': fptr = open(os.environ['OUTPUT_PATH'], 'w') n = int(input()) result = maximumProgramValue(n) fptr.write(str(result) + '\n') fptr.close()

17th Apr 2018, 6:48 PM
Anthony Perez
1 Resposta
0
To me, your question seems to suggest this: 1) We are given a program 2) We randomly remove lines 3) We execute the program, and it outputs an integer result 4) Repeat 2, until we get the largest integer result from step 3 Is that it!?
17th Apr 2018, 7:10 PM
Emma