Skip to content

Instantly share code, notes, and snippets.

@FiloSottile
Last active December 29, 2015 08:29
Show Gist options
  • Save FiloSottile/7643628 to your computer and use it in GitHub Desktop.
Save FiloSottile/7643628 to your computer and use it in GitHub Desktop.

Basketball Game

A group of N high school students wants to play a basketball game. To divide themselves into two teams they first rank all the players in the following way:

  • Players with a higher shot percentage are rated higher than players with a lower shot percentage.
  • If two players have the same shot percentage, the taller player is rated higher.

Luckily there are no two players with both the same shot percentage and height so they are able to order themselves in an unambiguous way. Based on that ordering each player is assigned a draft number from the range [1..N], where the highest-rated player gets the number 1, the second highest-rated gets the number 2, and so on. Now the first team contains all the players with the odd draft numbers and the second team all the players with the even draft numbers.

Each team can only have P players playing at a time, so to ensure that everyone gets similar time on the court both teams will rotate their players according to the following algorithm:

  • Each team starts the game with the P players who have the lowest draft numbers.
  • If there are more than P players on a team after each minute of the game the player with the highest total time played leaves the playing field. Ties are broken by the player with the higher draft number leaving first.
  • To replace her the player on the bench with the lowest total time played joins the game. Ties are broken by the player with the lower draft number entering first.

The game has been going on for M minutes now. Your task is to print out the names of all the players currently on the field, (that is after M rotations).

Input

The first line of the input consists of a single number T, the number of test cases.

Each test case starts with a line containing three space separated integers N M P

The subsequent N lines are in the format "<name> <shot_percentage> <height>". See the example for clarification.

Constraints

1 ≤ T ≤ 50
2 * PN ≤ 30
1 ≤ M ≤ 120
1 ≤ P ≤ 5
Each name starts with an uppercase English letter, followed by 0 to 20 lowercase English letters. There can be players sharing the same name. Each shot percentage is an integer from the range [0..100]. Each height is an integer from the range [100..240]

Output

For each test case i numbered from 1 to T, output "Case #i: ", followed by 2 * P space separated names of the players playing after M rotations. The names should be printed in lexicographical order.

Example

In the first example if you sort all the players by their shot percentage you get the list: [Wai, Purav, Weiyan, Slawek, Lin, Meihong]. This makes the two teams:
[Wai, Weiyan, Lin]
[Purav, Slawek, Meihong]

The game starts with Lin and Meihong sitting on the bench in their respective teams. After the first minute passes it's time for Weiyan and Slawek to sit out since they have the highest draft numbers of the people who played. After the second minute passes Lin and Meihong will keep playing since they only played one minute so far and it's Wai and Purav who have to sit out. Finally after the third minute Lin and Maihong go back to the bench and all the players currently playing again are:
Purav Slawek Wai Weiyan

5
6 3 2
Wai 99 131
Weiyan 81 155
Lin 80 100
Purav 86 198
Slawek 80 192
Meihong 44 109
7 93 2
Paul 82 189
Kittipat 62 126
Thomas 17 228
Fabien 57 233
Yifei 65 138
Liang 92 100
Victor 53 124
6 62 3
Meihong 33 192
Duc 62 162
Wai 70 148
Fabien 19 120
Bhuwan 48 176
Vlad 30 225
8 59 3
Anil 38 180
Song 7 187
David 65 159
Lin 45 121
Ranjeeth 39 183
Torbjorn 26 181
Clifton 57 158
Phil 3 183
4 72 1
Anh 2 187
Erling 69 226
Purav 0 199
Zejia 29 163
Case #1: Purav Slawek Wai Weiyan
Case #2: Fabien Kittipat Liang Paul
Case #3: Bhuwan Duc Fabien Meihong Vlad Wai
Case #4: Anil Lin Phil Ranjeeth Song Torbjorn
Case #5: Erling Zejia

