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 13:02Joad NacerJoad NacerScore: 7,711Success
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 13:024,823128,170,62753,056,59502,265,088
2Apr 20, 2024 13:024,836109,596,47153,198,73402,277,376
3Apr 20, 2024 13:024,848114,049,23853,324,58102,265,088
4Apr 20, 2024 13:027,680112,992,42083,476,0001,005,0002,289,664
5Apr 20, 2024 13:027,692110,369,11983,608,0001,007,0002,289,664
6Apr 20, 2024 13:027,696110,868,42183,653,0001,007,0002,277,376
7Apr 20, 2024 13:027,711109,361,72582,822,0001,995,0002,289,664
8Apr 20, 2024 13:027,713113,615,30583,847,000998,0002,289,664
9Apr 20, 2024 13:027,713111,712,78682,852,0001,996,0002,289,664
10Apr 20, 2024 13:027,729111,115,45284,014,0001,000,0002,289,664
11Apr 20, 2024 13:027,735108,219,29283,083,0002,002,0002,289,664
12Apr 20, 2024 13:027,740108,109,31284,137,0001,001,0002,359,296