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 1, 2021 14:45Yurkov AlekseyYurkov AlekseyScore: 10,734Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 1, 2021 14:4410,714148,622,488115,862,0001,997,0002,277,376
2May 1, 2021 14:4410,714143,129,550117,857,00002,281,472
3May 1, 2021 14:4410,714150,196,278115,857,0001,997,0002,269,184
4May 1, 2021 14:4410,717150,896,603116,893,000999,0002,265,088
5May 1, 2021 14:4510,718141,514,526115,897,0001,998,0002,277,376
6May 1, 2021 14:4510,720139,293,159116,920,000999,0002,383,872
7May 1, 2021 14:4510,727140,433,107116,002,0002,000,0002,531,328
8May 1, 2021 14:4410,728144,940,259117,011,0001,000,0002,531,328
9May 1, 2021 14:4410,731143,022,803115,038,0003,001,0002,277,376
10May 1, 2021 14:4510,734143,302,181115,075,0003,001,0002,277,376
11May 1, 2021 14:4510,736139,659,801117,099,0001,000,0002,269,184
12May 1, 2021 14:4510,736141,153,513116,094,0002,001,0002,277,376
13May 1, 2021 14:4410,736142,734,404116,099,0002,001,0002,273,280
14May 1, 2021 14:4410,740143,352,455116,139,0002,002,0002,277,376
15May 1, 2021 14:4510,753142,923,791116,283,0002,004,0002,265,088
16May 1, 2021 14:4510,754145,026,583116,286,0002,004,0002,531,328
17May 1, 2021 14:4510,768143,383,216118,449,00002,277,376
18May 1, 2021 14:4410,803144,218,780117,833,000998,0002,367,488