The Ultimate Cut-and-Paste Job and a JavaScript challenge

Ashok Be
Professional Pirates
1 min readMar 11, 2018

The task: Write python code to generate prime_factors for any integer.

The solution: A one-liner Python program (okay three, if you count the import statements) which get the job done, without actually defining the function. Lo and behold!

Credits: suic on codewars.com

The above python code scrapes and selects one of the answers associated with the related Stackoverflow question. The exec function call eliminates the need for performing the typical cut-and-paste job! How cool is that? That’s why Python rocks!

Incredible, isn’t it? Take it for a spin below:

The JavaScript Challenge

Who will be the first one to write an equivalent Javascript program that does exactly what the Python program does?

--

--

Ashok Be
Professional Pirates

Entrepreneur, struggle-to-code evangelist, paradox collector, green tea and black coffee enthusiast. And yes, squash!