Created
January 23, 2019 13:08
-
-
Save Viniciuscarvalho/179cb70389e480c6292584046c8f459c to your computer and use it in GitHub Desktop.
Algoritmo de procura se a messageString tem todas as letras de message e mostra se tem ou não todas as palavras.
This file contains hidden or 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 UIKit | |
| var messageString = ["a", "casa", "do", "lago", "sempre", "é", "azul"] | |
| var message = "a casa do lago é azul" | |
| // 1º Resolução | |
| let checkArray = message.components(separatedBy: " ").filter { return !messageString.contains($0) } | |
| print(checkArray.isEmpty ? "é igual": "erooou") | |
| --------------------------------------------------------------- | |
| // 2º Resolução | |
| //var splittedMessage = message.split(separator: " ") | |
| //splittedMessage.forEach { (word) in | |
| // if messageString.contains(word) { | |
| // matches += 1 | |
| // } | |
| //} | |
| //print(matches) | |
| //if matches == splittedMessage.count { | |
| // print("é igual baby") | |
| //} else { | |
| // print("errou baby") | |
| //} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment