Some time ago I was watching this amazing football match Germany vs Greece with a friend of mine. I still remember the lol moment when Archimedes realized what to do! From this video, an interesting discussion started about the suitability of certain languages towards philosophy and in particular, how both Ancient Greek and German may better mold philosophical concepts. We engaged on a very nice discussion about natural and programming languages too.
Finally, we agreed on these similarities:
- C/C++ : Latin
- Java : English
- Python : Ancient Greek/German
While enjoying some coding this morning, I was back on that concept while facing with the problem of reading quipus. Without entering too much into the details, the goal is to convert strings like this "XX--XXX-XXXX" into decimal numbers. In this specific case, the string "XX--XXX-XXXX" is equivalent to 234. The number of "-" may change based on positional coherence between different numbers.
Some examples are:
-XXXXXXX--XX-----XXXXX--- 725
---XX----XXX-----XXXX---- 234
-XXXXX---XXXXX--XXXXXXXX- 558
The proposed solutions for this problem consist of:
- 30 lines of codes in Java
- 41 lines of codes in C++
If I would have to propose a solution in Python, it might be
[int(''.join([str(t.count("X")) for t in q.split("-") if t != ''])) for q in quipusList]
References:
- Quipus: http://en.wikipedia.org/wiki/Quipu
- The QuipuReader problem:
No hay comentarios:
Publicar un comentario