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 listDec 14, 2024 14:22E SequeiraE SequeiraScore: 307,492Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Dec 14, 2024 14:22304,3053,375,483,4373,344,359,0002,998,0002,265,088
2Dec 14, 2024 14:30304,8083,380,850,6443,351,888,000999,0002,510,848
3Dec 14, 2024 14:30304,9623,384,779,7543,352,586,0001,998,0002,519,040
4Dec 14, 2024 14:22305,3793,391,978,1643,356,170,0002,998,0002,277,376
5Dec 14, 2024 14:22305,5903,386,562,8193,360,488,000999,0002,277,376
6Dec 14, 2024 14:30305,8473,391,828,7033,362,323,0001,999,0002,285,568
7Dec 14, 2024 14:22306,5253,398,328,8983,370,772,000999,0002,277,376
8Dec 14, 2024 14:30306,7773,410,224,9963,371,553,0002,997,0002,277,376
9Dec 14, 2024 14:30307,3173,411,794,8133,378,490,0001,998,0002,514,944
10Dec 14, 2024 14:30307,4923,410,829,2463,380,412,0001,999,0002,519,040
11Dec 14, 2024 14:30307,8583,414,575,7033,385,444,000999,0002,514,944
12Dec 14, 2024 14:30307,8753,415,092,9413,385,629,000999,0002,277,376
13Dec 14, 2024 14:22308,2763,425,553,7733,391,032,00002,285,568
14Dec 14, 2024 14:22308,9633,432,292,9423,396,596,0001,998,0002,285,568
15Dec 14, 2024 14:22309,6563,441,212,3803,405,219,000999,0002,277,376
16Dec 14, 2024 14:22309,7913,432,157,5063,406,707,000999,0002,277,376
17Dec 14, 2024 14:22311,6763,457,801,4753,427,432,000999,0002,277,376
18Dec 14, 2024 14:30312,9393,471,252,3583,441,334,000999,0002,510,848