Weird Palindrome Making CodeChef Solution

Problem -Weird Palindrome Making CodeChef Solution

This website is dedicated for CodeChef solution where we will publish right solution of all your favourite CodeChef problems along with detailed explanatory of different competitive programming concepts and languages.

Weird Palindrome Making CodeChef Solution in C++17

#include <iostream>
using namespace std;

int main() {
	// your code goes here
	long long t;
	cin>>t;
	while(t--){
	    long long n;
	    cin>>n;
	    long long c=0;
	    long long a[n];
	    for(int i=0; i<n; i++){
	        cin>>a[i];
	        if(a[i]%2!=0){
	            c++;
	        }
	    }
	    if(c<=1){
	        cout<<0<<endl;
	    }
	    else if(c==2){
	        cout<<1<<endl;
	    }
	    else{
	        cout<<c/2<<endl;
	    }
	    
	}
	return 0;
}

Weird Palindrome Making CodeChef Solution in C++14

//Weird Palidrome Making

#include <iostream>
#define ll long long
using namespace std;

void Solve(){
    int N;
    cin >> N;
    
    int cnt = 0;
    
    ll x;
    for( int i = 0; i < N; i++){
        cin >> x;
        if((x & 1) == 1) cnt++;
    }
    cout << cnt / 2 << "\n";
    
    
}

int main() {
	// your code goes here
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
	int T;
	cin >> T;
	while(T --){
	    Solve();
	}
	return 0;
}

Weird Palindrome Making CodeChef Solution in PYTH 3

# cook your dish here
for _ in range(int(input())):
    n = int(input())
    ch = [int(x) for x in input().split()]
    o = 0
    for c in ch:
        if c%2==1:  o+=1
    print(int(o/2))
        

Weird Palindrome Making CodeChef Solution in C

#include <stdio.h>
#define ml long long int 
int main() 
{
    ml t;
    scanf("%lld",&t);
    while(t--)
    {
        ml num,value,mvar=0;
        
        scanf("%lld",&num);
        for(ml i=0;i<num;i++)
        {
            scanf("%lld",&value);
            if(value%2==1) mvar+=1;
        }
        if(mvar%2==1) mvar-=1;
        printf("%lld\n",mvar/2);
        
    }
    return 0;
}

Weird Palindrome Making CodeChef Solution in JAVA

import java.util.Scanner;
class WeirdPalindromeMaking
{
        public static void main(String[] args)
        {
            int checking;
            Scanner sc=new Scanner(System.in);
            checking=sc.nextInt();
            while(checking-->0)
            {
                int n,i,kcpd;
                n=sc.nextInt();
                int manam_manam_amalapuram[];
                manam_manam_amalapuram=new int[n];
                kcpd=0;
                for(i=0;i<n;i++)
                {
                     manam_manam_amalapuram[i]=sc.nextInt();
                     if(((manam_manam_amalapuram[i]>>1)<<1)!=manam_manam_amalapuram[i])
                     kcpd++;
                }
                if(((kcpd<<1)>>1)!=kcpd)
                kcpd--;
                System.out.println(kcpd>>1);
            }
            sc.close();
        }
}

Weird Palindrome Making CodeChef Solution in PYPY 3

for t in range(int(input())):
    n=int(input())
    a=input().split()
    odd=0
    for i in range(n):
        a[i]=int(a[i])
        if a[i]%2!=0:
            odd=odd+1
    print(odd//2)

Weird Palindrome Making CodeChef Solution in PYTH

t = int(raw_input())
for i in range(t):
	N = int(raw_input())
	st = raw_input().split()
	n = 0
	for x in st:
		n += int(x)%2
	# endfor x
	r = n/2
	print r
# endfor i

Weird Palindrome Making CodeChef Solution in C#

using System;
using System.Linq;
public class Test
{
	public static void Main()
	{
		// your code goes here
		  string line = Console.ReadLine();
	    int t= Convert.ToInt32(line);
	    
	    while(t>0)
	    {
            line = Console.ReadLine();
            line = Console.ReadLine();
            int[] a= line.Split(' ').Select(x=> Convert.ToInt32(x)).ToArray();
            int count =0;
            for(int i=0;i<a.Length;i++)
            {
                if(!(a[i]%2==0))
                  count++;
            }
            
            Console.WriteLine(count==0?0:count/2);
            
            t--;
            
	    }
	}
}

Weird Palindrome Making CodeChef Solution in NODEJS


process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });
    
    main();    
});

function readLine() {
    return inputString[currentLine++];
}

const getMaxLessThanK = (A) => {
    let c = 0;
    for(let i = 0 ; i < A.length; i++) {
        if(A[i] % 2 === 1) c++;
    }
    return c % 2 === 1 ? (c - 1) / 2 : c / 2;
}

function main() {
    const q = +(readLine());

    for (let i = 0; i < q; i++) {
        const N = +(readLine());
        const arr = readLine().split(' ').map(Number);
        console.log(getMaxLessThanK(arr));
    }
}

Weird Palindrome Making CodeChef Solution in GO

package main

import (
	"bufio"
	"bytes"
	"fmt"
	"os"
)

func main() {
	reader := bufio.NewReader(os.Stdin)
	var buf bytes.Buffer
	tc := readNum(reader)

	for tc > 0 {
		tc--
		n := readNum(reader)
		A := readNNums(reader, n)
		res := solve(A)
		buf.WriteString(fmt.Sprintf("%d\n", res))
	}

	fmt.Printf(buf.String())
}

func readInt(bytes []byte, from int, val *int) int {
	i := from
	sign := 1
	if bytes[i] == '-' {
		sign = -1
		i++
	}
	tmp := 0
	for i < len(bytes) && bytes[i] >= '0' && bytes[i] <= '9' {
		tmp = tmp*10 + int(bytes[i]-'0')
		i++
	}
	*val = tmp * sign
	return i
}

func readNum(reader *bufio.Reader) (a int) {
	bs, _ := reader.ReadBytes('\n')
	readInt(bs, 0, &a)
	return
}

func readTwoNums(reader *bufio.Reader) (a int, b int) {
	res := readNNums(reader, 2)
	a, b = res[0], res[1]
	return
}

func readThreeNums(reader *bufio.Reader) (a int, b int, c int) {
	res := readNNums(reader, 3)
	a, b, c = res[0], res[1], res[2]
	return
}

func readNNums(reader *bufio.Reader, n int) []int {
	res := make([]int, n)
	x := 0
	bs, _ := reader.ReadBytes('\n')
	for i := 0; i < n; i++ {
		for x < len(bs) && (bs[x] < '0' || bs[x] > '9') && bs[x] != '-' {
			x++
		}
		x = readInt(bs, x, &res[i])
	}
	return res
}

func readUint64(bytes []byte, from int, val *uint64) int {
	i := from

	var tmp uint64
	for i < len(bytes) && bytes[i] >= '0' && bytes[i] <= '9' {
		tmp = tmp*10 + uint64(bytes[i]-'0')
		i++
	}
	*val = tmp

	return i
}

func solve(A []int) int {
	// only need to change odd numbers to some odd number, and leave the max odd
	var cnt int
	for _, a := range A {
		if a%2 == 1 {
			cnt++
		}
	}
	return cnt / 2
}
Weird Palindrome Making CodeChef Solution Review:

In our experience, we suggest you solve this Weird Palindrome Making 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 Weird Palindrome Making CodeChef Solution.

Find on CodeChef

Conclusion:

I hope this Weird Palindrome Making 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!

More Coding Solutions >>

Cognitive Class Answer

CodeChef Solution

Microsoft Learn

Leave a Reply

Your email address will not be published. Required fields are marked *