Problem number 1 of the Facebook Hacker Cup 2014 Qualification Round
This work is licensed under a Creative Commons Attribution-NonCommercial 3.0 Unported License.
https://www.facebook.com/hackercup/problems.php?pid=740733162607577&round=598486203541358

#!/usr/bin/env python3
#-*- coding:utf-8 -*-
import sys
INPUT = open(sys.argv[1])
class Player():
name = None
shot_percentage = None
height = None
draft = None
time_played = 0
T = int(INPUT.readline().strip())
for t in range(1, T + 1):
N, M, P = [int(x) for x in INPUT.readline().strip().split(' ')]
PLAYERS = []
for _ in range(N):
player = Player()
player.name, s, h = INPUT.readline().strip().split(' ')
player.shot_percentage, player.height = int(s), int(h)
PLAYERS.append(player)
PLAYERS.sort(reverse=True, key=lambda p: (p.shot_percentage, p.height))
for n, p in enumerate(PLAYERS):
p.draft = n + 1
TEAM_A = [p for p in PLAYERS if p.draft % 2 != 0]
TEAM_B = [p for p in PLAYERS if p.draft % 2 == 0]
PLAYING_A = TEAM_A[:P]
PLAYING_B = TEAM_B[:P]
for _ in range(M):
for TEAM, PLAYING in ((TEAM_A, PLAYING_A), (TEAM_B, PLAYING_B)):
if len(TEAM) == len(PLAYING): continue
for p in PLAYING: p.time_played += 1
BENCH = [p for p in TEAM if p not in PLAYING]
leaving = sorted(PLAYING, key=lambda p: (p.time_played, p.draft))[-1]
entering = sorted(BENCH, key=lambda p: (p.time_played, p.draft))[0]
PLAYING.remove(leaving)
PLAYING.append(entering)
BENCH.remove(entering)
BENCH.append(leaving)
print('Case #%i: ' % t + ' '.join(sorted(p.name for p in PLAYING_A + PLAYING_B)))
20
10 78 2
Xiao 51 110
Philip 18 141
Zejia 51 227
Anshuman 100 183
Tom 12 193
Erling 36 190
Philip 0 160
Zhen 4 203
Atol 57 106
Wesley 15 101
4 115 2
Manohar 16 215
Meihong 87 208
Anshuman 95 154
Nima 92 132
25 50 5
Aleksandar 34 200
Zihing 41 124
Andrii 14 226
Voja 91 228
Lin 83 182
Erling 53 150
Liang 74 233
Luiz 49 125
Atol 9 182
Yingsheng 82 170
Nima 71 228
Rudradev 99 142
Song 24 221
Chad 39 195
Bhuwan 54 146
Bhuwan 12 233
Zainab 88 180
Voja 79 135
Purav 79 203
Fabien 90 230
Nathan 12 148
Ranjeeth 75 133
Vladislav 88 148
Viswanath 61 158
Luiz 13 163
19 86 5
Andras 13 108
David 90 125
Vladislav 11 103
Erling 90 119
Doan 20 207
Torbjorn 8 147
Yifei 26 210
Sanjeet 81 126
Meihong 38 108
Chi 60 173
Lingjuan 15 175
Yingsheng 92 143
Dhruv 80 168
Yingsheng 20 105
Anh 11 187
Saransh 38 199
Vladislav 3 197
Wesley 64 197
Wai 62 181
19 109 3
Atol 21 171
Jan 56 128
Yintao 17 176
Ekansh 44 194
Jan 40 216
Ahmed 26 219
Victor 82 131
Amol 33 174
Doan 16 175
Zejia 9 214
Viswanath 68 139
Kittipat 93 124
Ajay 35 103
Anil 1 185
Paul 6 217
Zihing 34 196
Aravind 60 183
Rudradev 48 163
Wenjie 19 229
25 21 2
Keegan 80 196
Lin 47 184
Purav 21 142
Dhruv 8 198
Nima 9 233
John 57 141
Chi 40 176
Aravind 31 101
Oleksandr 97 240
Kittipat 91 208
Igor 28 178
Keegan 62 149
Vasily 89 103
Victor 59 107
Lin 57 140
Gaurav 3 195
Viswanath 69 178
Yintao 85 228
Saransh 97 129
Rajat 86 193
Jan 13 198
Anh 71 183
Anil 18 137
Sanjeet 12 180
Mehdi 28 129
25 103 2
Sharad 11 217
Aravind 22 127
Thomas 91 212
John 68 199
Josh 92 160
Doan 43 205
Weiyan 1 125
Dhruv 47 227
John 15 154
Tom 25 141
Viswanath 87 177
Rajat 42 150
Lovro 83 116
Rudradev 19 167
Mehdi 90 213
Paul 10 235
Xiao 27 100
Sharad 89 226
Steaphan 69 228
David 17 111
Steaphan 16 200
Liang 30 206
Victor 61 125
Sanjeet 74 216
Weiyan 64 185
24 119 3
Meihong 33 155
Lovro 46 175
Manohar 60 137
Nima 24 233
Erling 67 110
Viswanath 43 162
Andras 69 210
Yintao 59 116
Weitao 12 115
Weiyan 41 198
Erling 40 108
Weiyan 54 160
Yintao 88 211
Xiao 10 106
Chad 95 158
Weitao 28 124
Aleksandar 75 140
Wai 48 176
Anshuman 44 208
Anshuman 10 214
Bhuwan 32 231
Luiz 37 117
Josh 30 145
Lovro 33 175
19 1 4
Xiao 34 111
Ranjeeth 96 194
Luiz 46 224
Meihong 39 181
Andrei 46 176
Anil 46 113
Roman 61 197
Weitao 79 148
Andras 44 220
Nima 67 102
Weitao 79 193
Anh 74 234
Fabien 41 125
Weitao 65 214
Keegan 22 185
Zejia 10 217
Zihing 100 208
Philip 36 113
Steaphan 68 120
14 18 5
Jordan 38 176
Igor 95 146
Viswanath 39 130
Gaurav 62 118
Vladislav 97 231
Duc 54 102
Fabien 68 231
Rudradev 48 203
Doan 99 154
Thomas 11 142
Song 77 189
John 98 109
John 9 202
Liang 63 161
29 69 1
Duc 76 228
Ekansh 78 102
Erling 0 125
Wei 46 202
Steaphan 83 119
Zihing 57 175
Andrii 74 239
Fabien 59 177
Zihing 30 122
John 21 113
Roman 32 136
Rudradev 45 213
Rajat 33 138
Weiyan 8 173
Roman 18 182
Yintao 93 234
Erling 10 219
Chad 51 142
Liang 34 200
Ekansh 25 111
Erling 87 147
Zef 22 219
Kittipat 37 108
Tom 17 159
Aravind 4 109
Andriy 5 198
Sanjeet 68 239
Chad 7 220
Zainab 37 205
6 3 2
Wai 99 131
Weiyan 81 155
Lin 80 100
Purav 86 198
Slawek 80 192
Meihong 44 109
2 98 1
Lingjuan 65 193
Zejia 9 213
7 93 2
Paul 82 189
Kittipat 62 126
Thomas 17 228
Fabien 57 233
Yifei 65 138
Liang 92 100
Victor 53 124
30 104 4
Slawek 65 198
Zhen 15 233
Dmytro 26 215
Yintao 93 225
Oleksandr 35 169
Viswanath 14 197
Rajat 8 219
Anil 72 202
Meihong 97 114
Doan 76 222
Fabien 78 179
Jan 28 131
Chirag 40 233
Tom 98 102
Zejia 47 130
Paul 82 119
Steaphan 41 210
Duc 10 225
Xiao 13 207
Manohar 97 107
Dhruv 17 100
Weiyan 44 214
Anshuman 70 124
Yifei 69 153
Fabien 45 186
Xiao 63 120
Purav 34 157
Bhuwan 39 231
Saransh 51 219
John 35 126
7 52 1
John 61 186
Atol 62 231
Nathan 63 138
Lin 37 186
Daniel 37 171
Doan 99 226
Chad 37 196
24 80 3
Amol 52 169
David 35 118
Dmytro 37 222
Manohar 40 179
Roman 83 107
Tom 43 238
John 31 220
Tom 60 169
Paul 46 187
Steaphan 81 123
Andriy 26 103
Chad 99 101
Jan 31 129
Torbjorn 84 207
Slawek 28 159
Nathan 40 140
Daniel 61 129
Yintao 52 162
Ekansh 14 223
Sharad 53 232
Josh 51 174
Anil 86 206
Atol 0 218
Torbjorn 40 141
18 95 2
Liang 53 146
Wesley 12 197
Wenjie 86 238
Manohar 94 129
Anshuman 27 180
Chi 73 162
David 16 238
Purav 57 227
Wai 42 196
Chad 48 239
Zainab 46 175
Wai 98 114
Chi 45 209
Paul 17 135
Paul 10 171
Atol 23 162
Yifei 99 197
Wei 0 164
28 20 2
Yintao 12 206
Anh 11 178
Aleksandar 2 140
Jan 51 234
Kittipat 79 151
Zainab 71 169
Sanjeet 96 206
Wesley 74 201
Anh 27 184
Ahmed 73 171
Andrei 56 114
Dhruv 37 106
Ranjeeth 45 149
Lingjuan 77 113
Clifton 39 229
Ahmed 44 121
Ahmed 97 188
Lin 8 202
Slawek 39 174
Lingjuan 84 202
Zainab 30 130
Viswanath 70 107
Dmytro 1 115
Luiz 72 221
Steaphan 31 157
Gaurav 36 225
Liang 85 224
Anshuman 54 179
4 72 1
Anh 2 187
Erling 69 226
Purav 0 199
Zejia 29 163
Case #1: Philip Tom Wesley Zhen
Case #2: Anshuman Manohar Meihong Nima
Case #3: Atol Bhuwan Bhuwan Lin Nima Vladislav Voja Voja Yingsheng Zainab
Case #4: Andras Anh Doan Lingjuan Meihong Saransh Torbjorn Vladislav Vladislav Yingsheng
Case #5: Anil Aravind Jan Jan Victor Viswanath
Case #6: Anil Igor Purav Sanjeet
Case #7: Aravind Mehdi Weiyan Xiao
Case #8: Aleksandar Andras Anshuman Erling Manohar Xiao
Case #9: Anh Luiz Ranjeeth Roman Steaphan Weitao Weitao Zihing
Case #10: Doan Duc Gaurav John John Jordan Liang Rudradev Thomas Viswanath
Case #11: Aravind Ekansh
Case #12: Purav Slawek Wai Weiyan
Case #13: Lingjuan Zejia
Case #14: Fabien Kittipat Liang Paul
Case #15: Anil Doan Duc Fabien Manohar Paul Rajat Yintao
Case #16: Doan John
Case #17: Andriy David Dmytro Jan John Slawek
Case #18: Anshuman Atol Paul Wai
Case #19: Ahmed Anshuman Jan Ranjeeth
Case #20: Erling Zejia
cpdef double play_a_set(cache, int K, int won, int lost, double p_sun, double ps, double pr, double pu, double pw, double pd, double pl):
cdef double new_p_sun, positive
if won == K: return 1
if lost == K: return 0
if won * 1000 + lost * 10 + p_sun in cache:
return cache[won * 1000 + lost * 10 + p_sun]
positive = 0
## There is sun P: p_sun
#### He wins P: ps
###### p_sun changes P: pw
new_p_sun = min(1, p_sun + pu)
positive += p_sun * ps * pw * play_a_set(cache, K, won+1, lost, new_p_sun, ps, pr, pu, pw, pd, pl)
###### p_sun stays P: 1 - pw
positive += p_sun * ps * (1 - pw) * play_a_set(cache, K, won+1, lost, p_sun, ps, pr, pu, pw, pd, pl)
#### He loses P: 1 - ps
###### p_sun changes P: pl
new_p_sun = max(0, p_sun - pd)
positive += p_sun * (1 - ps) * pl * play_a_set(cache, K, won, lost+1, new_p_sun, ps, pr, pu, pw, pd, pl)
###### p_sun stays P: 1 - pl
positive += p_sun * (1 - ps) * (1 - pl) * play_a_set(cache, K, won, lost+1, p_sun, ps, pr, pu, pw, pd, pl)
## There is rain P: 1 - p_sun
#### He wins P: pr
###### p_sun changes P: pw
new_p_sun = min(1, p_sun + pu)
positive += (1 - p_sun) * pr * pw * play_a_set(cache, K, won+1, lost, new_p_sun, ps, pr, pu, pw, pd, pl)
###### p_sun stays P: 1 - pw
positive += (1 - p_sun) * pr * (1 - pw) * play_a_set(cache, K, won+1, lost, p_sun, ps, pr, pu, pw, pd, pl)
#### He loses P: 1 - pr
###### p_sun changes P: pl
new_p_sun = max(0, p_sun - pd)
positive += (1 - p_sun) * (1 - pr) * pl * play_a_set(cache, K, won, lost+1, new_p_sun, ps, pr, pu, pw, pd, pl)
###### p_sun stays P: 1 - pl
positive += (1 - p_sun) * (1 - pr) * (1 - pl) * play_a_set(cache, K, won, lost+1, p_sun, ps, pr, pu, pw, pd, pl)
cache[won * 1000 + lost * 10 + p_sun] = positive
return positive

