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 23:53Joad NacerJoad NacerScore: 7,920Success
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 23:534,905113,894,67453,951,88702,273,280
2Apr 18, 2024 23:534,906114,416,26153,966,57602,273,280
3Apr 18, 2024 23:534,912113,732,42354,028,73502,269,184
4Apr 18, 2024 23:537,901108,979,77384,915,0001,998,0002,289,664
5Apr 18, 2024 23:537,911112,660,82586,016,0001,000,0002,269,184
6Apr 18, 2024 23:537,919110,577,41985,107,0002,002,0002,289,664
7Apr 18, 2024 23:537,920111,661,98285,123,0002,002,0002,273,280
8Apr 18, 2024 23:537,923109,357,31986,156,0001,001,0002,289,664
9Apr 18, 2024 23:537,924111,529,23586,165,0001,001,0002,273,280
10Apr 18, 2024 23:537,929114,758,83085,213,0002,005,0002,289,664
11Apr 18, 2024 23:537,935110,892,99885,279,0002,006,0002,289,664
12Apr 18, 2024 23:537,962113,841,10587,582,00002,269,184