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 listJul 27, 2024 15:52Joad NacerJoad NacerScore: 6,815Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jul 27, 2024 15:524,461100,359,08149,073,46702,281,472
2Jul 27, 2024 15:524,464116,721,89749,100,45302,269,184
3Jul 27, 2024 15:524,46998,806,22849,161,63402,289,664
4Jul 27, 2024 15:526,807100,585,32472,878,0001,996,0002,273,280
5Jul 27, 2024 15:526,80896,796,10073,895,000998,0002,428,928
6Jul 27, 2024 15:526,81296,790,60472,937,0001,998,0002,433,024
7Jul 27, 2024 15:526,81593,064,62173,961,000999,0002,433,024
8Jul 27, 2024 15:526,81796,266,87373,984,000999,0002,437,120
9Jul 27, 2024 15:526,81795,066,03572,991,0001,999,0002,428,928
10Jul 27, 2024 15:526,81799,057,38472,991,0001,999,0002,424,832
11Jul 27, 2024 15:526,81996,409,65474,012,0001,000,0002,437,120
12Jul 27, 2024 15:526,827101,578,74674,093,0001,001,0002,433,024