Skip to content

Commit

Permalink
Merge pull request #205 from Uriel-David/challenges/2-palindromos/go/…
Browse files Browse the repository at this point in the history
…Uriel-David

Finalizando o desafio
  • Loading branch information
lanjoni authored Oct 4, 2023
2 parents ac41ee0 + 6d4549d commit f898a2f
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
22 changes: 22 additions & 0 deletions challenges/2-palindromos/go/Uriel-David/README.md
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
```
29 changes: 29 additions & 0 deletions challenges/2-palindromos/go/Uriel-David/palindromo.go
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
}

0 comments on commit f898a2f

Please sign in to comment.