+ 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 )

6th Oct 2017, 9:11 PM
Chrizzhigh
Chrizzhigh - avatar
7 Respuestas
+ 10
JavaScript: alert(prompt("").split(" ").reduce(function(a, b) { return b === b.split("").reverse().join("") ? a + 1 : a; }, 0));
7th Oct 2017, 3:03 AM
Krishna Teja Yeluripati
Krishna Teja Yeluripati - avatar
7th Oct 2017, 7:04 AM
m abrate
m abrate - avatar
+ 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
7th Oct 2017, 2:37 AM
Zephyr Koo
Zephyr Koo - avatar
7th Oct 2017, 6:21 AM
noobcøder
noobcøder - avatar
6th Oct 2017, 10:16 PM
Freezemage
Freezemage - avatar
7th Oct 2017, 1:49 AM
Paulo Matsuda Ueno
19th Oct 2017, 8:52 AM
m_sudhu
m_sudhu - avatar