Square Detector

You want to write an image detection system that is able to recognize different geometric shapes. In the first version of the system you settled with just being able to detect filled squares on a grid.

You are given a grid of N×N square cells. Each cell is either white or black. Your task is to detect whether all the black cells form a square shape.

Input

The first line of the input consists of a single number T, the number of test cases.

Each test case starts with a line containing a single integer N. Each of the subsequent N lines contain N characters. Each character is either "." symbolizing a white cell, or "#" symbolizing a black cell. Every test case contains at least one black cell.

Output

For each test case i numbered from 1 to T, output "Case #i: ", followed by YES or NO depending on whether or not all the black cells form a completely filled square with edges parallel to the grid of cells.

Constraints

1 ≤ T ≤ 20
1 ≤ N ≤ 20

Example

Test cases 1 and 5 represent valid squares. Case 2 has an extra cell that is outside of the square. Case 3 shows a square not filled inside. And case 4 is a rectangle but not a square.

5
4
..##
..##
....
....
4
..##
..##
#...
....
4
####
#..#
#..#
####
5
#####
#####
#####
#####
.....
5
#####
#####
#####
#####
#####
Case #1: YES
Case #2: NO
Case #3: NO
Case #4: NO
Case #5: YES

Problem number 1 of the Facebook Hacker Cup 2014 Qualification Round
This work is licensed under a Creative Commons Attribution-NonCommercial 3.0 Unported License.
https://www.facebook.com/hackercup/problems.php?pid=318555664954399&round=598486203541358

