You are given an array of N non-negative integers: A1, A2., AN An alternating subsequence is a subsequence in which the indices of any two consecutive elements differ by exactly two in the original array. That is if Ai1, Ai2., Aik is some subsequence then for it to be an alternating subsequence, (i2 - i1 = 2), (i3 - i2 = 2), and so on should all hold true. Among all alternating subsequences, find the one which has maximum sum of elements and output that sum
First line of the input contains an integer T denoting the number of test cases.
The first line of each test case contains an integer N denoting the number of elements in the array. Second line contains N space-separated integers A1, A2, ..., AN denoting the array A
Input:
1
3
1 2 5
Output:
6For the given array [1, 2, 5], there are 7 non-empty subsequences out of which there are 4 alternating subsequences. These will be {[1], [2], [5], [1, 5]}. The alternating subsequence [1, 5] will have the largest sum i.e 6.
Plot on the same figure the calculated acceleration and the classification variable ds mapping against time. Use left side y-axis and a line style to plot the acceleration. Use right side y-axis to illustrate the driving style classification. Hint: You may use plotyy to complete this task. Add labels to all axes. Add legend to the figure.
Table 1 below : Example of classification
acceleration value
-1.2 1
1.23 1
3.2 2
-4.3 3
9.5 0
ds mapping values
1
1
2
3
Rules:
1. Play a simple Black Jack game.
2. The player will get two cards first.
3. If the player get black Jack (21 points or two Aces), the player won and does not need to draw the third card.
4. If not, ask if the player wanted to draw the third card.
5. If the player get points less than 22, he won, else he lost.
Points:
1. J, Q and K is 10 points.
2. A is 11 points, but it will become 1 point if the player chooses to draw the third card.
3. Add up the points from the cards and show the final result.
Machine Problem 2
Create a Python script that will generate random n integers from a given start and end of a range.
Sample Output:
Value for n :5
Value for start: 1
Value for end : 10
10 8 7 8 3
Machine problem 3
In the game Rock Paper Scissors, two players simultaneously choose one of the three options: rock, paper, scissors. If both player choose the same option, then the result is a tie. However, if they choose differently, the winner is determined as follows:
• Rock beats scissors, because a rock can break a pair of scissors
• Scissors beats paper, because scissors can cut paper
• Paper beats rock, because a piece of paper can cover a rock
Create a Python script in which a computer randomly choose rock, paper or scissors. Let the user enter a number 1, 2, or 3 each representing one of the three choices. Then, determine the winner.
Machine Problem 1
Number Guessing Game
In the number guessing game, the computer will randomly select a number from a range of numbers e.g. 1-100 and then the game will give the player five attempts to guess the number.
Gameplay:
• If the player's guess is higher than the chosen number, the program will tell the player to try another LOWER than the previous guess.
• If the player's guess is lower than the chosen number, the program will tell the player to try another number HIGHER than the previous guess.
■ If the player guesses the number before he consumes the five attempts, then display congratulatory message.
Use: 8086 Assembler,
Code a program that will form a trees, use the word below. with different color in every word.
T R E E S
I think that I shall never see
A poem lovely as a tree A tree whose
hungry mouth is pressed Against the
sweet earth’s flowing breast A tree
that looks at God all day And lifts her
leafy arms to pray A tree that may in
summer wear A nest of robins
in her hair Upon whose bosom snow
has lain Who intimately lives with
rain Poems are made by fools
like me
But only
God can
Make
a tree
JOYCE KILMER
Using Python class Person, write a program that will generate the output below:
Hello, my name is Bob and I am 25 years old!