Macro for raw_input in python:code-golfing

In the shortest mode of clash of code, I end up using raw_input function many number of times. So,is it possible to create any shorter alias or macro to reduce the code size and also any other code-golfing technique related to python is welcome!!

1 Like

Adding a macro specifically for code-golfing is not the way. You should abstract your reading to reduce code size instead. Try r=raw_input;r();r() or similar.

1 Like

Python is good but not great at Shortest mode.

Another idea: Use input() instead of int(raw_input()) when reading in numbers.

@JamesMcG, while doing the challenges on this website, I always use python. But even with python I have seen myself reaching particular limit after which its just not possible to shorten the code while in same questions I have seen people writing amazingly short codes in javascript and ruby. So, I am planning on learning one of these at least to the extent where I can write shorter code than in python but I am confused as to which to pick out of js and ruby. So, can you suggest which one would be better. Also its very likely I might be using one of these languages in future, so I would prefer not to spend time on learning any other language which would be of no practical use other than code golfing.

There are very few languages which are practical only for code golfing. And, luckily, none of them are Codingame languages.

In other words, all languages on Codingame have practical uses and their use in code golfing is just for fun and for brain exercise.

Python is a great language to use on this website.
Shorter languages (for code golf) are Perl and Ruby, but I don’t recommend learning them only for this one reason.
Only 1/3 of Clashes are Shortest mode, so just get used to occasionally losing to Ruby masters there (you’ll still beat most other languages). Python is better for the other 2 modes, Fastest and Reverse, so spend time practicing it is good time usage.
There are other code-golf tricks for Python, if you see someone beat your Shortest Clash in Python then ask them how they did it in the chat afterwards.

@JamesMcG, well that’s the thing:), before I can ask the player who beat me, they disappear without any replies. I have never been able to get a reply from anyone who beat me. Is there another way to ask a question to someone?

1 Like

Yes, there is. You can use PM. Or you can just mention the player’s name in chat, the player will be notified about this and summoned to that chat (but he/she still may choose not to answer, you know).