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:56Yuriy LyfenkoYuriy LyfenkoScore: 5,582Success
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:565,55090,262,63759,044,0002,001,0002,523,136
2May 19, 2021 20:565,56990,193,51860,250,0001,004,0002,523,136
3May 19, 2021 20:565,57187,984,44260,281,0001,004,0002,396,160
4May 19, 2021 20:565,57586,885,11660,321,0001,005,0002,523,136
5May 19, 2021 20:565,57687,531,84761,337,00002,400,256
6May 19, 2021 20:565,57883,675,57559,349,0002,011,0002,387,968
7May 19, 2021 20:565,58286,520,53360,395,0001,006,0002,265,088
8May 19, 2021 20:565,58283,046,43560,398,0001,006,0002,523,136
9May 19, 2021 20:565,60290,222,72260,616,0001,010,0002,478,080
10May 19, 2021 20:565,892127,920,35464,807,15202,248,704
11May 19, 2021 20:565,892129,122,87464,810,59702,240,512
12May 19, 2021 20:565,901129,889,19564,914,61802,248,704