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 05:10Yuriy LyfenkoYuriy LyfenkoScore: 12,101Success
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 05:1012,074159,103,665131,817,000998,0002,392,064
2May 2, 2021 07:1012,075160,066,350130,832,0001,997,0002,392,064
3May 2, 2021 07:1012,084158,539,271130,926,0001,998,0002,260,992
4May 2, 2021 05:1012,089160,275,869130,979,0001,999,0002,260,992
5May 2, 2021 07:1012,092158,075,747132,012,0001,000,0002,383,872
6May 2, 2021 07:1012,092163,067,897131,010,0002,000,0002,396,160
7May 2, 2021 05:1012,093158,093,663130,018,0003,000,0002,260,992
8May 2, 2021 07:1012,094163,860,834132,030,0001,000,0002,396,160
9May 2, 2021 05:1012,098158,500,563131,077,0002,001,0002,523,136
10May 2, 2021 07:1012,101159,980,681131,110,0002,001,0002,260,992
11May 2, 2021 05:1012,101160,047,819131,107,0002,001,0002,260,992
12May 2, 2021 05:1012,102163,275,672132,117,0001,000,0002,523,136
13May 2, 2021 05:1012,104162,495,036131,137,0002,002,0002,387,968
14May 2, 2021 05:1012,105163,176,896132,149,0001,001,0002,392,064
15May 2, 2021 07:1012,114159,510,723130,254,0003,005,0002,387,968
16May 2, 2021 07:1012,117158,022,104131,283,0002,004,0002,260,992
17May 2, 2021 07:1012,120156,041,956131,315,0002,004,0002,396,160
18May 2, 2021 05:1012,145160,715,758133,598,00002,396,160