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,903Success
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,895118,082,72653,841,04302,269,184
2Apr 18, 2024 23:534,909112,875,19653,998,35202,269,184
3Apr 18, 2024 23:534,910117,910,62354,005,58002,265,088
4Apr 18, 2024 23:537,835111,704,26085,178,0001,002,0002,289,664
5Apr 18, 2024 23:537,897119,238,08184,872,0001,996,0002,289,664
6Apr 18, 2024 23:537,897110,578,32584,873,0001,997,0002,269,184
7Apr 18, 2024 23:537,903109,520,37485,939,000999,0002,289,664
8Apr 18, 2024 23:537,917114,444,09887,084,00002,289,664
9Apr 18, 2024 23:537,927111,642,94485,194,0002,004,0002,289,664
10Apr 18, 2024 23:537,929113,102,73385,214,0002,005,0002,289,664
11Apr 18, 2024 23:537,960112,447,96386,559,0001,006,0002,289,664
12Apr 18, 2024 23:537,989116,341,69185,883,0001,997,0002,289,664