#!/usr/bin/env python3
#-*- coding:utf-8 -*-
import sys
T = int(sys.stdin.readline().strip())
for t in range(1, T + 1):
N = int(sys.stdin.readline().strip())
GRID = [sys.stdin.readline().strip() for i in range(N)]
# Find the the upper-left corner (J, I) and the edge K
for I, row in enumerate(GRID):
if not '#' in row: continue
K = 0
J = row.index('#')
for x in range(J, N):
if row[x] == '#': K += 1
else: break
break
# If the square would not fit, fail
if I + K > N:
print('Case #%i: NO' % t)
continue
# Build a module of how a row including the square should look like
MOD = (J * '.' + K * '#').ljust(N, '.')
# Check that the grid looks like what it should
for i, row in enumerate(GRID):
if i >= I and i < I + K:
if row != MOD: break
else:
if row != N * '.': break
else:
# Reached if we didn't break out of the loop
# Ok, I'll admit that for-else is not that clear
print('Case #%i: YES' % t)
continue
print('Case #%i: NO' % t)
20
4
..##
..##
....
....
20
####################
####################
####################
####################
####################
####################
####################
####################
####################
####################
####################
####################
####################
####################
####################
####################
####################
####################
####################
###################.
20
..############......
..############......
..############......
..############......
..############......
..############......
..############......
..############......
..############......
..############......
..############......
....................
....................
....................
....................
....................
....................
....................
....................
....................
1
#
20
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
...........#########
...........#########
...........#########
...........#########
...........#########
...........#########
...........#########
...........#########
...........#########
4
###.
.###
.###
....
5
#####
#####
#####
#####
.....
10
..........
..........
.##.......
.##.......
..........
..........
......##..
......##..
..........
..........
10
..........
..........
..........
.....#....
..........
..#.......
..........
..........
..........
..........
20
####################
####################
####################
####################
####################
####################
####################
####################
####################
####################
####################
####################
####################
####################
####################
####################
####################
####################
####################
####################
20
....................
################....
################....
################....
################....
################....
################....
################....
################....
################....
################....
################....
################....
################....
################....
################....
....................
....................
....................
....................
10
..........
..........
..........
..........
..........
..........
..........
..........
..........
.........#
10
..........
.######...
.#####.#..
.######...
.######...
.######...
.######...
..........
..........
..........
20
....................
....................
....................
....................
....................
....................
###.................
###.................
###.................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
...............#....
4
..##
..##
#...
....
20
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
..........######....
..........######....
..........######....
..........######....
..........######....
..........######....
....................
20
....................
....................
....................
....................
########..#######...
########..########..
##........##....##..
##........##....##..
########..#######...
########..########..
##........##....##..
##........##....##..
##........########..
##........#######...
....................
....................
....................
....................
....................
....................
10
..........
..........
.......###
.......###
.......###
..........
..........
..........
..........
..........
20
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
.......#####........
.......#####........
.......#####........
.......#####........
....................
....................
....................
....................
....................
10
..........
..........
..........
...##.....
...##.....
...##.....
..........
..........
..........
..........
Case #1: YES
Case #2: NO
Case #3: NO
Case #4: YES
Case #5: YES
Case #6: NO
Case #7: NO
Case #8: NO
Case #9: NO
Case #10: YES
Case #11: NO
Case #12: YES
Case #13: NO
Case #14: NO
Case #15: NO
Case #16: YES
Case #17: NO
Case #18: YES
Case #19: NO
Case #20: NO

