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:39Yuriy LyfenkoYuriy LyfenkoScore: 4,468Success
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:394,44572,783,22946,905,0001,995,0002,289,664
2Aug 21, 2021 17:394,44871,415,31946,932,0001,997,0002,289,664
3Aug 21, 2021 17:394,45273,181,80546,971,0001,998,0002,289,664
4Aug 21, 2021 17:394,45474,961,98946,998,0001,999,0002,289,664
5Aug 21, 2021 17:394,45673,891,70247,014,0002,000,0002,289,664
6Aug 21, 2021 17:394,46374,705,89247,086,0002,003,0002,273,280
7Aug 21, 2021 17:394,46872,868,89247,144,0002,006,0002,277,376
8Aug 21, 2021 17:394,47372,951,62947,194,0002,008,0002,289,664
9Aug 21, 2021 17:394,47677,730,57747,230,0002,009,0002,289,664
10Aug 21, 2021 17:394,905122,561,20153,953,17102,256,896
11Aug 21, 2021 17:394,914105,429,54454,057,84602,244,608
12Aug 21, 2021 17:394,930121,937,26854,226,35602,256,896