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 listSep 3, 2024 18:57Yuriy LyfenkoYuriy LyfenkoScore: 3,737Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Sep 3, 2024 18:573,71264,271,90738,843,0001,991,0002,445,312
2Sep 3, 2024 18:573,71666,641,56638,886,0001,994,0002,453,504
3Sep 3, 2024 18:573,71762,812,83938,890,0001,994,0002,531,328
4Sep 3, 2024 18:573,72261,985,00538,945,0001,997,0002,531,328
5Sep 3, 2024 18:573,72362,456,06338,951,0001,997,0002,445,312
6Sep 3, 2024 18:573,72361,773,66938,952,0001,997,0002,535,424
7Sep 3, 2024 18:573,72463,486,40038,970,0001,998,0002,269,184
8Sep 3, 2024 18:573,73063,866,49139,025,0002,001,0002,457,600
9Sep 3, 2024 18:573,73664,663,64239,094,0002,004,0002,535,424
10Sep 3, 2024 18:573,73764,620,43039,104,0002,005,0002,273,280
11Sep 3, 2024 18:573,73862,871,19939,117,0002,006,0002,535,424
12Sep 3, 2024 18:573,74261,809,98939,153,0002,007,0002,535,424
13Sep 3, 2024 18:573,74966,901,39040,237,0001,005,0002,449,408
14Sep 3, 2024 18:573,75263,816,74840,271,0001,006,0002,531,328
15Sep 3, 2024 18:573,75763,200,08940,317,0001,007,0002,531,328
16Sep 3, 2024 18:573,76162,358,50841,368,00002,449,408
17Sep 3, 2024 18:573,76262,266,12740,369,0001,009,0002,535,424
18Sep 3, 2024 18:573,77164,631,15040,469,0001,011,0002,535,424