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 21, 2021 17:40Yuriy LyfenkoYuriy LyfenkoScore: 3,908Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Aug 21, 2021 17:403,84864,844,78440,310,0002,015,0002,392,064
2Aug 21, 2021 17:403,87077,484,83742,567,00002,392,064
3Aug 21, 2021 17:403,87466,985,44641,599,0001,014,0002,265,088
4Aug 21, 2021 17:403,89771,111,62640,878,0001,994,0002,527,232
5Aug 21, 2021 17:403,90168,606,35541,918,000998,0002,387,968
6Aug 21, 2021 17:403,90871,455,05140,984,0001,999,0002,265,088
7Aug 21, 2021 17:403,90868,148,07140,987,0001,999,0002,519,040
8Aug 21, 2021 17:403,90874,617,06140,990,0001,999,0002,265,088
9Aug 21, 2021 17:403,91569,392,08342,068,0001,001,0002,392,064
10Aug 21, 2021 17:403,927103,230,56843,199,96902,232,320
11Aug 21, 2021 17:403,944115,305,88043,382,35802,244,608
12Aug 21, 2021 17:403,959114,809,70443,553,37302,236,416