# Hackerrank Day 6 Lets Review 30 days of code solution

In this HackerRank Day 6 Let's Review 30 days of code problem we have Given a string, s , of length n that is indexed from 0 to n-1, print its even-indexed and odd-indexed characters as 2 space-separated strings on a single line.

## Problem solution in Python 2 programming.

```# Enter your code here. Read input from STDIN. Print output to STDOUT
N = int(raw_input().strip())
for i in range(N):
str = raw_input().strip()
funny = True
for j in range(len(str)/2 + 1):
if abs(ord(str[j+1]) - ord(str[j])) != abs(ord(str[len(str)-j-2]) - ord(str[len(str)-j-1])):
funny = False
break
if funny:
print "Funny"
else:
print "Not Funny"```

## Problem solution in Python 3 programming.

```# Enter your code here. Read input from STDIN. Print output to STDOUT

n = int(input())
temp = []
for i in range(0,n):
s = input()
temp.append(s)

for i in range(0,n):
for j in range(0,len(temp[i]),2):
print(temp[i][j],end='')
print(end=' ')
for j in range(1,len(temp[i]),2):
print(temp[i][j],end='')
print()
```

### Problem solution in java programming.

```import java.io.*;
import java.util.*;

public class Solution {

public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
sc.nextLine();
for(int i=0;i<n;i++){
String s = sc.nextLine();
String r = new StringBuilder(s).reverse().toString();
char sArr[] = s.toCharArray();
char rArr[] = r.toCharArray();
int j = 1;
int k = s.length();
int flag = 1;
while(j < k){
if(Math.abs(sArr[j]-sArr[j-1]) != Math.abs(rArr[j]-rArr[j-1])){
System.out.println("Not Funny");
flag = 0;
break;
}
++j;
}
if(flag == 1){
System.out.println("Funny");
}
}
}
}```

### Problem solution in c++ programming.

```#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;

int main() {
int T;
int test;
int N;
cin>>T;
string S;
for(int j=0;j<T;j++){
cin>>S;
test=1;
N=S.size();
for(int i=1;i<N;i++){
if(abs(S[i]-S[i-1])!=abs(S[N-i]-S[N-i-1])){
test=0;
break;
}
}
if(test==0){
cout<<"Not Funny"<<endl;
} else{
cout<<"Funny"<<endl;
}

}
return 0;
}```

### Problem solution in c programming.

```#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>

int main() {

/* Enter your code here. Read input from STDIN. Print output to STDOUT */
int n,i; // n number of arrays,

scanf("%d",&n);
// malloc an array of n char array pointers.
char **array = (char**) malloc(sizeof(char *)*n);

// allocate memory for each of the char array pointers
for(i=0;i<n;i++) {
array[i] = malloc(sizeof(char)*20000);
scanf("%s",array[i]);
}

for(i = 0; i < n; i++) {
int end = strlen(array[i]) - 2;
int funnyFlag = 1;

for(int j = 1; j < strlen(array[i]) - 1; j++) {

if(abs(array[i][j] - array[i][j - 1]) != abs(array[i][end] - array[i][end+1])) {
funnyFlag = 0;
break;
}

end--;
}

if(funnyFlag == 1){
printf("Funny\n");
}else {
printf("Not Funny\n");
}
free(array[i]);
}

free(array);
return 0;
}```

### Problem solution in Javascript programming.

```function funnyOrNot(word) {
var sval;
var rval;
var j = word.length - 1;

for (var i = 1; i < word.length; i++) {
sval = Math.abs(word.charCodeAt(i) - word.charCodeAt(i - 1));
rval = Math.abs(word.charCodeAt(j) - word.charCodeAt(j - 1));
//process.stdout.write(sval + " " + rval + "\n");
if (sval !== rval) {
process.stdout.write("Not ");
break;
}
j--;
}

process.stdout.write("Funny\n");
}

function processData(input) {
var pieces = input.split('\n');
for (var i = 0; i < parseInt(pieces[0]); i++) {
funnyOrNot(pieces[i+1]);
}
}

process.stdin.resume();
process.stdin.setEncoding("ascii");
_input = "";
process.stdin.on("data", function (input) {
_input += input;
});

process.stdin.on("end", function () {
processData(_input);
});```