Python Forum
a coding challenge - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: General (https://python-forum.io/forum-1.html)
+--- Forum: News and Discussions (https://python-forum.io/forum-31.html)
+--- Thread: a coding challenge (/thread-20186.html)



a coding challenge - Skaperen - Jul-30-2019

this is my coding challenge for July 2019. it qualifies to work if it runs correctly on at least one of the following versions of Python: 2.6.x, 2.7.x, 3.4.x, 3.5.x, 3.6.x, 3.7.x

code the smallest possible script that prints an exact copy of its own source code without reading any files.


RE: a coding challenge - ichabod801 - Jul-30-2019

Got it:





RE: a coding challenge - Yoriz - Jul-30-2019

I could only get my version down to two lines which is twice the size of ichabod801's
 
 



RE: a coding challenge - Yoriz - Jul-30-2019

SyntaxError: invalid syntax
Output:
SyntaxError: invalid syntax



RE: a coding challenge - Skaperen - Aug-02-2019

  File "foo.py", line 1
    File "foo.py", line 1
    ^
IndentationError: unexpected indent



RE: a coding challenge - ichabod801 - Aug-02-2019

I tested mine in 2.7 and it worked.


RE: a coding challenge - Skaperen - Aug-03-2019

i'm sure many of them work. i was trying to make a larger file. i osed the method of replacing the code with the output after it was run and did that a few times, checking that it wasn't alternating (a outputs b, b outputs a) and was the same each cycle. i posted what it converged to. i could change the file name in it.


RE: a coding challenge - Skaperen - Aug-12-2019

a more difficult problem: your code should output "BREAKING NEWS! WORLD ENDS!" at the end of the source it outputs.