[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y / ] [Home]
4chanarchives logo

One Line Python


Thread replies: 15
Thread images: 2

File: python.png (7KB, 144x144px) Image search: [Google] [Yandex] [Bing]
python.png
7KB, 144x144px
So you think you're cool, eh?

One Line Python challenge: Write programs using only a single line of Python. No newlines or semicolons.

Challenges:

Baby mode: Loop print integers 1 to 100
Easy mode: Fizzbuzz
Medium mode: Arithmetic parser and calculator.
Math mode: Write a program that estimates the values of integrals.
Hell mode: Define a Polygon and Square class, create a square instance and call some methods on it, do some polygon collison tests, etc.
>>
Here's a freebie to start you guys off:

list(map(print, range(1, 101)))
>>
I couldn't be fucked trying to make it pretty or even more minimalist.

for i in range (1, 101):print 'FizzBuzz' if not i%15 else 'Buzz' if not i%5 else 'Fizz' if not i%3 else i
>>
>>51505223
>one line
>>
>>51505223
for i in range (1, 101):print 'FizzBuzz' if not i%15 else 'Buzz' if not i%5 else 'Fizz' if not i%3 else i 

>Not using python3
>>
>>51505631
> no semicolons
fails
>>
>>51504921
list(map(...))

Why did they have to do this? I want a strict map function again.
>>
>>51504856
>one line
http://pastebin.com/gUBmYj8h

I know it's three lines (or 4 if you count the standard boilerplate), but I hope you can forgive me.
>>
>>51505712
>http://pastebin.com/gUBmYj8h
What even is that?
>>
>>51506193
Try it :^)

Note that when it ask for an upper bound, this a non-strict bound (because of an off-by-one error).
>>
>>51506421
>non-strict
I mean strict.
>>
>>51506421
Well, I mean that's impressive.
>>
>>51506479
https://github.com/csvoss/onelinerizer

:|
>>
>>51506490
>https://github.com/csvoss/onelinerizer
Not what I used, though. That's done by hand and a couple of Emacs macros.
>>
Do your own homework faggot.
Thread replies: 15
Thread images: 2
[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y / ] [Home]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
If a post contains illegal content, please click on its [Report] button and follow the instructions.
This is a 4chan archive - all of the content originated from them. If you need information for a Poster - you need to contact them.
This website shows only archived content and is not affiliated with 4chan in any way.
If you like this website please support us by donating with Bitcoin at 1XVgDnu36zCj97gLdeSwHMdiJaBkqhtMK