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 2, 2021 06:51Yuriy LyfenkoYuriy LyfenkoScore: 12,023Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 2, 2021 06:2811,938152,678,186131,313,00002,265,088
2May 2, 2021 06:2811,984155,179,599129,827,0001,997,0002,367,488
3May 2, 2021 06:5111,989161,568,398129,883,0001,998,0002,273,280
4May 2, 2021 06:5112,002155,169,800129,021,0003,000,0002,281,472
5May 2, 2021 06:2812,003154,671,578132,032,00002,281,472
6May 2, 2021 06:2812,006161,215,913130,067,0002,001,0002,281,472
7May 2, 2021 06:5112,009155,098,784130,095,0002,001,0002,277,376
8May 2, 2021 06:5112,010155,228,709130,106,0002,001,0002,281,472
9May 2, 2021 06:5112,023156,046,704131,253,0001,001,0002,273,280
10May 2, 2021 06:2812,023152,727,838129,245,0003,005,0002,396,160
11May 2, 2021 06:2812,034159,042,639131,367,0001,002,0002,277,376
12May 2, 2021 06:2812,035160,266,060130,376,0002,005,0002,281,472
13May 2, 2021 06:5112,036159,468,299131,395,0001,003,0002,281,472
14May 2, 2021 06:5112,045154,762,689130,483,0002,007,0002,277,376
15May 2, 2021 06:2812,053158,769,572131,576,0001,004,0002,277,376
16May 2, 2021 06:5112,074160,766,447129,824,0002,995,0002,269,184
17May 2, 2021 06:5112,100155,511,060131,097,0002,001,0002,281,472
18May 2, 2021 06:2812,173164,713,879131,910,0001,998,0002,289,664