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 9, 2021 18:46Sergey StreminSergey StreminScore: 9,508Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 9, 2021 18:449,446130,882,134100,908,0002,997,0002,363,392
2May 9, 2021 18:449,470124,884,25264,103,00040,064,0002,289,664
3May 9, 2021 18:469,470125,052,77166,107,00038,061,0002,367,488
4May 9, 2021 18:459,491130,399,52674,284,00030,115,0002,289,664
5May 9, 2021 18:469,497127,845,47967,304,00037,168,0002,281,472
6May 9, 2021 18:449,497130,917,14781,365,00023,103,0002,289,664
7May 9, 2021 18:449,497130,861,90279,352,00025,111,0002,367,488
8May 9, 2021 18:459,502126,326,41876,385,00028,142,0002,375,680
9May 9, 2021 18:459,504129,119,51180,421,00024,126,0002,289,664
10May 9, 2021 18:449,505130,791,09769,372,00035,188,0002,383,872
11May 9, 2021 18:449,505135,968,95377,413,00027,144,0002,375,680
12May 9, 2021 18:459,507128,203,37471,393,00033,182,0002,449,408
13May 9, 2021 18:469,508132,655,50973,415,00031,176,0002,383,872
14May 9, 2021 18:449,508136,482,68867,379,00037,209,0002,289,664
15May 9, 2021 18:459,512136,207,71170,428,00034,208,0002,281,472
16May 9, 2021 18:449,513136,663,60067,412,00037,227,0002,375,680
17May 9, 2021 18:469,515129,914,64477,493,00027,172,0002,289,664
18May 9, 2021 18:459,517131,815,59576,506,00028,186,0002,289,664
19May 9, 2021 18:459,517131,941,82875,495,00029,191,0002,289,664
20May 9, 2021 18:469,517135,077,36378,519,00026,173,0002,473,984
21May 9, 2021 18:469,519133,168,21181,769,00022,935,0002,289,664
22May 9, 2021 18:449,529131,381,89773,876,00030,948,0002,289,664
23May 9, 2021 18:469,530136,243,75375,880,00028,954,0002,371,584
24May 9, 2021 18:469,532132,655,32972,897,00031,955,0002,469,888
25May 9, 2021 18:459,540134,258,29065,963,00038,978,0002,289,664
26May 9, 2021 18:459,551129,155,19685,051,00020,012,0002,289,664
27May 9, 2021 18:469,585138,648,26674,307,00031,128,0002,375,680