Last active
January 18, 2016 16:07
-
-
Save ajamaica/a2a4d6ac2c783118d734 to your computer and use it in GitHub Desktop.
Ransom Note
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import string | |
#!/usr/bin/env python | |
def ransom_note(revistas,ransom): | |
catalogo = dict() | |
for letra in revistas: | |
if not letra in catalogo.keys(): | |
catalogo[letra] = 1 | |
else: | |
catalogo[letra] = catalogo[letra] + 1 | |
print "%s" % catalogo | |
for letra in ransom: | |
if letra in catalogo.keys(): | |
if catalogo[letra] >= 1: | |
catalogo[letra] = catalogo[letra] - 1 | |
else: | |
return "Ya no hay %s disponibles en las revistas " % letra | |
else: | |
return "No existe la letra %s en las revistas " % letra | |
return "Texto completado" | |
if __name__ == "__main__": | |
revistas =""" | |
Remember, remember! | |
The fifth of November, | |
The Gunpowder treason and plot; | |
I know of no reason | |
Why the Gunpowder treason | |
Should ever be forgot! | |
Guy Fawkes and his companions | |
Did the scheme contrive, | |
To blow the King and Parliament | |
All up alive. | |
Threescore barrels, laid below, | |
To prove old England's overthrow. | |
But, by God's providence, him they catch, | |
With a dark lantern, lighting a match! | |
A stick and a stake | |
For King James's sake! | |
If you won't give me one, | |
I'll take two, | |
The better for me, | |
And the worse for you. | |
A rope, a rope, to hang the Pope, | |
A penn'orth of cheese to choke him, | |
A pint of beer to wash it down, | |
And a jolly good fire to burn him. | |
Holloa, boys! holloa, boys! make the bells ring! | |
Holloa, boys! holloa boys! God save the King! | |
Hip, hip, hooor-r-r-ray!""" | |
ransom = "Remember, remember!" | |
revistas_limpio = revistas.translate(None, string.whitespace) | |
ransom_limpio = ransom.translate(None, string.whitespace) | |
print ransom_note(revistas_limpio,ransom_limpio) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment