TIC-TAC-TOE
ravan's dream is to win the tic-tac-toe champions to accomplish this,the practices alone at home to learn the strategies in the game your task is to identify the cell where ravan should place his 3rd piece so that be wins the game Assume that each cell in the tic-tac-toe board is marked with number as shown in the table below
tic tac toe
0 1 2
3 4 5
6 7 8
input:
the 1st line of input contains two space-separated integers represetation the cells where ravan has placed his 1st two piece
i/P:
0 1
o/P: 2
i/p: 0 3
o/p:6
substring:
you are given two strings N &K your goal is to determine the smallest substring of N that contains all the characters in K If no substring present in N print No matches found
note: if a character is repeated multiple time in K your substring should also contain that character repeated the same no.of times
i/p:the 1st line input two strings N&K
input:
stealen lent
o/p:
tealen
i/p:
tomato tomatho
no matches found
Discount sale:
it is a summer discount sale in mumbai and all the local shops have put up various offers Arjun selected N items to buy while standing in the building queue,he noticed the offer "buy two !" get two FREE!".this means that for every two items he buys they give him two items for free however ,items can be of varying prices they always charge for two most costly items and give the other two as free.Arjun is confused with grouping his items to reduce the total price he has to pay your task is to find the minimum price arjun has to pay to buy all the N items
input:the 1st line contains a single integer N
the 2nd line has N space-separated integers representing the cost of items
input:
4
1 1 2 2
o/p:4
i/p:
2
10 200
output:
210
candies:
Rose bought 3 boxes of candies each box contains candies only of one specific flavor
box1:blue raspberry flavor
box2:butterscotch flavor
box3:cherry flavor
each day rose eats exactly two candies flavor(she won't eat two candies of the same flavor in a day)she won't eat more than 2 candies or 1 candy in a day .your task is to find the maximum number of days rose can keep eating candies.
input:
the 1st line input contains 3 space-separated integers A,B,C denoting the no.of blue raspberry, butterscatch and cherry candies respectively
input: 1 1 1
output:1
i/p:1 2 1
o/p:2
Write a program to print the following,
Input
The first line contains a string representing a scrambled word.
The second line contains some space-separated strings representing words guessed by the player.
Output
The output should be a single integer of the final score.
Explanation
scramble word = "tacren"
guessed words = ["trance", "recant"]
Since "trance" and "recant" both have length 6 then you score 54 pts each.
So the output is 108.
Sample Input1
tacren
trance recant
Sample Output1
108
Number of moves:
you are given a nxn square chessboard with one bishop and k number of obstacles placed on it. A bishop can go to different places in a single move. find the total no.of places that are possible for the bishop in a single move. Each square is referenced by a type describing the row, R, and column, C, where the square is located.
explanation: given N=6 K=2
bishop position 5 2
obstacle positions (2 2), (1 5)
the bishop can move in so o/p is 6
I/p:
6 2
5 2
2 2
1 6
O/p:
6
I/p:
6 4
3 3
1 3
3 1
5 1
1 5
O/p: 7
Write a program that requests the user for a year (you can assume the year will always be at
least 2000), the population of Brazil in that year (in terms of millions of people) and the annual
population growth rate (always as a real number in the range 0 – 1), and then uses the two
methods written above to determine and display the year in which Brazil’s population first
exceeded/exceeds 180 million people. The program must also display Brazil’s total population
in this year.
a) Write a method PopulationTotal that accepts 2 positive values, namely the current
population (in millions, e.g. a value of 1.5 means 1.5 million people) and the growth rate (e.g.
0.14 means 14%). The method determines and returns the total population based on the current
population and growth rate. For example, if the current population for a country is 1.165 million
people, and the annual population growth rate is 10%, then the total population is 1.2815 million
people after 1 year.
b) Write a method Over180Million that accepts a positive value representing the population (in
millions). The method determines whether the population is over 180 million people, and returns
a value of true if this is so, otherwise returns a value of false.
Program
Write a program to print the following, Given a word W and pattern P, you need to check whether the pattern matches the given word.The word will only contain letters(can be Uppercase and Lowercase). The pattern can contain letters, ? and *.
? : Can be matched with any single letter.
* : Can be matched with any sequence of letters (including an empty sequence).If the pattern matches with the given word, print True else False.
Sample input 1
3
Hello Helll*
Hell He*ll
Hell hell*
Sample output 1
True
True
False
Sample Input 2
3
Hello *l?
Hell He?ll
Hell ?*
Sample Output 2
True
False
True
Instructions:
1. Input a random positive integer. Then, create an integer array with a size the same as the inputted integer.
2. Then, using loops, add random integer values into the array one by one. The number of values to be stored is dependent on the inputted odd integer on the first instruction.
3. Print out the list's new order in this manner, with each number separated by a space per row:
second-half values
middle value
first-half values
Refer to the sample output for a clearer view on how it is to be printed out.
Input
The first line contains an odd positive integer. It is guaranteed that this integer is greater than or equal to 3.
The next lines contains an integer.
5
1
3
4
5
2
Output
A line containing grouped arrays.
{2,5}-{4}-{3,1}