2009-2010 Round 6 Question 1
Author |
Message |
PropagandaPanda
|
Posted: Wed Apr 28, 2010 5:55 pm Post subject: 2009-2010 Round 6 Question 1 |
|
|
Hello.
I'm not sure why the code below (Python) was judged as wrong. It was my second submission, so it didn't so up in the score sheet.
code: | def ReadFile():
for Line in open("data1.txt").read().split("\n"):
yield Line
Next = ReadFile().next
def WriteLine(Line):
open("out1.txt","a").write(str(Line) + "\n")
def DoIt(Line):
S = ""
for Chr in Line:
if "A" <= Chr <= "Z":
Ord = ord(Chr) - 65
Ord += 13
Ord %= 26
S += chr(Ord+65)
else:
S += Chr
return S
for QQ in xrange(5):
WriteLine(DoIt(Next()))
|
I'm guessing it was because there were trailing spaces in the test file, but I assumed this may have been allowed because the program was suppose to read the whole line.
Would it be possible for you to attach a copy of the test file used on the judge machine?
Thanks. |
|
|
|
|
|
Sponsor Sponsor
|
|
|
Tony
|
Posted: Wed Apr 28, 2010 6:59 pm Post subject: RE:2009-2010 Round 6 Question 1 |
|
|
It might have had something to do with \r\n newlines on the Windows judge, vs. \n newlines on *nix machines.
The test data is available online via http://dwite.org/home/contest/29, although you wouldn't see the system dependent newlines. |
Tony's programming blog. DWITE - a programming contest. |
|
|
|
|
Dan
|
Posted: Wed Apr 28, 2010 9:44 pm Post subject: RE:2009-2010 Round 6 Question 1 |
|
|
If you give me your team name I can look up in the judges logs about what might have happened. |
Computer Science Canada
Help with programming in C, C++, Java, PHP, Ruby, Turing, VB and more! |
|
|
|
|
PropagandaPanda
|
Posted: Thu Apr 29, 2010 3:33 pm Post subject: RE:2009-2010 Round 6 Question 1 |
|
|
Hello.
Quote: It might have had something to do with \r\n newlines on the Windows judge, vs. \n newlines on *nix machines. I don't think this is the issue. Python automatically convers \r\n to \n when reading and vice versa when writing.
The test data provided works fine with my program.
Quote:
If you give me your team name I can look up in the judges logs about what might have happened. My team name is PropagandaPanda. I would appreciate if you could look into it for me.
Thanks for your time. |
|
|
|
|
|
Dan
|
Posted: Thu Apr 29, 2010 8:49 pm Post subject: Re: 2009-2010 Round 6 Question 1 |
|
|
For the fist submssion the judge reported the following error:
code: |
Traceback (most recent call last):
File "answer1.py", line 25, in <module>
A = Next()
StopIteration
|
and the output file contained:
Quote:
QJVGR DHRFGVBA
BAR CHAPGHNGVBA.,
EBG13 <GBAL>
Note that all the line breaks are wrong.
The second submssion had no errors but the output file contained the following:
Quote:
QUESTION ONE
<TONY>
ROT13
PUNCTUATION.,
DWITE
This is the contents of the data1.txt file.
The code you submited for the second submission is diffrent from what you posted here and looks like so:
Python: |
def ReadFile():
for Part in open("data1.txt","r").read().split("\n"):
yield Part
Next = ReadFile().next
def WriteLine(Line):
open("out1.txt","a").write(str(Line) + "\n")
def DoIt(Line):
S = ""
for Chr in Line:
if "A" <= Chr <= "Z":
Ord = ord(Chr) - 65
Ord += 13
Ord %= 26
S += chr(Ord+65)
else:
S += Chr
return S
for QQ in xrange(5):
WriteLine(Next())
|
note the last line:
WriteLine(Next())
is diffrent then what you posted and just copies the contents of data1.txt to out1.txt. |
Computer Science Canada
Help with programming in C, C++, Java, PHP, Ruby, Turing, VB and more! |
|
|
|
|
PropagandaPanda
|
Posted: Sun May 02, 2010 7:13 pm Post subject: RE:2009-2010 Round 6 Question 1 |
|
|
Hello Dan.
Sorry for wasting your time. The mistake was completely mine.
I had submitted the a bad copy of my code.
Thanks. |
|
|
|
|
|
|
|