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 18:26Yuriy LyfenkoYuriy LyfenkoScore: 4,354Success
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 18:234,30377,882,20846,325,0001,007,0002,527,232
2May 22, 2021 18:234,31266,778,29346,421,0001,009,0002,265,088
3May 22, 2021 18:504,31268,971,57146,421,0001,009,0002,527,232
4May 22, 2021 18:264,31475,937,72946,450,0001,009,0002,383,872
5May 22, 2021 18:264,32777,122,06246,588,0001,012,0002,260,992
6May 22, 2021 18:504,32873,950,15846,592,0001,012,0002,396,160
7May 22, 2021 18:504,32973,701,29346,608,0001,013,0002,527,232
8May 22, 2021 18:234,33276,557,88346,641,0001,013,0002,527,232
9May 22, 2021 18:234,33273,704,24847,648,00002,265,088
10May 22, 2021 18:234,346109,770,52747,810,40802,240,512
11May 22, 2021 18:504,346113,263,52747,808,42902,240,512
12May 22, 2021 18:264,34774,827,74747,820,00002,527,232
13May 22, 2021 18:264,34881,512,48847,833,00002,527,232
14May 22, 2021 18:234,34979,735,67546,843,000996,0002,269,184
15May 22, 2021 18:504,35076,993,11246,856,000996,0002,392,064
16May 22, 2021 18:504,35175,119,25545,862,0001,994,0002,265,088
17May 22, 2021 18:264,351120,475,81647,856,61202,236,416
18May 22, 2021 18:264,35274,521,80245,875,0001,994,0002,265,088
19May 22, 2021 18:234,35475,095,24146,901,000997,0002,265,088
20May 22, 2021 18:234,354108,975,40847,893,59302,236,416
21May 22, 2021 18:504,356111,657,04947,913,41902,236,416
22May 22, 2021 18:264,35673,335,08845,921,0001,996,0002,392,064
23May 22, 2021 18:504,35883,664,85646,938,000998,0002,265,088
24May 22, 2021 18:264,36173,667,21545,968,0001,998,0002,387,968
25May 22, 2021 18:504,36474,498,26146,008,0002,000,0002,265,088
26May 22, 2021 18:504,36474,204,04846,001,0002,000,0002,265,088
27May 22, 2021 18:234,368122,262,91448,045,70402,244,608
28May 22, 2021 18:264,370111,301,32448,069,57202,240,512
29May 22, 2021 18:504,37180,336,14546,076,0002,003,0002,523,136
30May 22, 2021 18:264,37379,034,37547,097,0001,002,0002,396,160
31May 22, 2021 18:234,37473,659,83447,111,0001,002,0002,392,064
32May 22, 2021 18:234,37674,127,45846,126,0002,005,0002,514,944
33May 22, 2021 18:504,383115,451,67748,218,10802,236,416
34May 22, 2021 18:234,38373,670,27646,200,0002,008,0002,383,872
35May 22, 2021 18:264,385111,005,87448,239,36202,232,320
36May 22, 2021 18:264,38771,370,16947,252,0001,005,0002,265,088