Tennison

You may be familiar with the works of Alfred Lord Tennyson, the famous English poet. In this problem we will concern ourselves with Tennison, the less famous English tennis player. As you know, tennis is not so much a game of skill as a game of luck and weather patterns. The goal of tennis is to win K sets before the other player. However, the chance of winning a set is largely dependent on whether or not there is weather.

Tennison plays best when it's sunny, but sometimes of course, it rains. Tennison wins a set with probability ps when it's sunny, and with probability pr when it's raining. The chance that there will be sun for the first set is pi. Luckily for Tennison, whenever he wins a set, the probability that there will be sun increases by pu with probability pw. Unfortunately, when Tennison loses a set, the probability of sun decreases by pd with probability pl. What is the chance that Tennison will be successful in his match?

Rain and sun are the only weather conditions, so P(rain) = 1 - P(sun) at all times. Also, probabilities always stay in the range [0, 1]. If P(sun) would ever be less than 0, it is instead 0. If it would ever be greater than 1, it is instead 1.

Input

Input begins with an integer T, the number of tennis matches that Tennison plays. For each match, there is a line containing an integer K, followed by the probabilities ps, pr, pi, pu, pw, pd, pl in that order. All of these values are given with exactly three places after the decimal point.

Output

For each match, output "Case #i: " followed by the probability that Tennison wins the match, rounded to 6 decimal places (quotes for clarity only). It is guaranteed that the output is unaffected by deviations as large as 10-8.

