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 4, 2021 23:19Yurkov AlekseyYurkov AlekseyScore: 9,122Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 4, 2021 23:199,081127,377,68797,894,0001,997,0002,281,472
2May 4, 2021 23:199,095126,387,27699,050,0001,000,0002,277,376
3May 4, 2021 23:199,095122,343,52898,044,0002,000,0002,392,064
4May 4, 2021 23:199,096123,999,25298,053,0002,001,0002,277,376
5May 4, 2021 23:199,096122,969,53398,058,0002,001,0002,265,088
6May 4, 2021 23:199,097128,188,02498,070,0002,001,0002,527,232
7May 4, 2021 23:199,101121,880,07999,112,0001,001,0002,277,376
8May 4, 2021 23:199,102123,641,15898,121,0002,002,0002,375,680
9May 4, 2021 23:199,104129,910,31898,145,0002,002,0002,277,376
10May 4, 2021 23:199,122122,957,59099,343,0001,003,0002,519,040
11May 4, 2021 23:199,124126,495,15498,361,0002,007,0002,277,376
12May 4, 2021 23:199,124133,671,64998,357,0002,007,0002,273,280
13May 4, 2021 23:199,127120,853,26699,392,0001,003,0002,269,184
14May 4, 2021 23:199,128124,238,47998,399,0002,008,0002,277,376
15May 4, 2021 23:199,130120,993,86198,423,0002,008,0002,351,104
16May 4, 2021 23:199,132125,329,73497,435,0003,013,0002,277,376
17May 4, 2021 23:199,133126,476,29999,458,0001,004,0002,281,472
18May 4, 2021 23:199,141123,568,73198,538,0002,010,0002,527,232