Aug
22
Code Golf - Kurteous Tips and Tricks
Hey guys,
Hope you all are doing great. I love Code Golfing, what it brings out in you is the hidden concepts of a programming language and especially the push to implement same thing in numerous ways.
Code Golfing and Python - Yeah that's my Poison!
Below are few tips and tricks which will give you an edge over other programmer to write the shortest code:
1. The foo if condition else bar condition can be shortened to
True if condition else False ------- [False,True][condition]
2. Convert long range rifle to pistol: range to an small format
for i in range(n) ------ for i in [1]*n
3. String input in Python2 vs String input in Python3:
string = raw_input() vs string = input()
4.
Hope you all are doing great. I love Code Golfing, what it brings out in you is the hidden concepts of a programming language and especially the push to implement same thing in numerous ways.
Code Golfing and Python - Yeah that's my Poison!
Below are few tips and tricks which will give you an edge over other programmer to write the shortest code:
1. The foo if condition else bar condition can be shortened to
True if condition else False ------- [False,True][condition]
2. Convert long range rifle to pistol: range to an small format
for i in range(n) ------ for i in [1]*n
3. String input in Python2 vs String input in Python3:
string = raw_input() vs string = input()
4.