SQL: Cryptocurrency Account Balance Analysis
A cryptocurrency exchange platform seeks to analyze transactional data across its users’ accounts for Bitcoin (BTC), Ethereum (ETH), and Litecoin (LTC). The goal is to calculate the total balance of each cryptocurrency for every account, taking into account all transactions that have taken place. This analysis should include both incoming (positive amounts) and outgoing (negative amounts) transactions, offering a detailed view of the current holdings of each cryptocurrency in each account.
The result should have the following columns:email | btc_balance | eth_balance | ltc_balance
email
- the email associated with the account.btc_balance
- the total balance of Bitcoin (BTC) for the account, rounded to five decimal places, including trailing zeros if necessary (e.g.,5.00000
).eth_balance
- the total balance of Ethereum (ETH) for the account, rounded to five decimal places, including trailing zeros if necessary (e.g.,5.00000
).ltc_balance
- the total balance of Litecoin (LTC) for the account, rounded to five decimal places, including trailing zeros if necessary (e.g.,5.00000
).
The result should be sorted in ascending order by email
.
Note:
- Transactions are recorded in a format that combines the amount and the type of cryptocurrency (e.g.,
"-1.23456 BTC"
), where positive values indicate receipts and negative values indicate expenditures.
Python: Suffix-stripping Stemmer
Stemming is the process of extracting the base word from a word. For instance, the base for "worked"
is "work"
.
Use the following algorithm to stem a word:
- If the word ends in
'ed'
,'ly'
, or'ing'
, remove the suffix. - If the resulting word is longer than
8
letters, keep the first8
letters.
Implement a function that takes a string of space-separated words and returns its stemmed counterpart.
Example
Input:text = "an extremely dangerous dog is barking"
Processing:
'an'
does not end in one of the suffixes and is less than8
letters.'extremely'
is'extreme'
after removing the suffix.'extreme'
is less than8
letters.'dangerous'
is9
letters long, so reduce it to8
letters:'dangerou'
.'dog'
and'is'
are unchanged.'barking'
is'bark'
after removing the suffix and is less than8
letters.
Output:"an extreme dangerou dog is bark"
Function Description
Complete the function stemmer
in the editor below.
我们长期稳定承接各大科技公司如TikTok、Google、Amazon等的OA笔试代写服务,确保满分通过。如有需求,请随时联系我们。
We consistently provide professional online assessment services for major tech companies like TikTok, Google, and Amazon, guaranteeing perfect scores. Feel free to contact us if you're interested.
