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 20, 2021 14:50Andrey TsvetkovAndrey TsvetkovScore: 11,894Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jun 20, 2021 14:4411,851153,045,416128,359,0002,005,0002,330,624
2Jun 20, 2021 14:5011,863157,058,340128,482,0002,007,0002,510,848
3Jun 20, 2021 14:5011,864157,678,304128,497,0002,007,0002,506,752
4Jun 20, 2021 14:4411,869153,483,798128,553,0002,008,0002,510,848
5Jun 20, 2021 14:4211,870161,139,712128,563,0002,008,0002,514,944
6Jun 20, 2021 14:4211,871153,004,158128,569,0002,008,0002,510,848
7Jun 20, 2021 14:4211,873157,627,683128,593,0002,009,0002,330,624
8Jun 20, 2021 14:4211,875164,178,490128,619,0002,009,0002,330,624
9Jun 20, 2021 14:5011,875159,324,706128,615,0002,009,0002,330,624
10Jun 20, 2021 14:4411,876155,476,329129,634,0001,004,0002,310,144
11Jun 20, 2021 14:4411,880161,589,018128,667,0002,010,0002,330,624
12Jun 20, 2021 14:4411,880159,722,815129,672,0001,005,0002,502,656
13Jun 20, 2021 14:4211,880155,689,388129,670,0001,005,0002,330,624
14Jun 20, 2021 14:4211,881158,769,100128,698,0001,995,0002,326,528
15Jun 20, 2021 14:4211,887203,789,646130,759,91302,187,264
16Jun 20, 2021 14:5011,888195,924,078130,767,62702,191,360
17Jun 20, 2021 14:5011,889203,027,984130,774,21202,179,072
18Jun 20, 2021 14:5011,890153,958,076127,790,0002,995,0002,506,752
19Jun 20, 2021 14:4411,894162,658,144128,835,0001,997,0002,519,040
20Jun 20, 2021 14:4211,895163,646,080128,847,0001,997,0002,514,944
21Jun 20, 2021 14:4211,895157,537,324129,850,000998,0002,330,624
22Jun 20, 2021 14:4211,895159,038,933128,853,0001,997,0002,502,656
23Jun 20, 2021 14:5011,895155,501,624128,847,0001,997,0002,506,752
24Jun 20, 2021 14:5011,895155,131,209128,846,0001,997,0002,375,680
25Jun 20, 2021 14:4411,898155,366,345127,879,0002,997,0002,514,944
26Jun 20, 2021 14:4411,899154,145,733127,887,0002,997,0002,330,624
27Jun 20, 2021 14:5011,900164,822,090128,902,0001,998,0002,510,848
28Jun 20, 2021 14:5011,903159,345,479127,934,0002,998,0002,330,624
29Jun 20, 2021 14:4411,903190,658,236130,930,63102,187,264
30Jun 20, 2021 14:4211,903198,248,267130,938,00002,179,072
31Jun 20, 2021 14:4411,906198,247,638130,962,01102,187,264
32Jun 20, 2021 14:4411,910157,429,280129,012,0002,000,0002,510,848
33Jun 20, 2021 14:5011,915153,654,979129,062,0002,000,0002,506,752
34Jun 20, 2021 14:4411,916191,115,039131,076,45902,187,264
35Jun 20, 2021 14:5011,917200,019,335131,087,65502,187,264
36Jun 20, 2021 14:4211,917196,554,101131,091,58102,183,168