The Hardy-Ramanujan Number Coding Challenge

It all started as a joke. I first challenged my sister  to compete a simple gist of mine implementing a really naive dummy algorithm to compute some of the first Hardy- Ramanujan numbers.

The number derives its name from the following story G. H. Hardy told about Ramanujan. "Once, in the taxi from London, Hardy noticed its number, 1729. He must have thought about it a little because he entered the room where Ramanujan lay in bed and, with scarcely a hello, blurted out his disappointment with it. It was, he declared, 'rather a dull number,' adding that he hoped that wasn't a bad omen. 'No, Hardy,' said Ramanujan, 'it is a very interesting number. It is the smallest number expressible as the sum of two [positive] cubes in two different ways' " (Hofstadter 1989; Kanigel 1991; Snow 1993; Hardy 1999, pp. 13 and 68).

My original gist can be found at github.

Then Vasilis accepted then challenge with an elegant solution. As we were discussing his solution a lot of optimisations were found, such as itertools of python, or using redis for the set() to enable the script to scale. He even created a solution in C to check the performance of his algorithm.

Then, a nice solution making full exploitation of python's internal power by Dimitris can be found also available on github.

If you like it, contribute and let me know by commenting so that I update the post.

For more similar challenges, go to the projectEuler!

Σχόλια

Δημοφιλείς αναρτήσεις από αυτό το ιστολόγιο

One day at the WS-REST workshop in Florence

PyAPI: A python library to play with various API Standards, like Hydra, Swagger, RAML and more

What is the Semantic Web?