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:02Yurkov 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 2, 2021 14:5510,712142,962,781115,840,0001,997,0002,277,376
2May 1, 2021 14:0210,712148,779,752116,838,000998,0002,265,088
3May 1, 2021 14:0210,717141,913,840114,895,0002,997,0002,281,472
4May 2, 2021 14:5510,718145,644,062114,900,0002,997,0002,269,184
5May 1, 2021 14:0210,724140,511,161115,965,0001,999,0002,277,376
6May 2, 2021 14:5510,725144,042,087116,971,000999,0002,277,376
7May 2, 2021 14:5510,726141,074,657115,985,0001,999,0002,387,968
8May 2, 2021 14:5510,729141,653,422115,014,0003,000,0002,387,968
9May 1, 2021 14:0210,733139,345,746116,063,0002,001,0002,277,376
10May 1, 2021 14:0210,734147,933,588116,069,0002,001,0002,355,200
11May 2, 2021 14:5510,737140,991,449117,110,0001,000,0002,367,488
12May 1, 2021 14:0210,737141,544,998114,101,0004,003,0002,277,376
13May 2, 2021 14:5510,738148,088,210117,114,0001,000,0002,277,376
14May 1, 2021 14:0210,740140,342,307115,136,0003,003,0002,277,376
15May 1, 2021 14:0210,743142,266,156116,173,0002,002,0002,277,376
16May 1, 2021 14:0210,745148,473,223116,191,0002,003,0002,273,280
17May 2, 2021 14:5510,755142,750,694116,296,0002,005,0002,277,376
18May 2, 2021 14:5510,768139,584,670117,444,0001,003,0002,367,488