davidktw
Arch-Supremacy Member
- Joined
- Apr 15, 2010
- Messages
- 13,547
- Reaction score
- 1,301
JUST FOR FUN, NOT EVEN A CHALLENGE
I have a very simple Python3 script here
Before you start telling me this is a very inefficient fibonacci sequence implementation. We are not interested in this. This is just a demonstration of a multi-line Python3 script. While there are some cases where a Python script can be written in one-liner such as
The challenge here is given any possible simple/complex Python3 script, can it be somehow massaged into yet another valid Python3 script such that it is a valid one liner Python3 source code and can be interpreted by a Python3 interpreter and executed as follows
The contents of
Below is a sample output when I execute the
I have a very simple Python3 script here
Python:
import sys
def fib(n):
return n if n <= 1 else fib(n - 1) + fib(n - 2)
print(fib(int(sys.argv[1])))
Before you start telling me this is a very inefficient fibonacci sequence implementation. We are not interested in this. This is just a demonstration of a multi-line Python3 script. While there are some cases where a Python script can be written in one-liner such as
Python:
for i in range(10): print(i)
The challenge here is given any possible simple/complex Python3 script, can it be somehow massaged into yet another valid Python3 script such that it is a valid one liner Python3 source code and can be interpreted by a Python3 interpreter and executed as follows
Bash:
$ python3 oneliner.py
The contents of
oneliner.py should be in the formCCCCCCCCCC....CCCCCCCCC with no newline, no carriage return charactersC here refer to just any other possible characters except "\n" (ASCII 10) or "\r" (ASCII 13)Below is a sample output when I execute the
oneliner.py which will output as per how the fibonacci implementation works
Python:
$ python3 oneliner.py 10
55
Last edited: