0% found this document useful (0 votes)
40 views3 pages

Case Study For Data Science

The document describes two problems related to counting outcomes and holidays. The first problem involves calculating the prize money for the World Chess Championship based on the results of 14 games between two players. The second problem involves counting the total holidays in a 30-day month given that weekends and certain festival days are holidays.

Uploaded by

thiru
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
40 views3 pages

Case Study For Data Science

The document describes two problems related to counting outcomes and holidays. The first problem involves calculating the prize money for the World Chess Championship based on the results of 14 games between two players. The second problem involves counting the total holidays in a 30-day month given that weekends and certain festival days are holidays.

Uploaded by

thiru
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Python Case studies

Problem
The World Chess Championship 2022 is about to start. 14 Classical games will be played
between Chef and Carlsen in the championship, where each game has one of three
outcomes — it can be won by Carlsen, won by Chef, or it can be a draw. The winner of a
game gets 2 points, and the loser gets 0 points. If it’s a draw, both players get 1 point each.

The total prize pool of the championship is 100 ⋅ X. At end of the 14 Classical games, if one
player has strictly more points than the other, he is declared the champion and gets 60 ⋅ X
as his prize money, and the loser gets 40 ⋅ X.
If the total points are tied, then the defending champion Carlsen is declared the winner.
However, if this happens, the winner gets only 55 ⋅ X, and the loser gets 45 ⋅ X.
Given the results of all the 14 games, output the prize money that Carlsen receives.
The results are given as a string of length 14 consisting of the characters C, N, and D.
 C denotes a victory by Carlsen.
 N denotes a victory by Chef.
 D denotes a draw.

Input Format
 The first line of input contains an integer T, denoting the number of test cases. The description
of T test cases follows.
 The first line of each test case contains one integer X, denoting that the total prize pool is 100⋅X.
 The second line contains the results of the match, as a string of length 14 containing only the
characters C, N, and D.

Output Format
For each test case, output in a single line the total prize money won by Carlsen.

Constraints
 1≤T≤1000
 1≤X≤106
 ∣S∣=14
 S contains only characters D, C, N.

Subtasks
Subtask #1 (100 points): Original constraints

Sample 1:
Input
4
100
CCCCCCCCCCCCCC
400
CDCDCDCDCDCDCD
30
DDCCNNDDDCCNND
1
NNDNNDDDNNDNDN

Output

6000
24000
1650
40

Problem
A particular month has 30 days, numbered from 1 to 30.
Day 1 is a Monday, and the usual 7-day week is followed (so day 2 is Tuesday, day 3 is
Wednesday, and so on).
Every Saturday and Sunday is a holiday. There are N festival days, which are also holidays.
Note that it is possible for a festival day to occur on a Saturday or Sunday.

You are given the dates of the festivals. Determine the total number of holidays in this
month.

Input Format
 The first line of input contains a single integer T, denoting the number of test cases. The
description of T test cases follows.
 The first line of each test case contains an integer N denoting the number of festival days.
 The second line of each test case contains N distinct space-separated integers A1,A2,…AN,
denoting the festival days. Note that the Ai are not necessarily given in sorted order.

Output Format
For each test case, output a new line containing the total number of holidays.

Constraints
 1≤T≤1000
 1≤N≤30
 1≤Ai≤30
 All the Ai are distinct

Sample 1:
Input
3
2
57
3
23 1 6
1
13

Output

9
10
8

You might also like