Skip to content

Instantly share code, notes, and snippets.

@yngwie74
yngwie74 / find_primes.py
Created January 17, 2012 00:12
Mi implementación del problema #7 del proyecto Euler
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""
Implementación del problema #7 del proyecto Euler (projecteuler.net/problem=7):
By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that
the 6th prime is 13. What is the 10,001st prime number?
https://gist.github.com/1623748
"""
@yngwie74
yngwie74 / find_primes_tests.py
Created January 17, 2012 00:13
Pruebas unitarias para find_primes.py (https://gist.github.com/1623748)
#!/usr/bin/python
# -*- coding: utf-8 -*-
from itertools import izip
from unittest import main, TestCase
from find_primes import allPrimes, isPrime, findNthPrime
class TestPrimes(TestCase):
def verifyIsPrime(self, number, outcome):
@yngwie74
yngwie74 / roman.py
Created January 17, 2012 00:36
Implementación "literaria" de la kata "Roman Numerals". La versión sin refactorizar en gist.github.com/1623830
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""
Implementación de la kata "Roman Numerals" (http://bit.ly/92cEtq).
Esta es una implementación "literal" de las reglas de la numeración romana.
Fue escrita con el propósito específico de *NO* usar un diccionario en la
conversión.
@yngwie74
yngwie74 / roman_single_func.py
Created January 17, 2012 00:41
Mi implementación de la kata "Roman Numerals" en una sola función.
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""
Implementación de la kata "Roman Numerals" (http://bit.ly/92cEtq).
Esta es una implementación "literal" de las reglas de la numeración romana.
Fue escrita con el propósito específico de *NO* usar un diccionario en la
conversión.
"""
@yngwie74
yngwie74 / roman_dict.py
Created January 17, 2012 00:45
Mi implementación original de la kata "Roman Numerals".
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""
Implementación de la kata "Roman Numerals" (http://bit.ly/92cEtq).
Esta implementación mapea directamente cada dígito arábigo a su
representación romana. Mientras que es la versión más pequeña y
clara que he hecho, de alguna forma "feels like cheating".
"""
@yngwie74
yngwie74 / roman_tests.py
Created January 17, 2012 01:13
Pruebas unitarias para la roman.py y sus variaciones
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""
Pruebas unitarias para
- roman.py (https://gist.github.com/1623819),
- roman_single_func.py (https://gist.github.com/1623830), y
- roman_func.py (https://gist.github.com/1885963)
- roman_dict.py (https://gist.github.com/1623854)
@yngwie74
yngwie74 / euler07.htm
Created February 1, 2012 01:00
"Runner page" para las pruebas del problema 7 del Projecto Euler
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<!-- this file: https://gist.github.com/1714293 -->
<title>Project Euler - Problem 7</title>
<link rel="shortcut icon" type="image/png" href="jasmine/jasmine_favicon.png">
<link rel="stylesheet" type="text/css" href="jasmine/jasmine.css">
<script type="text/javascript" src="jasmine/jasmine.js"></script>
@yngwie74
yngwie74 / euler07spec.js
Created February 1, 2012 01:02
Especificación para euler07.js en Jasmine
/***
* Especificación para:
* - euler07.js (https://gist.github.com/1714307)
*
* requiere jasmine (http://tryjasmine.com/)
*
* https://gist.github.com/1714297
***/
describe("Euler07", function() {
@yngwie74
yngwie74 / euler07.js
Created February 1, 2012 01:04
Mi implementación del problema #7 del proyecto Euler en Javascript 1.7
/***
* Implementación del problema #7 del proyecto Euler (http://projecteuler.net/problem=7):
* By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see
* that the 6th prime is 13. What is the 10,001st prime number?
*
* Requiere javascript 1.7
*
* https://gist.github.com/1714307
***/
@yngwie74
yngwie74 / roman_func.py
Created February 22, 2012 16:43
Mi implementación de la kata "Roman Numerals", en estilo funcional
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""
Implementación de la kata "Roman Numerals" en estilo funcional.
"""
from itertools import izip, count
_NUMERALES = (