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:22Yuriy LyfenkoYuriy LyfenkoScore: 4,020Success
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 21:503,92769,633,67542,197,0001,004,0002,392,064
2May 22, 2021 19:223,93871,373,39942,315,0001,007,0002,265,088
3May 22, 2021 21:503,94062,292,94843,337,00002,527,232
4May 22, 2021 19:223,96065,376,71243,559,00002,392,064
5May 22, 2021 21:503,96165,027,32642,558,0001,013,0002,265,088
6May 22, 2021 21:503,98571,869,99442,837,000996,0002,506,752
7May 22, 2021 21:503,99069,616,26142,891,000997,0002,387,968
8May 22, 2021 21:503,998103,355,56143,977,05302,236,416
9May 22, 2021 21:504,00672,392,77342,067,0002,003,0002,400,256
10May 22, 2021 19:224,008100,565,99844,086,59302,236,416
11May 22, 2021 19:224,00868,688,22042,081,0002,003,0002,527,232
12May 22, 2021 19:224,01366,072,65542,139,0002,006,0002,265,088
13May 22, 2021 21:504,020103,583,61744,218,47102,240,512
14May 22, 2021 19:224,02269,029,97741,223,0003,016,0002,269,184
15May 22, 2021 21:504,02767,643,87943,289,0001,006,0002,392,064
16May 22, 2021 19:224,03166,752,02044,339,00002,265,088
17May 22, 2021 19:224,03377,229,80243,355,0001,008,0002,396,160
18May 22, 2021 19:224,03570,786,70843,373,0001,008,0002,265,088
19May 22, 2021 21:504,03767,083,43343,401,0001,009,0002,527,232
20May 22, 2021 21:504,03967,451,76743,416,0001,009,0002,387,968
21May 22, 2021 21:504,042112,318,18344,462,44302,240,512
22May 22, 2021 19:224,04367,003,43744,470,00002,396,160
23May 22, 2021 19:224,060107,855,39844,658,05602,232,320
24May 22, 2021 19:224,10399,759,00345,138,28502,232,320