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 19, 2021 20:32Yuriy LyfenkoYuriy LyfenkoScore: 8,280Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 19, 2021 20:328,2584,314,957,20688,823,0002,018,0002,322,432
2May 19, 2021 20:328,267650,416,39087,942,0002,998,0002,326,528
3May 19, 2021 20:328,2701,530,857,59687,976,0002,999,0002,322,432
4May 19, 2021 20:328,2711,264,835,12588,978,0001,999,0002,326,528
5May 19, 2021 20:328,2712,897,399,30489,983,000999,0002,322,432
6May 19, 2021 20:328,2784,519,688,53390,050,0001,011,0002,326,528
7May 19, 2021 20:328,2802,222,935,57489,079,0002,001,0002,326,528
8May 19, 2021 20:328,2814,350,467,02590,083,0001,012,0002,326,528
9May 19, 2021 20:328,2871,299,802,68789,150,0002,003,0002,322,432
10May 19, 2021 20:328,448504,588,01892,929,39102,248,704
11May 19, 2021 20:328,4531,508,611,95392,977,99502,248,704
12May 19, 2021 20:328,5861,326,300,13794,445,35302,248,704