Skip to content

Commit ef6dd33

Browse files
committed
Create Palindrome.scala
1 parent ea3aa36 commit ef6dd33

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4468,8 +4468,8 @@ In order to achieve greater coverage and encourage more people to contribute to
44684468
</a>
44694469
</td>
44704470
<td> <!-- Scala -->
4471-
<a href="./CONTRIBUTING.md">
4472-
<img align="center" height="25" src="./logos/github.svg" />
4471+
<a href="./src/scala/Palindrome.scala">
4472+
<img align="center" height="25" src="./logos/scala.svg" />
44734473
</a>
44744474
</td>
44754475
<td> <!-- Kotlin -->

src/scala/Palindrome.scala

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
def isPalindrome(content: String): Boolean = {
2+
val sanitizedContent: String = content.replaceAll("\\W", "").toLowerCase
3+
sanitizedContent == sanitizedContent.reverse
4+
}
5+
6+
object Main extends App {
7+
val data: Seq[String] = Seq(
8+
"",
9+
"a",
10+
"abba",
11+
"No lemon, no melon",
12+
"Was it a palindrome?"
13+
)
14+
data.foreach(x => println(s"'$x' is a palindrome? ${isPalindrome(x)}"))
15+
}

0 commit comments

Comments
 (0)