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 listAug 4, 2023 09:30Yurkov AlekseyYurkov AlekseyScore: 6,664Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Aug 4, 2023 09:306,63999,671,95770,033,0003,001,0002,277,376
2Aug 4, 2023 09:306,64594,659,90072,096,0001,001,0002,277,376
3Aug 4, 2023 09:306,64695,890,42371,103,0002,002,0002,527,232
4Aug 4, 2023 09:306,64696,130,92571,108,0002,003,0002,277,376
5Aug 4, 2023 09:306,65798,334,30871,222,0002,006,0002,277,376
6Aug 4, 2023 09:306,65998,349,81171,241,0002,006,0002,387,968
7Aug 4, 2023 09:306,66497,811,69371,297,0002,008,0002,269,184
8Aug 4, 2023 09:306,66595,315,65570,302,0003,012,0002,355,200
9Aug 4, 2023 09:306,66596,398,09271,308,0002,008,0002,277,376
10Aug 4, 2023 09:307,360140,193,05380,956,96302,256,896
11Aug 4, 2023 09:307,363148,963,59980,989,57902,265,088
12Aug 4, 2023 09:307,398146,224,65381,382,71702,269,184