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 22:00Joad NacerJoad NacerScore: 7,907Success
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 22:007,812145,098,92185,929,62202,265,088
2Apr 18, 2024 22:007,814147,655,50485,957,97702,269,184
3Apr 18, 2024 22:007,820153,737,99086,017,22102,265,088
4Apr 18, 2024 22:007,895112,807,29884,847,0001,996,0002,289,664
5Apr 18, 2024 22:007,895112,865,03284,851,0001,996,0002,523,136
6Apr 18, 2024 22:007,899112,652,41784,897,0001,997,0002,289,664
7Apr 18, 2024 22:007,907109,992,83285,979,000999,0002,289,664
8Apr 18, 2024 22:007,908109,820,93284,984,0001,999,0002,273,280
9Apr 18, 2024 22:007,911110,451,29985,018,0002,000,0002,289,664
10Apr 18, 2024 22:007,913114,004,82586,045,0001,000,0002,289,664
11Apr 18, 2024 22:007,918109,106,11286,102,0001,001,0002,269,184
12Apr 18, 2024 22:007,926110,805,49885,180,0002,004,0002,277,376