Physical Address

304 North Cardinal St.
Dorchester Center, MA 02124

Tweedle-Dee and Tweedle-Dum CodeChef Solution

Problem -Tweedle-Dee and Tweedle-Dum 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.

Tweedle-Dee and Tweedle-Dum CodeChef Solution in C++14

#include <iostream>
using namespace std;

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

Tweedle-Dee and Tweedle-Dum CodeChef Solution in PYTH 3

# cook your dish here
for  _ in range(int(input())):
    
    n,p = input().split()
    
    n = int(n)
    
    a = [int(j) for j in input().split()]
    
    if(n==1):
        if(a[0]%2==0 and p=="Dee"):
            print("Dee");
        else:
            print("Dum")
    else:
        print("Dum")

Tweedle-Dee and Tweedle-Dum CodeChef Solution in C

#include<stdio.h>
int main()
{
    int count;
    for(scanf("%d", &count);count;count--)
    {
        int a;
        
        char name[3];
        
        int b, c, d;
        
        scanf("%d%*c%c%c%c", &a, &name[0], &name[1], &name[2]);
        
        int arr[a];
        
        
        for(b=0;b<a;b++)
        
        {
            
            scanf("%d", &arr[b]);
            
        }
        if(a==1 && name[1]=='e' && arr[0]%2==0)
        
        printf("Dee\n");
        
        else printf("Dum\n");
    }
    return 0;
}

Tweedle-Dee and Tweedle-Dum 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
	{
		BufferedReader reader=new BufferedReader(new InputStreamReader(System.in));
		BufferedWriter writer=new BufferedWriter(new OutputStreamWriter(System.out));
		int tt=Integer.parseInt(reader.readLine().trim());
		while(tt-->0){
		    String[] parts=reader.readLine().split("\\s+");
		    int n=Integer.parseInt(parts[0]);
		    String p=parts[1].trim();
		    int even=0, odd=0;
		    int[] a=parseInt(reader.readLine());
		    for(int i: a){
		        if((i&1)!=0){
		            odd++;
		        }else{
		            even++;
		        }
		    }
		    int dee=(int)Math.floor(even/2.0);
		    if(p.equals("Dee")){
		        dee=(int)Math.ceil(even/2.0);
		    }
		    if(dee>(odd+2*(n-dee))){
		        writer.write("Dee\n");
		    }else{
		        writer.write("Dum\n");
		    }
		}
		writer.flush();
	}
	
    
    private static int[] parseInt(String str) {
        String[] parts=str.split("\\s+");
        int[] ans=new int[parts.length];
        for(int i=0;i<ans.length;i++){
            ans[i]=Integer.parseInt(parts[i]);
        }
        return ans;
    }

    private static long[] parseLong(String str) {
        String[] parts=str.split("\\s+");
        long[] ans=new long[parts.length];
        for(int i=0;i<ans.length;i++){
            ans[i]=Long.parseLong(parts[i]);
        }
        return ans;
    }
}

Tweedle-Dee and Tweedle-Dum CodeChef Solution in PYPY 3

t=int(input())
for j in range(t):
    n,m=input().split()
    a=list(map(int,input().split()))
    if(int(n)==1 and a[0]%2==0 and m=='Dee'):
        print('Dee')
    else:
        print('Dum')

Tweedle-Dee and Tweedle-Dum CodeChef Solution in PYTH

t = int(raw_input())
for i in xrange(t):
	st = raw_input().split()
	N = int(st[0])
	P = st[1]
	st = raw_input().split()
	n = int(st[0])
	rst = 'Dum'
	if (P == 'Dee') and (n%2 == 0) and (N == 1):
		rst = 'Dee'
	# endif
	print rst
# endfor i

Tweedle-Dee and Tweedle-Dum CodeChef Solution in C#

using System;
using System.Collections;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args)
    {
        try
        {
            int cases = Convert.ToInt32(Console.ReadLine());
            for (int i = 0; i < cases; i++)
            {
                string[] input = Console.ReadLine().Split(' ');
                int numberOfHeaps = Convert.ToInt32(input[0]);
                string[] heapSizesString = Console.ReadLine().Split(' ');
                int[] heapSizes = new int[50];
                int j =0;
                foreach (var v in heapSizesString)
                {
                    heapSizes[j] = Convert.ToInt32(v);
                } 
                string firstPlayer = input[1];
                if (firstPlayer == "Dee" && numberOfHeaps == 1 && (heapSizes[0] % 2 == 0))
                {
                    Console.WriteLine("Dee");
                }
                else {
                    Console.WriteLine("Dum");
                }
            }
        }
        catch { }
        }
}

Tweedle-Dee and Tweedle-Dum CodeChef Solution in NODEJS

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

var arr = '';
process.stdin.on('data', function (chunk) {
    arr += chunk;
});

process.stdin.on('end', function () {
    arr = arr.split('\n');
    let t = Number(arr.shift());
    loop: for (let s = 0; s < t; s++) {
      let [n, p] = arr[s*2].split(' ');
      n = Number(n);
      const nArray = arr[s*2+1].split(' ');
      console.log(n===1 && !(nArray[0]&1) ? p : 'Dum');
    }
});

Tweedle-Dee and Tweedle-Dum CodeChef Solution in GO

package main

import (
	"fmt"
)

func main() {
	var T, n, k int
	var s string
	fmt.Scan(&T)
	for ; T > 0; T-- {
		fmt.Scan(&n, &s)
		for i := 0; i < n; i++ {
			fmt.Scan(&k)
		}

		if s == "Dee" && n == 1 && k%2 == 0 {
			fmt.Println("Dee")
		} else {
			fmt.Println("Dum")
		}
	}
}
Tweedle-Dee and Tweedle-Dum CodeChef Solution Review:

In our experience, we suggest you solve this Tweedle-Dee and Tweedle-Dum 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 Tweedle-Dee and Tweedle-Dum CodeChef Solution.

Find on CodeChef

Conclusion:

I hope this Tweedle-Dee and Tweedle-Dum 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 *