304 North Cardinal St.
Dorchester Center, MA 02124

# Xor Palindrome CodeChef Solution

## Xor Palindrome CodeChef Solution in C++17

``````#include <iostream>
using namespace std;

int main()
{
int t;
cin>>t;
while (t--)
{
int n,c=0;
cin>>n;
string s;
cin>>s;
for(int i=0;i<(n+1)/2;i++)
{
if(s[i]!=s[n-i-1])
c++;
}

cout<<(c+1)/2<<endl;
}

return 0;
}``````

## Xor Palindrome CodeChef Solution in C++14

``````#include <iostream>
using namespace std;

int main()
{
int t;
cin>>t;
while (t--)
{
int n,c=0;
cin>>n;
string s;
cin>>s;
for(int i=0;i<(n+1)/2;i++)
{
if(s[i]!=s[n-i-1])
c++;
}

cout<<(c+1)/2<<endl;
}

return 0;
}``````

## Xor Palindrome CodeChef Solution in PYTH 3

``````# cook your dish here
for _ in range(int(input())):
n = int(input())
s = input()
count_entries_to_be_changed = 0
for i in range(n//2):
if s[i] != s[n-i-1]:
count_entries_to_be_changed += 1

print(count_entries_to_be_changed//2 + count_entries_to_be_changed%2)``````

## Xor Palindrome CodeChef Solution in C

``````#include <stdio.h>

int main(void)
{
int t;
scanf("%d",&t);
for( int j=0;j<t;j++)
{
int n,count=0;
scanf("%d",&n);
char a[n];
scanf("%s",a);
for(int i=0; i<(n/2);i++)
{
if(a[i]!=a[n-i-1])
{
count ++;
}
}
printf("%d\n",(count+1)/2);
}
return 0;
}

``````

## Xor Palindrome CodeChef Solution in JAVA

``````/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Codechef
{
public static void main (String[] args) throws java.lang.Exception
{
Scanner sc=new Scanner(System.in);
int t=sc.nextInt();
for(int j=0;j<t;j++)
{
int n=sc.nextInt();
String s=sc.next();int count1=0;int count0=0;
for(int i=0;i<n/2;i++)
{
if(s.charAt(i)!=s.charAt(n-i-1))
{
count0++;
}
}
System.out.println((count0+1)/2);

}
}
}``````

## Xor Palindrome CodeChef Solution in PYPY 3

``````for _ in range(int(input())):
n=int(input())
s=input()
count=0
for i in range(n//2):
count += s[i]!=s[n-i-1]
print((count+1)//2)``````

## Xor Palindrome CodeChef Solution in PYTH

``````t = int(raw_input())
for i in range(t):
N = int(raw_input())
st = raw_input().strip()
r = 0
for p in range(N/2):
if st[p] != st[N-1-p]:
r += 1
# endif
# endfor p
n = r/2 + r%2
print n
# endfor i
``````

## Xor Palindrome CodeChef Solution in C#

``````using System;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.Text;
using System.Numerics;

public class Test
{
public static void Main()
{
var WS = new StringBuilder();
int A = GetInt();
while(A-- != 0){
int i=0;
int j=n-1;
int op=0;
while(i<j){
if(str[i]!=str[j])
op++;
i++;
j--;
}
WS.Append(op/2 + op%2 + "\n");
}

Console.WriteLine(WS.ToString());
}

public static void Writex(string s) => (Console.WriteLine(s));
public static int GetInt() => int.Parse(Console.ReadLine());
public static long GetLong() => long.Parse(Console.ReadLine());
public static string GetString() => (Console.ReadLine());

public static string[] GetStringArray() => Console.ReadLine().Trim().Split(' ');
public static int[] GetIntArray() => Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
public static long[] GetLongArray() =>  Console.ReadLine().Trim().Split(' ').Select(long.Parse).ToArray();
}``````

## Xor Palindrome CodeChef Solution in NODEJS

``````process.stdin.resume();
process.stdin.setEncoding('utf8');

var stdin_input = "";

process.stdin.on("data", function (input) {
stdin_input += input;
});

process.stdin.on("end", function () {
main(stdin_input);
});

function main(input) {
input = input.split("\n");
const testCases = Number(input[0]);
let j = 1;
for(let i=0;i<testCases;i++) {
let n = Number(input[j]);
j++;
console.log(getMax(n,convertToNumber(input[j].split(""))));
j++;
}
}

function getMax(n,arr) {
let left = 0;
let right = n-1;
let count=0;
while(left<right) {
if(arr[left]!=arr[right]) {
count++;
}
left++;
right--;
}
return Math.ceil(count/2);
}

function convertToNumber(arr) {
return arr.map((a)=> {
return Number(a);
});
}``````

## Xor Palindrome CodeChef Solution in GO

``````package main

import (
"fmt"
"math"
)

func main() {
var T int
fmt.Scan(&T)
for i:=0; i<T; i++ {
var N int
fmt.Scan(&N)
var a string
fmt.Scan(&a)
var zeros1 int = 0
var ones1 int = 0
var zeros2 int = 0
var ones2 int = 0
for j:=0; j<N/2; j++ {
if (a[j] == '1' && a[N-1-j] == '0') {
ones1 += 1
zeros2 += 1
} else if a[j] == '0' && a[N-1-j] == '1' {
zeros1 += 1
ones2 += 1
}
}

var first int = zeros1 + (ones1+1)/2
var second int = zeros2 + (ones2+1)/2
var third int = zeros1+zeros2
var fourth int = (ones1+ones2+1)/2
fmt.Println(math.Min(float64(first), math.Min(float64(second), math.Min(float64(third), float64(fourth)))))
}
}``````
##### Xor Palindrome CodeChef Solution Review:

In our experience, we suggest you solve this Xor Palindrome CodeChef Solution and gain some new skills from Professionals completely free and we assure you will be worth it.

If you are stuck anywhere between any coding problem, just visit Queslers to get the Xor Palindrome CodeChef Solution.

Find on CodeChef

##### Conclusion:

I hope this Xor Palindrome CodeChef Solution would be useful for you to learn something new from this problem. If it helped you then don’t forget to bookmark our site for more Coding Solutions.

This Problem is intended for audiences of all experiences who are interested in learning about Programming Language in a business context; there are no prerequisites.

Keep Learning!