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 2, 2021 16:32Yurkov AlekseyYurkov AlekseyScore: 8,961Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 2, 2021 16:328,935119,810,61295,276,0003,008,0002,273,280
2May 2, 2021 16:328,936124,384,73396,294,0002,006,0002,277,376
3May 2, 2021 16:328,941124,985,57297,352,0001,003,0002,277,376
4May 2, 2021 16:328,944121,898,63596,376,0002,007,0002,277,376
5May 2, 2021 16:328,945119,607,02797,387,0001,003,0002,269,184
6May 2, 2021 16:328,946125,188,26296,395,0002,008,0002,277,376
7May 2, 2021 16:328,948121,058,56396,422,0002,008,0002,277,376
8May 2, 2021 16:328,954127,530,15598,497,00002,277,376
9May 2, 2021 16:328,955129,832,39097,502,0001,005,0002,277,376
10May 2, 2021 16:328,961126,692,84097,562,0001,005,0002,269,184
11May 2, 2021 16:328,963131,314,06697,584,0001,006,0002,273,280
12May 2, 2021 16:328,964129,329,71398,606,00002,273,280
13May 2, 2021 16:328,964123,188,91997,593,0001,006,0002,277,376
14May 2, 2021 16:328,964122,311,10897,597,0001,006,0002,269,184
15May 2, 2021 16:328,969125,633,53097,658,0001,006,0002,277,376
16May 2, 2021 16:328,971126,676,03798,684,00002,277,376
17May 2, 2021 16:328,972123,830,35997,684,0001,007,0002,277,376
18May 2, 2021 16:328,986128,226,65196,845,0001,996,0002,527,232