+ 3
[Challenge] palindrome counter
what is a palindrome? A palindrome is a word, phrase, number, or other sequence of characters which reads the same backward as forward, such as madam or racecar. Challenge: write your shortest solution to determine how many palindromes are in a given input! eg. "abcdcba ghj 167h 1234ff4321" should output 2 (extra challenge for python user, it is possible in 1 line )
7 Answers
+ 10
JavaScript:
alert(prompt("").split(" ").reduce(function(a, b) { return b === b.split("").reverse().join("") ? a + 1 : a; }, 0));
+ 8
one-liner in Python! đ
https://code.sololearn.com/cZbm6ad72wcZ/?ref=app
+ 7
Here's my C# implementation â
LINQ One-Lineră°
input.Split(
new char[] { ' ' },
StringSplitOptions.RemoveEmptyEntries)
.Count(w => w.SequenceEqual(w.Reverse()))
Well C# LINQ can do it in one line too! Enjoy~ â€
https://code.sololearn.com/ctD5q0gOi5I4/?ref=app
+ 4
Solved in Ruby:
https://code.sololearn.com/cO0sINgy8vtx/#rb
+ 2
Hardly a challenge.
https://code.sololearn.com/wMeOAw48RWUQ/?ref=app
+ 2
+ 2