Parse JSON Sergey Svistunov

Compute the total amount of non-canceled external USD transactions from a stream of JSON records as fast as possible.

Input: 1 000 000 JSON records on STDIN, one per line. Each record has the following structure:

{
    "user_id": 0,
    "currency": "USD",
    "transactions": [
        {
            "amount": 0,
            "to_user_id": 0,
            "canceled": false
        }
    ]
}
Field Constraints
user_id Integer, max 10 000
currency One of "GBP", "USD", "RUB", "JPY", "CHF"
transactions Array, max 10 elements
amount Integer, max 1000
canceled Boolean; may be omitted when false

Field order is not guaranteed within any object.

Output: The total amount of all transactions where:

  • record.currency == "USD"
  • transaction.to_user_id != record.user_id (external)
  • transaction.canceled is false or absent
Back to listApr 20, 2024 14:27Joad NacerJoad NacerScore: 7,582Success
Source Code

Source code access is restricted. Log in to request access.

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Apr 20, 2024 14:274,765109,096,91852,411,98902,277,376
2Apr 20, 2024 14:274,765123,891,96152,414,65002,269,184
3Apr 20, 2024 14:274,766118,496,78152,429,48002,260,992
4Apr 20, 2024 14:277,559108,497,75681,148,0002,003,0002,273,280
5Apr 20, 2024 14:277,577111,975,47283,352,00002,273,280
6Apr 20, 2024 14:277,579111,820,56383,366,00002,289,664
7Apr 20, 2024 14:277,582105,966,73382,401,0001,004,0002,273,280
8Apr 20, 2024 14:277,585105,745,67381,420,0002,010,0002,289,664
9Apr 20, 2024 14:277,590111,353,57783,487,00002,289,664
10Apr 20, 2024 14:277,591111,590,22882,491,0001,005,0002,531,328
11Apr 20, 2024 14:277,595108,530,77981,551,0001,989,0002,289,664
12Apr 20, 2024 14:277,601114,039,25682,608,0001,007,0002,289,664