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, 2024 00:09Joad NacerJoad NacerScore: 7,358Success
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, 2024 00:094,716124,714,67751,875,50702,277,376
2May 8, 2024 00:094,724116,662,00951,962,04002,273,280
3May 8, 2024 00:094,728107,770,21352,002,69102,273,280
4May 8, 2024 00:097,348108,546,65779,833,000997,0002,289,664
5May 8, 2024 00:097,350105,810,76278,858,0001,996,0002,289,664
6May 8, 2024 00:097,355104,231,03679,909,000998,0002,269,184
7May 8, 2024 00:097,358108,247,11178,935,0001,998,0002,527,232
8May 8, 2024 00:097,361103,226,48778,971,0001,999,0002,408,448
9May 8, 2024 00:097,363108,652,43878,995,0001,999,0002,289,664
10May 8, 2024 00:097,365104,943,82379,018,0002,000,0002,359,296
11May 8, 2024 00:097,368103,963,67680,048,0001,000,0002,269,184
12May 8, 2024 00:097,382106,168,95379,199,0002,005,0002,289,664