def submit(partId): print '==\n== [automata-class] Submitting Solutions | Programming Exercise %s\n==' % homework_id( ) """Test on Sample""" sampleoutput = CYK.Start('sampleCYK.in') print '**********************\nTest on sample input (sampleCYK.in)......' if (cmp(sampleoutput, "1 \n02 1 \n1 02 1 \n02 1 02 1 \n13 23 13 23 13 \n") == 0): print '\nYou output is correct for sample input. Now start submitting to servers.....\n**********************\n\n' else: print 'Your output on sampleCYK.in is not correct' print 'Your generated table X is: %s' % sampleoutput print 'Correct table X is: 1 \n02 1 \n1 02 1 \n02 1 02 1 \n13 23 13 23 13 ' print '0: S, 1: A, 2: B, 3: C' print 'You cannot submit until your output on samples is correct' return """Submission""" # Setup submit list partId = promptPart() partNames = validParts() if (not isValidPartId(partId)): print '!! Invalid homework part selected.' print '!! Expected an integer from 1 to %d.' % len(partNames) + 1 print '!! Submission Cancelled' return (login, password) = loginPrompt() if not login: print '!! Submission Cancelled Because of Failure in Logging in' return print '\n== Connecting to automata-class ... \n' if partId == len(partNames) + 1: submitParts = range(1, len(partNames) + 1) else: submitParts = [partId] for partId in submitParts: # Get Challenge (login, ch, state, ch_aux) = getChallenge(login, partId) if ((not login) or (not ch) or (not state)): # Some error occured, error string in first return element. print '\n!! Error: %s\n' % login return # Attempt Submission with Challenge ch_resp = challengeResponse(login, password, ch) result = submitSolution(login, ch_resp, partId, output(partId, ch_aux), \ source(partId), state, ch_aux) if (not result): result = 'NULL RESPONSE' print '\n== [automata-class] Submitted Homework %s - Part %d - %s' % \ (homework_id(), partId, partNames[partId - 1]) print '== %s' % result.strip()
def output(partId, ch_aux): """Uses the student code to compute the output for test cases.""" res = CYK.Start("testCYK.in") return res