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 18, 2024 20:49Joad NacerJoad NacerScore: 11,051Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Apr 18, 2024 20:4911,032145,840,583119,351,0002,005,0002,527,232
2Apr 18, 2024 20:4911,033145,042,144120,364,0001,003,0002,527,232
3Apr 18, 2024 20:4911,037145,912,125121,404,00002,273,280
4Apr 18, 2024 20:4911,039141,895,757120,428,0001,003,0002,387,968
5Apr 18, 2024 20:4911,042142,870,984121,464,00002,289,664
6Apr 18, 2024 20:4911,046143,393,981120,497,0001,004,0002,289,664
7Apr 18, 2024 20:4911,051151,561,280120,561,0001,004,0002,289,664
8Apr 18, 2024 20:4911,053148,714,860120,578,0001,004,0002,289,664
9Apr 18, 2024 20:4911,054151,903,861120,589,0001,004,0002,289,664
10Apr 18, 2024 20:4914,488216,804,424159,372,63602,269,184
11Apr 18, 2024 20:4914,501222,400,263159,514,57802,273,280
12Apr 18, 2024 20:4914,531220,814,801159,837,32302,269,184