-
Notifications
You must be signed in to change notification settings - Fork 138
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #205 from Uriel-David/challenges/2-palindromos/go/…
…Uriel-David Finalizando o desafio
- Loading branch information
Showing
2 changed files
with
51 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Submissão de Exercicio | ||
|
||
**Exercicio:** 2 - Palindromo | ||
|
||
**Nickname:** Uriel-David (Zinr4x) | ||
|
||
**Nível Técnico:** - Senior | ||
|
||
**Empresa:** - Comuniverse / Software Engineer - | ||
|
||
**Twitter**: O Elon Musk baniu minha conta sem motivo (opcional) | ||
|
||
**Dificuldade de Resolução:** - Baixa | ||
|
||
**Comentários:** GOneles | ||
|
||
**Como rodar o desafio**: | ||
|
||
Dentro do diretório do projeto, utilize o comando abaixo: | ||
```bash | ||
go run palindromo.go | ||
``` |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"strings" | ||
) | ||
|
||
func main() { | ||
var word string | ||
|
||
fmt.Print("Digite uma palavra e verifique se é um palindromo: ") | ||
fmt.Scanln(&word) | ||
|
||
result := isPalindrome(word) | ||
fmt.Println() | ||
fmt.Println(result) | ||
} | ||
|
||
func isPalindrome(word string) bool { | ||
word = strings.ToLower(strings.ReplaceAll(word, " ", "")) | ||
|
||
for i, j := 0, len(word)-1; i < j; i, j = i+1, j-1 { | ||
if word[i] != word[j] { | ||
return false | ||
} | ||
} | ||
|
||
return true | ||
} |