Created
November 24, 2010 13:00
-
-
Save nati57/713616 to your computer and use it in GitHub Desktop.
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
#@author Rafael Salomao <rafaelgavazzi at gmail.com> | |
#@author Natalia Marcondes < natalia.marcondes at gmail.com> | |
#@author Marco Moura <email at marcomoura.com> | |
#@author Carlos Eduardo <kaddxxi at gmail.com> | |
#@author Patricia Carvalho <patfcarv at gmail.com> | |
class Anagrama: | |
@staticmethod | |
def comparar(palavra1, palavra2): | |
lista_palavra1 = Anagrama.palavra_2_lista_and_sort(palavra1) | |
lista_palavra2 = Anagrama.palavra_2_lista_and_sort(palavra2) | |
return lista_palavra1 == lista_palavra2 | |
@staticmethod | |
def palavra_2_lista_and_sort(palavra): | |
lista = [] | |
lista2 = [] | |
for i in palavra: | |
lista.append(i) | |
return sorted(lista) | |
if __name__ == "__main__": | |
print "Hello World" |
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
#@author Rafael Salomao <rafaelgavazzi at gmail.com> | |
#@author Natalia Marcondes < natalia.marcondes at gmail.com> | |
#@author Marco Moura <email at marcomoura.com> | |
#@author Carlos Eduardo <kaddxxi at gmail.com> | |
#@author Patricia Carvalho <patfcarv at gmail.com> | |
import unittest | |
from Anagrama import Anagrama | |
class New_TestCase(unittest.TestCase): | |
def test_identificar_anagrama_duas_palavras_fio_foi(self): | |
self.assertTrue(Anagrama.comparar("fio", "foi")) | |
def test_identificar_anagrama_duas_palavras_fui_foi(self): | |
self.assertFalse(Anagrama.comparar("fui", "foi")) | |
def test_lista_palavra_casa_c_a_s_a(self): | |
self.assertEquals(["a","a","c","s"],Anagrama.palavra_2_lista_and_sort("casa")) | |
if __name__ == '__main__': | |
unittest.main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment