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 listJun 16, 2021 21:43Andrey TsvetkovAndrey TsvetkovScore: 12,332Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jun 16, 2021 21:4412,302158,756,705132,319,0003,007,0002,519,040
2Jun 16, 2021 21:4312,316163,174,732134,475,0001,003,0002,498,560
3Jun 16, 2021 21:4412,316158,790,957134,477,0001,003,0002,330,624
4Jun 16, 2021 21:4412,317156,955,271133,479,0002,007,0002,330,624
5Jun 16, 2021 21:4412,320159,652,566132,507,0003,011,0002,326,528
6Jun 16, 2021 21:4312,322155,387,312134,543,0001,004,0002,326,528
7Jun 16, 2021 21:4312,324160,443,910134,558,0001,004,0002,330,624
8Jun 16, 2021 21:4312,325162,996,607135,573,00002,306,048
9Jun 16, 2021 21:4312,326163,254,533134,584,0001,004,0002,330,624
10Jun 16, 2021 21:4412,326161,375,241133,573,0002,008,0002,502,656
11Jun 16, 2021 21:4412,330164,524,861133,618,0002,009,0002,330,624
12Jun 16, 2021 21:4312,331159,056,828133,633,0002,009,0002,330,624
13Jun 16, 2021 21:4312,332164,450,394134,651,0001,004,0002,514,944
14Jun 16, 2021 21:4312,334158,920,469133,664,0002,009,0002,330,624
15Jun 16, 2021 21:4312,337167,587,744133,692,0002,010,0002,506,752
16Jun 16, 2021 21:4312,338205,077,090135,716,23002,191,360
17Jun 16, 2021 21:4412,345162,812,814132,800,0002,995,0002,330,624
18Jun 16, 2021 21:4412,347194,181,801135,820,76602,191,360
19Jun 16, 2021 21:4312,347194,559,808135,817,64602,306,048
20Jun 16, 2021 21:4412,350160,679,523133,848,0001,997,0002,330,624
21Jun 16, 2021 21:4412,350191,462,724135,854,09102,174,976
22Jun 16, 2021 21:4412,352163,799,446132,871,0002,997,0002,330,624
23Jun 16, 2021 21:4412,368190,620,062136,050,31502,183,168
24Jun 16, 2021 21:4312,371198,367,249136,082,51102,187,264