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 listMay 7, 2024 23:47Joad NacerJoad NacerScore: 7,491Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 7, 2024 23:475,073117,814,61155,804,51202,265,088
2May 7, 2024 23:475,111136,005,62656,226,45502,269,184
3May 7, 2024 23:475,123114,648,20156,353,96502,265,088
4May 7, 2024 23:477,478106,097,80780,256,0002,006,0002,289,664
5May 7, 2024 23:477,489103,333,98681,380,0001,004,0002,379,776
6May 7, 2024 23:477,490111,691,84182,385,00002,289,664
7May 7, 2024 23:477,491106,683,76381,402,0001,004,0002,273,280
8May 7, 2024 23:477,539108,697,35380,935,0001,998,0002,289,664
9May 7, 2024 23:477,548111,477,51781,033,0002,000,0002,531,328
10May 7, 2024 23:477,588110,178,65682,465,0001,005,0002,527,232
11May 7, 2024 23:477,598111,483,83482,574,0001,007,0002,269,184
12May 7, 2024 23:477,637106,033,98383,003,0001,000,0002,367,488