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 4, 2021 13:06Yuriy LyfenkoYuriy LyfenkoScore: 5,666Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 4, 2021 13:065,64584,685,07960,093,0002,003,0002,269,184
2May 4, 2021 13:065,64683,809,53260,100,0002,003,0002,281,472
3May 4, 2021 13:055,64684,851,90960,100,0002,003,0002,269,184
4May 4, 2021 13:065,64989,142,03660,134,0002,004,0002,277,376
5May 4, 2021 13:065,65182,836,11861,164,0001,002,0002,383,872
6May 4, 2021 13:065,65294,837,24360,166,0002,005,0002,281,472
7May 4, 2021 13:065,65283,100,86961,166,0001,002,0002,273,280
8May 4, 2021 13:065,65287,269,14560,172,0002,005,0002,281,472
9May 4, 2021 13:065,65384,817,30861,180,0001,002,0002,269,184
10May 4, 2021 13:065,65487,501,82759,187,0003,009,0002,269,184
11May 4, 2021 13:065,65589,256,20759,197,0003,010,0002,269,184
12May 4, 2021 13:065,65584,780,48861,204,0001,003,0002,281,472
13May 4, 2021 13:065,65588,711,64160,204,0002,006,0002,281,472
14May 4, 2021 13:065,65586,475,26061,198,0001,003,0002,269,184
15May 4, 2021 13:055,65688,991,93960,210,0002,007,0002,273,280
16May 4, 2021 13:065,65688,877,33460,213,0002,007,0002,277,376
17May 4, 2021 13:065,65687,555,06660,213,0002,007,0002,273,280
18May 4, 2021 13:065,65684,736,23160,207,0002,006,0002,269,184
19May 4, 2021 13:065,66283,243,70060,272,0002,009,0002,371,584
20May 4, 2021 13:065,66485,691,21460,294,0002,009,0002,273,280
21May 4, 2021 13:065,66587,373,65960,301,0002,010,0002,527,232
22May 4, 2021 13:055,66588,399,27360,302,0002,010,0002,281,472
23May 4, 2021 13:065,66684,037,65461,326,0001,005,0002,277,376
24May 4, 2021 13:065,66688,903,74662,326,00002,281,472
25May 4, 2021 13:055,66787,727,47662,338,00002,281,472
26May 4, 2021 13:055,66983,824,02861,357,0001,005,0002,269,184
27May 4, 2021 13:065,66990,946,48961,349,0001,005,0002,281,472
28May 4, 2021 13:055,67187,421,03961,372,0001,006,0002,523,136
29May 4, 2021 13:065,67289,641,87362,392,00002,277,376
30May 4, 2021 13:065,67291,410,58661,387,0001,006,0002,273,280
31May 4, 2021 13:065,67390,240,76960,391,0002,013,0002,281,472
32May 4, 2021 13:065,67389,018,34662,398,00002,273,280
33May 4, 2021 13:065,67492,657,19659,397,0003,020,0002,281,472
34May 4, 2021 13:065,67490,967,68060,398,0002,013,0002,277,376
35May 4, 2021 13:065,67584,635,05161,423,0001,006,0002,281,472
36May 4, 2021 13:065,67984,154,53862,464,00002,269,184
37May 4, 2021 13:065,68183,875,20959,469,0003,023,0002,281,472
38May 4, 2021 13:055,68182,265,51061,488,0001,008,0002,277,376
39May 4, 2021 13:055,68287,743,27562,504,00002,269,184
40May 4, 2021 13:065,68385,177,95961,505,0001,008,0002,269,184
41May 4, 2021 13:065,68489,198,67860,505,0002,016,0002,281,472
42May 4, 2021 13:065,68487,250,40962,523,00002,527,232
43May 4, 2021 13:065,68992,536,90161,570,0001,009,0002,289,664
44May 4, 2021 13:055,69088,287,36262,593,00002,523,136
45May 4, 2021 13:065,69687,629,39161,644,0001,010,0002,273,280