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 listJul 27, 2024 15:50Joad NacerJoad NacerError
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jul 27, 2024 15:4900000Error: No answer to stdout. Died or killed?stderr
2Jul 27, 2024 15:504,528112,099,33349,809,19602,285,568
3Jul 27, 2024 15:504,539106,369,24549,932,03802,289,664
4Jul 27, 2024 15:504,552104,493,62850,073,23802,285,568
5Jul 27, 2024 15:506,930101,066,46075,229,0001,003,0002,433,024
6Jul 27, 2024 15:506,937101,551,59276,304,00002,433,024
7Jul 27, 2024 15:506,941104,068,54676,351,00002,433,024
8Jul 27, 2024 15:506,94399,338,64675,369,0001,004,0002,510,848
9Jul 27, 2024 15:506,94797,429,86476,414,00002,437,120
10Jul 27, 2024 15:506,953101,210,55276,484,00002,273,280
11Jul 27, 2024 15:506,955104,657,17376,504,00002,535,424
12Jul 27, 2024 15:506,957101,243,09376,530,00002,535,424
13Jul 27, 2024 15:506,95994,541,64376,545,00002,428,928