HackerRank Tower Breakers Problem Solution
HackerRank Tower Breakers Problem Solution
HackerRank Tower Breakers Problem Solution
HackerRank
CLOSE ADS Tower Breakers problem solution CLOSE ADS
In this HackerRank Tower Breakers problem solution, Two players are playing a game of
Tower Breakers! Player 1 always moves first, and both players always play optimally. The
rules of the game are as follows:
If the current player is unable to make a move, they lose the game.
Given the values of N and M, determine which player will win. If the first player wins,
return 1. Otherwise, return 2.
Subscribe To Channel
Programmingoneonone
YouTube 797
}
}
int main() {
int n,x,y;
cin>>n;
do{
cin>>x>>y;
(y==1||x%2==0)?cout<<"2"<<endl:cout<<"1"<<endl;
n--;
}while(n>0);
/* Enter your code here. Read input from STDIN. Print output
to STDOUT */
Metastatic Breast Cancer Symptoms Women
return 0;
Breast Cancer Symptoms | Search Ads
breast-cancer-in.life >
}
Problem solution in C.
CLOSE ADS CLOSE ADS
Code
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
int main() {
int n;
scanf("%d", &n);
for(int testcase = 0; testcase < n; testcase++) {
int num_towers;
int height;
scanf("%d %d", &num_towers, &height);
if(height == 1 || num_towers % 2 == 0)
printf("2\n");
else
printf("1\n");
}
return 0;
}
Facebook Twitter
UNKNOWN
CLOSE ADS CLOSE ADS
March 11, 2022 at 10:30 AM
C# code by me
Reply Delete
Replies
Reply
UNKNOWN
March 27, 2022 at 7:32 AM
Reply Delete
Replies
Reply
UNKNOWN
April 10, 2022 at 11:30 PM
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.Collections;
using System.ComponentModel;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.Serialization;
using System.Text.RegularExpressions;
using System.Text;
using System;
class Result
{
/*
* Complete the 'towerBreakers' function below.
*
* The function is expected to return an INTEGER.
* The function accepts following parameters:
* 1. INTEGER n
* 2. INTEGER m
*/
class Solution
{ Metastatic Breast Cancer Symptoms Women
{
Breast Cancer Symptoms | Search Ads
public static void Main(string[] args)
breast-cancer-in.life >
TextWriter textWriter = new
StreamWriter(@System.Environment.GetEnvironmentVariable("OUTPUT_PATH"), true);
int t = Convert.ToInt32(Console.ReadLine().Trim());
int n = Convert.ToInt32(firstMultipleInput[0]);
int m = Convert.ToInt32(firstMultipleInput[1]);
textWriter.WriteLine(result);
}
textWriter.Flush();
textWriter.Close();
}
}
Reply Delete
Replies
Reply
NAVEEN NEELAM
July 31, 2022 at 10:05 AM
function towerBreakers(n, m) {
Reply Delete
Replies
Reply
Add comment
To leave a comment, click the button below to sign in with Blogger.