Constraints

  • 1 ≤ T ≤ 100
  • 1 ≤ K ≤ 100
  • 0 ≤ ps, pr, pi, pu, pw, pd, pl ≤ 1
  • ps > pr
5
1 0.800 0.100 0.500 0.500 0.500 0.500 0.500
2 0.600 0.200 0.500 0.100 1.000 0.100 1.000
1 1.000 0.000 1.000 1.000 1.000 1.000 1.000
25 0.984 0.222 0.993 0.336 0.207 0.084 0.478
58 0.472 0.182 0.418 0.097 0.569 0.816 0.711
Case #1: 0.450000
Case #2: 0.352000
Case #3: 1.000000
Case #4: 0.999956
Case #5: 0.000000

Problem number 1 of the Facebook Hacker Cup 2014 Qualification Round
This work is licensed under a Creative Commons Attribution-NonCommercial 3.0 Unported License.
https://www.facebook.com/hackercup/problems.php?pid=373965339404375&round=598486203541358

#!/usr/bin/env python3
#-*- coding:utf-8 -*-
import pyximport; pyximport.install()
from fast_Tennison import play_a_set
from multiprocessing import Pool
import sys
T = int(sys.stdin.readline().strip())
TEST_CASES = []
for t in range(1, T + 1):
l = sys.stdin.readline().strip().split(' ')
K = int(l[0])
ps, pr, pi, pu, pw, pd, pl = (float(x) for x in l[1:])
won, lost = 0, 0
TEST_CASES.append((t, {}, K, won, lost, pi, ps, pr, pu, pw, pd, pl))
def do(x):
r = play_a_set(*x[1:])
sys.stderr.write('#{}: {:f}\n'.format(x[0], r))
return r
pool = Pool(processes=8)
RESULTS = pool.map(do, TEST_CASES, chunksize=1)
for t in range(1, T + 1):
print('Case #{}: {:f}'.format(t, RESULTS[t-1]))
20
99 0.753 0.662 0.810 0.984 0.645 0.511 0.015
37 0.916 0.809 0.178 0.801 0.235 0.996 0.077
65 0.964 0.395 0.549 0.741 0.686 0.702 0.686
58 0.472 0.182 0.418 0.097 0.569 0.816 0.711
25 0.984 0.222 0.993 0.336 0.207 0.084 0.478
1 0.800 0.100 0.500 0.500 0.500 0.500 0.500
45 0.889 0.664 0.232 0.454 0.785 0.637 0.611
42 0.219 0.065 0.968 0.173 0.045 0.878 0.889
55 0.419 0.097 0.088 0.922 0.455 0.094 0.638
35 0.721 0.098 0.455 0.201 0.752 0.090 0.297
3 0.532 0.063 0.517 0.565 0.208 0.142 0.525
20 0.284 0.273 0.854 0.914 0.086 0.198 0.653
87 0.447 0.384 0.187 0.898 0.240 0.964 0.301
1 1.000 0.000 1.000 1.000 1.000 1.000 1.000
71 0.649 0.181 0.358 0.197 0.773 0.810 0.348
2 0.600 0.200 0.500 0.100 1.000 0.100 1.000
11 0.698 0.348 0.651 0.528 0.828 0.526 0.129
28 0.918 0.381 0.851 0.346 0.278 0.369 0.757
41 0.411 0.033 0.972 0.669 0.828 0.748 0.402
17 0.706 0.216 0.713 0.435 0.885 0.951 0.396
Case #1: 1.000000
Case #2: 1.000000
Case #3: 0.999999
Case #4: 0.000000
Case #5: 0.999956
Case #6: 0.450000
Case #7: 1.000000
Case #8: 0.000000
Case #9: 0.001279
Case #10: 0.937467
Case #11: 0.186419
Case #12: 0.001556
Case #13: 0.009297
Case #14: 1.000000
Case #15: 0.005814
Case #16: 0.352000
Case #17: 0.910761
Case #18: 0.812133
Case #19: 0.000005
Case #20: 0.452012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment