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 listJun 4, 2021 11:49Yurkov AlekseyYurkov AlekseyScore: 6,903Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jun 4, 2021 11:516,872102,600,01874,590,0001,007,0002,523,136
2Jun 4, 2021 11:516,878101,263,75774,654,0001,008,0002,277,376
3Jun 4, 2021 11:496,880102,149,75574,676,0001,009,0002,277,376
4Jun 4, 2021 11:496,882102,029,95872,670,0003,027,0002,277,376
5Jun 4, 2021 11:496,886102,757,36174,747,000996,0002,523,136
6Jun 4, 2021 11:496,894100,479,08673,844,0001,995,0002,277,376
7Jun 4, 2021 11:516,89599,895,87174,849,000997,0002,269,184
8Jun 4, 2021 11:516,896105,192,31674,862,000998,0002,281,472
9Jun 4, 2021 11:516,897108,080,58275,872,00002,277,376
10Jun 4, 2021 11:496,89898,016,19074,868,0001,011,0002,277,376
11Jun 4, 2021 11:516,898105,997,42273,885,0001,996,0002,269,184
12Jun 4, 2021 11:516,900101,909,92773,900,0001,997,0002,277,376
13Jun 4, 2021 11:516,90398,756,65972,937,0002,997,0002,277,376
14Jun 4, 2021 11:496,90598,282,20373,962,0001,998,0002,277,376
15Jun 4, 2021 11:496,90798,489,09673,980,0001,999,0002,273,280
16Jun 4, 2021 11:496,910100,196,06674,008,0002,000,0002,277,376
17Jun 4, 2021 11:496,918105,743,93174,094,0002,002,0002,531,328
18Jun 4, 2021 11:516,92198,253,06773,131,0003,005,0002,265,088
19Jun 4, 2021 11:517,612153,355,95583,733,15702,269,184
20Jun 4, 2021 11:517,626147,288,09183,890,75202,256,896
21Jun 4, 2021 11:517,627134,862,59883,898,83902,256,896
22Jun 4, 2021 11:497,628164,717,50383,907,23002,256,896
23Jun 4, 2021 11:497,635143,996,70383,981,89302,269,184
24Jun 4, 2021 11:497,657142,873,38884,232,45802,260,992