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 listMay 3, 2021 00:58Yuriy LyfenkoYuriy LyfenkoScore: 7,243Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 3, 2021 00:587,21298,678,84577,327,0002,008,0002,277,376
2May 3, 2021 00:587,237107,418,64377,596,0002,015,0002,281,472
3May 3, 2021 00:587,241110,586,83378,643,0001,008,0002,277,376
4May 3, 2021 00:587,242109,210,16678,656,0001,008,0002,281,472
5May 3, 2021 00:587,243105,351,78778,668,0001,008,0002,281,472
6May 3, 2021 00:587,258108,001,83979,837,00002,269,184
7May 3, 2021 00:587,259107,337,25378,851,000998,0002,281,472
8May 3, 2021 00:587,260111,187,53777,859,0001,996,0002,277,376
9May 3, 2021 00:587,260112,475,77779,859,00002,273,280