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 20, 2024 16:57Joad NacerJoad NacerScore: 7,823Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Apr 20, 2024 16:574,758114,415,52852,337,20302,265,088
2Apr 20, 2024 16:574,758117,600,23652,341,80502,260,992
3Apr 20, 2024 16:574,762123,209,45152,385,48202,273,280
4Apr 20, 2024 16:577,815111,223,13983,965,0001,999,0002,289,664
5Apr 20, 2024 16:577,818109,713,81083,996,0001,999,0002,289,664
6Apr 20, 2024 16:577,821107,640,49684,029,0002,000,0002,273,280
7Apr 20, 2024 16:577,823115,610,90684,057,0002,001,0002,523,136
8Apr 20, 2024 16:577,829113,818,13584,119,0002,002,0002,273,280
9Apr 20, 2024 16:577,833109,463,73084,162,0002,003,0002,289,664
10Apr 20, 2024 16:577,839110,186,81284,221,0002,005,0002,531,328
11Apr 20, 2024 16:577,839112,415,96284,224,0002,005,0002,289,664
12Apr 20, 2024 16:577,846107,524,85285,308,0001,003,0002,281,472