Ruby Code:

a = gets.strip
b = []
c = []
for i in 0 .. a.length / 2
  b.push(a[i])
  c.push(a[a.length - i - 1])
end
if b == c
  puts "It's palindrome."
end

ECMAScript/JavaScript Code:

"use strict";

process.stdin.on('data', function (a) {
  a = a.toString().trim();
  var b = [],
      c = [];
  for (var i = 0; i < a.length / 2; ++i) {
    b.push(a[i]);
    c.push(a[a.length - i - 1]);
  }
  if (b.toString() == c.toString()) {
    console.log("It's palindrome.");
  }
  return process.exit();
});

CoffeeScript Code:

process.stdin.on 'data', (a) ->
  a = a.toString().trim()
  b = []
  c = []
  for i in [0 .. a.length / 2]
    do (i) ->
      b.push(a[i])
      c.push(a[a.length - i - 1])
  if (b.toString() == c.toString())
  console.log "It's palindrome."
  process.exit 0
Comments
Write a Comment