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 8, 2021 16:32Yuriy LyfenkoYuriy LyfenkoScore: 8,364Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 8, 2021 16:338,350122,946,28390,855,000998,0002,330,624
2May 8, 2021 16:328,350117,979,16591,851,00002,531,328
3May 8, 2021 16:338,350120,269,14391,846,00002,330,624
4May 8, 2021 16:338,351115,730,96790,859,000998,0002,523,136
5May 8, 2021 16:328,351115,336,09390,860,000998,0002,330,624
6May 8, 2021 16:338,352118,101,45689,871,0001,997,0002,535,424
7May 8, 2021 16:338,359121,687,26489,954,0001,998,0002,535,424
8May 8, 2021 16:328,359115,525,23989,951,0001,998,0002,400,256
9May 8, 2021 16:338,362120,750,07089,984,0001,999,0002,531,328
10May 8, 2021 16:328,364118,194,61689,007,0003,000,0002,531,328
11May 8, 2021 16:328,365116,866,52089,010,0003,000,0002,531,328
12May 8, 2021 16:328,365117,578,00789,018,0003,000,0002,330,624
13May 8, 2021 16:328,366122,159,14989,025,0003,000,0002,531,328
14May 8, 2021 16:328,367127,201,83290,038,0002,000,0002,330,624
15May 8, 2021 16:338,368115,910,97589,048,0003,001,0002,334,720
16May 8, 2021 16:338,368127,789,19090,051,0002,001,0002,330,624
17May 8, 2021 16:338,374121,859,48189,115,0003,003,0002,330,624
18May 8, 2021 16:328,374121,758,10590,117,0002,002,0002,527,232