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 04:37Yuriy LyfenkoYuriy LyfenkoScore: 12,221Success
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 04:3712,182155,042,415132,002,0002,000,0002,281,472
2May 2, 2021 04:3712,186155,597,283132,046,0002,000,0002,273,280
3May 2, 2021 04:3712,195159,651,729132,148,0002,002,0002,273,280
4May 2, 2021 04:3712,204160,147,954133,243,0001,001,0002,269,184
5May 2, 2021 04:3712,206161,186,138132,263,0002,003,0002,273,280
6May 2, 2021 04:3712,207155,448,340132,275,0002,004,0002,269,184
7May 2, 2021 04:3712,207156,051,718132,276,0002,004,0002,281,472
8May 2, 2021 04:3712,217158,647,348133,383,0001,002,0002,289,664
9May 2, 2021 04:3712,219161,049,631133,404,0001,003,0002,277,376
10May 2, 2021 04:3712,221160,463,011133,425,0001,003,0002,281,472
11May 2, 2021 04:3712,224163,981,649133,461,0001,003,0002,281,472
12May 2, 2021 04:3712,233164,829,082134,563,00002,265,088
13May 2, 2021 04:3712,233161,479,538133,557,0001,004,0002,269,184
14May 2, 2021 04:3712,242165,589,227134,661,00002,269,184
15May 2, 2021 04:3712,256160,528,303132,822,0001,997,0002,355,200
16May 2, 2021 04:3712,256161,812,925132,815,0001,997,0002,281,472
17May 2, 2021 04:3712,257163,527,826132,830,0001,997,0002,281,472
18May 2, 2021 04:3712,258163,413,416132,846,0001,997,0002,273,280