CLI for competitive programming template in python - general - CodeChef Discuss
How do you format python code for competitive programming? - Stack Overflow
Python for competitive coding? (Data Structures and Recursion Depth)
I want to design and build a programming language specifically for competitive programming!
Videos
» pip install online-judge-template-generator
So I've recently dived into competitive coding, and discovered that I'm indirectly being forced to use some weird, horrific language called C++.
I absolutely adore python, but its lack of simple (but important) data structures like BBSTs (sorted containers in general), bloom filters, etc is painful.
Heaps and hastables are easy and fast since python includes them. I've used this elegant piece of python I found via this subreddit for making trees
def tree():
return collections.defaultdict(tree)Does anyone know of similar, short and elegant snippets for other data structures?
Another huge problem is the painfully small recursion depth. Even with sys.setrecursionlimit(), solving a dynamic programming problem with python almost never works. This answer explains why python has such a low recursion limit, but a reason like
Guido doesn't want a language where deep recursion is idiomatic. (And most of the Python community agrees.
is weird and unpythonic! Last time I checked, python was open minded and was not about forcing programmers to use it only for simple problems.
Are you guys using python for competitive coding? How do you get around these issues?
Thanks.
I can't use Jenk's Sorted Containers because Competitive Coding doesn't allow importing libraries like that.
I remember Raymond Hettinger mentioning in an old talk that they're looking into adding useful data structures (like bloom filters) in Python, but I haven't found any follow up material.
David's PyCon talk: Generators: The Final Frontier shows a wonderful way of "hacking" the recursion depth by using lazy evaluation, but doing that in competitive coding makes debugging hard and code run significantly slower.
Competitive coding isn't a good indicator of programming problems that one faces in real life. But being forced to use an ancient, poorly designed, overly verbose, dangerous language like C++, just because the Python community chose some hand wavy reasons to omit good features, makes me sad.