Skip to content

Instantly share code, notes, and snippets.

@nati57
Created November 24, 2010 13:00
Show Gist options
  • Save nati57/713616 to your computer and use it in GitHub Desktop.
Save nati57/713616 to your computer and use it in GitHub Desktop.
#@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"
#@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