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 27, 2021 13:12Yurkov AlekseyYurkov AlekseyScore: 11,279Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 27, 2021 13:1211,263148,081,805121,895,0001,998,0002,277,376
2May 27, 2021 13:1211,269151,038,045122,963,000999,0002,265,088
3May 27, 2021 13:1211,270150,391,235122,970,000999,0002,277,376
4May 27, 2021 13:1211,273146,986,039121,004,0003,000,0002,523,136
5May 27, 2021 13:1211,275152,702,390122,029,0002,000,0002,531,328
6May 27, 2021 13:1211,276148,611,931122,033,0002,000,0002,269,184
7May 27, 2021 13:1211,279150,301,105121,068,0003,001,0002,269,184
8May 27, 2021 13:1211,280145,682,154123,076,0001,000,0002,277,376
9May 27, 2021 13:1211,291147,190,942123,197,0001,001,0002,277,376
10May 27, 2021 13:1211,584167,866,548127,422,48902,392,064
11May 27, 2021 13:1211,588201,785,726127,472,39502,252,800
12May 27, 2021 13:1211,596163,809,018127,558,60802,269,184