BlackRock OA

T1

T2

Programming challenge description:
The goal of this question is to design a cash register program. Your register currently has the following notes/coins within it:

One Pence: .01
Two Pence: .02
Five Pence: .05
Ten Pence: .10
Twenty Pence: .20
Fifty Pence: .50
One Pound: 1
Two Pounds: 2
Five Pounds: 5
Ten Pounds: 10
Twenty Pounds: 20
Fifty Pounds: 50
The aim of the program is to calculate the change that has to be returned to the customer with the least number of coins/notes. Note that the expectation is to have an object-oriented solution - think about creating classes for better reusability.

Input:
Your program should read lines of text from standard input (this is already part of the initial template). Each line contains two numbers which are separated by a semicolon. The first is the Purchase price (PP) and the second is the cash(CH) given by the customer.

Output:
For each line of input print a single line to standard output which is the change to be returned to the customer. If CH == PP, print out Zero. If CH > PP, print the amount that needs to be returned (in terms of the currency values). Any other case where the result is an error, the output should be ERROR.

The output should the change from highest to lowest denomination.

Test 1
Test Input
Download Test 1 Input
11.25
20
Expected Output
Download Test 1 Input
Five Pounds, Two Pounds, One Pound, Fifty Pence, Twenty Pence, Five Pence
Test 2
Test Input
Download Test 2 Input
8.75
50
Expected Output
Download Test 2 Input
Twenty Pounds, Twenty Pounds, One Pound, Twenty Pence, Five Pence
Test 3
Test Input
Download Test 3 Input
20
10
Expected Output
Download Test 3 Input
ERROR

T3

Programming challenge description:
Given a pattern as the first argument and a string of blobs split by | show the number of times the pattern is present in each blob and the total number of matches.

Input:
The input consists of the pattern (“bc” in the example) which is separated by a semicolon followed by a list of blobs (“bcdefbcbebc|abcdebcfgsdf|cbdbesfbcy|1bcdef23423bc32” in the example). Example input: bc;bcdefbcbebc|abcdebcfgsdf|cbdbesfbcy|1bcdef23423bc32

Output:
The output should consist of the number of occurrences of the pattern per blob (separated by |). Additionally, the final entry should be the summation of all the occurrences (also separated by |).

Example output: 3|2|1|2|8 where ‘bc’ was repeated 3 times, 2 times, 1 time, 2 times in the 4 blobs passed in. And 8 is the summation of all the occurrences (3+2+1+2 = 8)

Test 1
Test Input
Download Test 1 Input
bc;bcdefbcbebc|abcdebcfgsdf|cbdbesfbcy|1bcdef23423bc32
Expected Output
Download Test 1 Input
3|2|1|2|8
Test 2
Test Input
Download Test 2 Input
aa;aaaakjlhaa|aaadsaaa|easaaad|sa
Expected Output
Download Test 2 Input
4|4|2|0|10
Test 3
Test Input
Download Test 3 Input
b;bcdefbcbebc|abcdebcfgsdf|cbdbesfbcy|1bcdef23423bc32
Expected Output
Download Test 3 Input
4|2|3|2|11
Test 4
Test Input
Download Test 4 Input
;bcdefbcbebc|abcdebcfgsdf|cbdbesfbcy|1bcdef23423bc32
Expected Output
Download Test 4 Input
0|0|0|0|0

T4

Programming challenge description:
We say a portfolio matches the benchmark when the number of shares of each asset in the portfolio matches the number of shares of each asset in the benchmark. Your question is to write a program that determines the transactions necessary to make a portfolio match a benchmark.

A portfolio is a collection of assets such as stocks and bonds. A portfolio could have 10 shares of Vodafone stock, 15 shares of Google stock and 15 shares of Microsoft bonds. A benchmark is also just a collection of assets. A benchmark could have 15 shares of Vodafone stock, 10 shares of Google stock and 15 shares of Microsoft bonds.

A transaction is when you “buy” or “sell” a particular asset of certain asset type (“stock” or “bond”). For instance, you can decide to buy 5 shares of Vodafone stock which, given the portfolio described above, would result in you having 15 shares of Vodafone stock. Correspondingly, you decide to sell 5 shares of Microsoft bonds, which would result in 10 shares of Microsoft bonds in the above portfolio.

Assumptions:

Shares are positive decimals
There will always be at least 1 asset present in the Portfolio and Benchmark
A particular asset can be bond, stock, or both. For example, 5 shares of Microsoft bonds and 10 shares of Microsoft stock can both be present in the portfolio/benchmark
The trades should be sorted in alphabetical order based on the names of the assets; if both bonds and stock are present for an asset, list bonds first
Input:
The first part of the input is the Portfolio holdings (in the format Name,AssetType,Shares where each asset is separated by ‘|’ symbol)
The second part of the input is the Benchmark holdings (in the format Name,AssetType,Shares where each asset is separated by ‘|’ symbol)
Example input: Vodafone,STOCK,10|Google,STOCK,15|Microsoft,BOND,15:Vodafone,STOCK,15|Google,STOCK,10|Microsoft,BOND,15

Note that the two parts are separated by the ‘:’ symbol.

Output:
The output is a list of transactions (separated by new line) in the format TransactionType,Name,AssetType,Shares. Note that the TransactionType should only be BUY or SELL.

Example output: SELL,Google,STOCK,5 BUY,Vodafone,STOCK,5

Test 1
Test Input
Download Test 1 Input
Vodafone,STOCK,10|Google,STOCK,15|Microsoft,BOND,15:Vodafone,STOCK,15|Google,STOCK,10|Microsoft,BOND,15
Expected Output
Download Test 1 Input
SELL,Google,STOCK,5
BUY,Vodafone,STOCK,5
Test 2
Test Input
Download Test 2 Input
Vodafone,STOCK,10|Google,STOCK,15:Vodafone,STOCK,15|Vodafone,BOND,10|Google,STOCK,10
Expected Output
Download Test 2 Input
SELL,Google,STOCK,5
BUY,Vodafone,BOND,10
BUY,Vodafone,STOCK,5

2021 Summer Analyst，方向是 Software，和楼主刷到同一套题