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 22, 2021 19:06Yuriy LyfenkoYuriy LyfenkoScore: 3,995Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 22, 2021 19:103,98371,000,23442,813,000995,0002,265,088
2May 22, 2021 19:063,98569,771,53842,838,000996,0002,383,872
3May 22, 2021 19:063,98676,161,73541,852,0001,992,0002,387,968
4May 22, 2021 19:103,98668,760,14943,851,00002,387,968
5May 22, 2021 19:063,98668,719,92542,848,000996,0002,383,872
6May 22, 2021 19:063,98774,198,31242,865,000996,0002,392,064
7May 22, 2021 19:103,98773,391,19841,865,0001,993,0002,396,160
8May 22, 2021 19:103,98769,790,92842,866,000996,0002,396,160
9May 22, 2021 19:103,98876,266,22042,867,000996,0002,396,160
10May 22, 2021 19:063,98968,680,89442,884,000997,0002,473,984
11May 22, 2021 19:103,98967,151,51141,880,0001,994,0002,527,232
12May 22, 2021 19:063,99383,379,30341,923,0001,996,0002,392,064
13May 22, 2021 19:063,99575,000,52741,945,0001,997,0002,265,088
14May 22, 2021 19:103,99776,108,09941,973,0001,998,0002,265,088
15May 22, 2021 19:103,99977,155,56541,985,0001,999,0002,392,064
16May 22, 2021 19:064,001102,053,03544,013,54002,232,320
17May 22, 2021 19:104,00172,268,32242,016,0002,000,0002,265,088
18May 22, 2021 19:064,00966,796,21942,091,0002,004,0002,265,088
19May 22, 2021 19:064,00971,731,14343,097,0001,002,0002,265,088
20May 22, 2021 19:064,010109,963,05244,114,74402,224,128
21May 22, 2021 19:064,011106,157,57144,115,51602,228,224
22May 22, 2021 19:104,015110,706,08344,161,73002,228,224
23May 22, 2021 19:104,032108,906,99744,356,66402,232,320
24May 22, 2021 19:104,039114,358,24644,425,32902,236,416