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 listApr 16, 2023 04:37Robert BurkeRobert BurkeError
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Apr 16, 2023 04:3900000Error: No answer to stdout. Died or killed?stderr
2Apr 16, 2023 04:3812,870198,560,246141,572,79002,244,608
3Apr 16, 2023 04:3712,885205,379,427141,731,04602,252,800
4Apr 16, 2023 04:3812,893210,313,844141,821,61302,252,800
5Apr 16, 2023 04:3712,903200,109,476141,931,97902,244,608
6Apr 16, 2023 04:3812,919203,777,521142,107,73702,273,280
7Apr 16, 2023 04:3713,037202,229,301143,406,54802,269,184