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 3, 2021 01:02Yuriy LyfenkoYuriy LyfenkoScore: 5,955Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 3, 2021 01:005,70989,252,23060,804,0001,993,0002,281,472
2May 3, 2021 01:005,71593,514,19760,868,0001,995,0002,281,472
3May 3, 2021 00:595,71986,876,18860,917,0001,997,0002,265,088
4May 3, 2021 01:005,72091,060,90160,921,0001,997,0002,277,376
5May 3, 2021 01:005,72088,509,10060,925,0001,997,0002,523,136
6May 3, 2021 00:595,72185,506,13860,929,0001,997,0002,277,376
7May 3, 2021 01:005,72683,609,50160,986,0001,999,0002,371,584
8May 3, 2021 00:595,72789,291,52960,994,0001,999,0002,281,472
9May 3, 2021 01:005,72984,736,09162,015,0001,000,0002,281,472
10May 3, 2021 01:005,72986,316,93160,019,0003,000,0002,269,184
11May 3, 2021 00:595,73189,701,55661,035,0002,001,0002,273,280
12May 3, 2021 01:005,73184,859,76861,045,0002,001,0002,371,584
13May 3, 2021 00:595,73286,960,31561,053,0002,001,0002,281,472
14May 3, 2021 01:005,73488,840,33362,071,0001,001,0002,367,488
15May 3, 2021 00:595,73686,588,97261,089,0002,002,0002,273,280
16May 3, 2021 00:595,73788,570,24161,103,0002,003,0002,281,472
17May 3, 2021 00:595,73888,543,05361,115,0002,003,0002,281,472
18May 3, 2021 00:595,73984,414,85961,123,0002,004,0002,281,472
19May 3, 2021 01:015,94589,627,39863,388,0002,012,0002,281,472
20May 3, 2021 01:015,94789,490,46765,414,00002,277,376
21May 3, 2021 01:025,95086,667,56565,454,00002,281,472
22May 3, 2021 01:025,95591,279,99864,495,0001,007,0002,277,376
23May 3, 2021 01:025,95586,048,24264,501,0001,007,0002,269,184
24May 3, 2021 01:015,95789,071,53464,520,0001,008,0002,265,088
25May 3, 2021 01:025,95888,869,81364,535,0001,008,0002,269,184
26May 3, 2021 01:025,96389,949,45664,586,0001,009,0002,281,472
27May 3, 2021 01:025,96690,982,61564,615,0001,009,0002,527,232
28May 3, 2021 01:025,96691,435,27464,613,0001,009,0002,269,184
29May 3, 2021 01:025,96693,688,30564,619,0001,009,0002,269,184
30May 3, 2021 01:015,96996,152,91464,652,0001,010,0002,281,472
31May 3, 2021 01:025,97092,380,87364,661,0001,010,0002,277,376
32May 3, 2021 01:015,98492,423,11165,819,00002,269,184
33May 3, 2021 01:025,98490,977,82663,828,0001,994,0002,404,352
34May 3, 2021 01:025,98595,663,43663,840,0001,995,0002,273,280
35May 3, 2021 01:025,98595,419,77863,840,0001,995,0002,281,472
36May 3, 2021 01:025,98693,024,21863,854,0001,995,0002,269,184
37May 3, 2021 01:015,98697,479,12763,856,0001,995,0002,269,184
38May 3, 2021 01:015,98791,838,02763,858,0001,995,0002,273,280
39May 3, 2021 01:025,98894,319,55165,868,00002,273,280
40May 3, 2021 01:025,98895,463,36164,866,000997,0002,277,376
41May 3, 2021 01:015,99090,011,23963,898,0001,996,0002,281,472
42May 3, 2021 01:025,99387,478,89364,923,000998,0002,265,088
43May 3, 2021 01:016,00189,064,05864,013,0002,000,0002,273,280
44May 3, 2021 01:026,00292,269,87661,020,0005,001,0002,281,472
45May 3, 2021 01:026,01389,019,56465,138,0001,002,0002,265,088