SI 100B Programming Assignment 2
SI 100B TA Team
October 23, 2024
1Notice
- This homework is due 10:00 AM October 30, Wednesday, please start early.
- The problems should be solved individually. You should submit solutions for all problems to the onlinejudge (OJ) system, which will give a score for each submission automatically.
- You may discuss course material, programming languages, general techniques, and share test cases withothers.
- You’re encouraged to ask any question about problem description, environment setup, error information, grammar, functions, methods etc., or post general ideas at Piazza. It can help others too!
- However, you may NOT read, possess, copy, or submit any part of other’s solution. You may not askothers to directly debug your program or provide specific lines of solution. You should not access another person’s account. Also, do not offer such help, and protect your account and code. Giving orreceiving inappropriate help is plagiarism, an infringement of academic integrity.
- You are not allowed to write your solution directly by or based on code generated by AI tools.
- Good luck and have fun!21 UNFORTUNATE STOCKHOLDER
1 Unfortunate Stockholder
“I really hate green,” the poor man sighed, looking down, and found his beloved Alexandra NikolaevnaPetrovskaya lying on the floor, stiff and cold. With her gone, his nearly hairless head now has one less hair.A month ago, he was still a rich man, with positive daily profit from his investments. However, withouthim noticing, some ofhis stocks had been falling for several days, and then suddenly hit the lower limit.Quicker than he could take any actions, his other stocks also began falling.Because he had so many stocks, he only checked the total profit every day.“Oh God! How I wish I had a
tool that can tell me the details of my stocks!”
1.1 Task
As it happens, you know how to use python, and you will kindly fulfill his wish by writing a pythonprogram to give the details of his stocks. You will be given a list of numbers, representing the profit of hisstocks, and a series of queries. For each query, you should perform the corresponding operation and print the
esult.1.2 Input/Output Specification
1.2.1 Input
The first line contains a string of float numbers, representing the profit of the stocks.The second line contains a single positive integer n, indicating the number of queries.Each of the following n lines contains a query, with details shown in the Table below. All queries will begiven in one of the formats
- query, operation
- query, operation, start_index, end_index, stepquery, operation, start_index, end_index, step means querying on the profit of a subset of the stocks obained by performing slicing operation. It is guaranteed that start_i代写 SI 100B Programming Assignment 2 ndex, end_index and step are all integers.If the subset of the stocks to be queried is empty, print Querying on empty list! (with a single spaceat the end of the output) and do nothing else.
1.2.2 Output
n lines, each line the result of the query.31.2 Input/Output Specification the list of profits of the sliced subset of stockscomputeavcompute, avgthe average profit of all stockscompute, avg, 5, 12, 3the average profit of the sliced subset of stocks
allompute, allthe total profit of all stockscompute, all, 6, 3, 2the total profit of the sliced subset of stocksreorderascreorder, ascthe reordered list of profitsof all stocks inascending orderreorder, asc, 7, 30, 1the list of profits with the profits of thesliced stocks reordered in ascending orderdescreorder, descthe reordered list of profitsof all stocks in descending orderreorder,desc, 3, 4, 2he list of profits with the profits of thesliced stocks reordered in descending orderrevreorder, revthe reordered list of profitsf all stocks in reverse orderrorder, rev, 9, 3, 3the list of profits with the profits of thesliced stocks reordered in reverse order1.2.3 Example
1.3 Hint
After each reorder query, the list is reordered (i.e., it is mutated), as shown in the examples.
2 Average Running Speed
As part of promoting a healthy lifestyle, the university has introduced a running App. The App generatesdata points consecutively containing the student’s positionsand timestamps during their running sessions.The App helps generate useful statistics, such as distance covered and average speed. And students can freely
select specific data points for customized analysis.
2.1 Task
You are tasked with writing a program to process data points of a running session and then evaluatea runner’s performance. Your program receives n data points at the beginning. The i-th data point Pi =(xi , yi , ti), where xi and yi are the runner’s 2D coordinates, ti is the timestamp measured in seconds. Forsimplicity, we assume that runners travels along a straightpath between two adjacent points, so the distancebetween two adjacent data points is estimated using the Euclidean distance formula:D(Pk, Pk−1) = √ (xk−xk−1) 2 + (yk−yk−1) 2
52.2 Input/Output Specification
2 AVERAGE RUNNING SPEED irstly, you need to estimate the average speed V of the entire session, note that the session starts at P0 and ends at Pn−1:
Myers–Briggs Type Indicator (MBTI) is a assessment particularly popular in social occasions. There isone dimension: energy orientation, which is divided into introversion and extraversion—— extraverted personobtains energy from social interactions, while introverted person obtains energy from self-reflection.However, a person’s energy orientation is not fixed. For example, a person who is initially classified asintroverted may turn out to be extraverted under some circumstances.
3.1 Task
In this scenario, a meeting consists of participants of three initial orientations: “E”, “I”, and “i”. You are
given a seating arrangement represented as an n × m matrix
标签:reordered,profit,Programming,list,100B,SI,points,stocks,profits From: https://www.cnblogs.com/CSSE2310/p/18517784