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 18, 2024 23:20Joad NacerJoad NacerScore: 7,768Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Apr 18, 2024 23:205,286121,861,02958,142,68502,256,896
2Apr 18, 2024 23:205,289126,427,21458,175,86002,252,800
3Apr 18, 2024 23:205,296126,677,82058,259,21202,269,184
4Apr 18, 2024 23:207,749109,215,93883,230,0002,005,0002,265,088
5Apr 18, 2024 23:207,758109,699,59184,330,0001,003,0002,269,184
6Apr 18, 2024 23:207,765109,507,73684,408,0001,004,0002,527,232
7Apr 18, 2024 23:207,768113,116,66584,448,0001,005,0002,289,664
8Apr 18, 2024 23:207,769113,106,95384,455,0001,005,0002,289,664
9Apr 18, 2024 23:207,771107,008,31584,473,0001,005,0002,289,664
10Apr 18, 2024 23:207,772111,253,25184,489,0001,005,0002,289,664
11Apr 18, 2024 23:207,773107,865,05984,494,0001,005,0002,392,064
12Apr 18, 2024 23:207,777111,156,67984,546,0001,006,0002,527,232