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 listMay 2, 2021 17:54Yurkov AlekseyYurkov AlekseyScore: 7,383Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 2, 2021 17:547,373106,094,52880,102,0001,001,0002,269,184
2May 2, 2021 17:547,373107,421,09279,097,0002,002,0002,277,376
3May 2, 2021 17:537,375103,953,27479,121,0002,003,0002,355,200
4May 2, 2021 17:537,375106,311,27579,126,0002,003,0002,527,232
5May 2, 2021 17:537,375109,380,55278,125,0003,004,0002,277,376
6May 2, 2021 17:537,379104,154,66079,169,0002,004,0002,363,392
7May 2, 2021 17:537,380103,629,76579,180,0002,004,0002,277,376
8May 2, 2021 17:547,381107,282,34579,191,0002,004,0002,277,376
9May 2, 2021 17:547,381112,695,07679,186,0002,004,0002,277,376
10May 2, 2021 17:547,383110,014,72679,203,0002,005,0002,277,376
11May 2, 2021 17:537,385101,699,85279,229,0002,005,0002,277,376
12May 2, 2021 17:537,386109,460,61879,243,0002,006,0002,277,376
13May 2, 2021 17:547,394103,996,07681,331,00002,277,376
14May 2, 2021 17:547,400104,510,69680,391,0001,004,0002,277,376
15May 2, 2021 17:547,401104,139,13180,401,0001,005,0002,277,376
16May 2, 2021 17:547,401106,741,85181,413,00002,277,376
17May 2, 2021 17:537,404101,741,37078,427,0003,016,0002,277,376
18May 2, 2021 17:537,404105,740,37679,437,0002,011,0002,277,376