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 20, 2021 05:41Sergey StreminSergey StreminScore: 6,169Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 17, 2021 16:396,15095,045,00066,637,0001,009,0002,277,376
2May 17, 2021 16:396,15192,518,44067,660,00002,371,584
3May 17, 2021 16:396,15192,987,12766,649,0001,009,0002,277,376
4May 17, 2021 16:406,15294,866,87366,667,0001,010,0002,371,584
5May 20, 2021 05:416,15492,719,62565,678,0002,020,0002,375,680
6May 20, 2021 05:416,158123,362,76767,736,50402,207,744
7May 20, 2021 05:416,159131,378,27667,753,43302,199,552
8May 17, 2021 16:406,15992,160,11867,749,00002,375,680
9May 17, 2021 16:396,16695,542,28066,829,000997,0002,277,376
10May 17, 2021 16:386,16797,508,19565,838,0001,995,0002,367,488
11May 17, 2021 16:406,16796,504,46567,841,00002,277,376
12May 17, 2021 16:386,16894,245,10966,855,000997,0002,277,376
13May 17, 2021 16:386,16898,552,21966,850,000997,0002,277,376
14May 17, 2021 16:396,16891,690,47065,849,0001,995,0002,277,376
15May 17, 2021 16:406,16896,347,15866,846,000997,0002,277,376
16May 17, 2021 16:406,16895,790,30166,847,000997,0002,371,584
17May 17, 2021 16:386,16895,332,96666,854,000997,0002,379,776
18May 20, 2021 05:416,16893,372,16267,845,00002,371,584
19May 20, 2021 05:416,168100,353,87966,846,000997,0002,375,680
20May 17, 2021 16:406,169102,516,78164,861,0002,993,0002,277,376
21May 17, 2021 16:406,16992,087,86666,861,000997,0002,375,680
22May 17, 2021 16:386,16994,749,65065,864,0001,995,0002,371,584
23May 20, 2021 05:416,17095,312,78266,871,000998,0002,281,472
24May 20, 2021 05:416,17197,564,29265,888,0001,996,0002,277,376
25May 20, 2021 05:416,17297,379,07265,899,0001,996,0002,371,584
26May 17, 2021 16:396,17297,849,12665,893,0001,996,0002,371,584
27May 17, 2021 16:386,17496,998,44163,916,0003,994,0002,277,376
28May 17, 2021 16:386,17794,638,62165,954,0001,998,0002,367,488
29May 20, 2021 05:416,17789,682,59265,950,0001,998,0002,277,376
30May 17, 2021 16:386,17898,836,57165,961,0001,998,0002,379,776
31May 17, 2021 16:406,17893,936,09666,964,000999,0002,281,472
32May 17, 2021 16:396,18096,079,55865,979,0001,999,0002,277,376
33May 17, 2021 16:386,18194,857,45766,992,000999,0002,277,376
34May 20, 2021 05:416,185100,060,40866,032,0002,000,0002,277,376
35May 20, 2021 05:416,187128,841,64668,057,56202,207,744
36May 17, 2021 16:396,19194,050,82365,096,0003,004,0002,277,376
37May 17, 2021 16:396,19196,104,25067,096,0001,001,0002,371,584
38May 17, 2021 16:406,19194,183,49266,098,0002,002,0002,367,488
39May 20, 2021 05:416,20487,993,76266,234,0002,007,0002,277,376