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 listSep 4, 2024 10:05Joad NacerJoad NacerScore: 4,457Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Sep 4, 2024 10:054,44279,404,39046,873,0001,994,0002,273,280
2Sep 4, 2024 10:034,44571,194,89147,903,000997,0002,535,424
3Sep 4, 2024 10:054,44870,628,54346,928,0001,996,0002,428,928
4Sep 4, 2024 10:034,44970,618,71947,939,000998,0002,535,424
5Sep 4, 2024 10:034,44972,257,90647,939,000998,0002,433,024
6Sep 4, 2024 10:054,44971,759,07247,944,000998,0002,433,024
7Sep 4, 2024 10:054,44968,977,51347,945,000998,0002,535,424
8Sep 4, 2024 10:054,44969,237,58546,945,0001,997,0002,424,832
9Sep 4, 2024 10:034,45075,102,10947,951,000998,0002,535,424
10Sep 4, 2024 10:054,45167,262,85046,962,0001,998,0002,428,928
11Sep 4, 2024 10:054,45171,006,01646,965,0001,998,0002,433,024
12Sep 4, 2024 10:054,45274,156,07347,970,000999,0002,273,280
13Sep 4, 2024 10:054,45476,180,18647,999,000999,0002,428,928
14Sep 4, 2024 10:054,45466,788,27147,990,000999,0002,535,424
15Sep 4, 2024 10:054,45770,129,94047,022,0002,000,0002,433,024
16Sep 4, 2024 10:054,45778,968,20047,028,0002,001,0002,437,120
17Sep 4, 2024 10:054,45871,949,68748,035,0001,000,0002,535,424
18Sep 4, 2024 10:034,45870,472,63248,040,0001,000,0002,273,280
19Sep 4, 2024 10:034,45970,714,11348,045,0001,000,0002,428,928
20Sep 4, 2024 10:034,46071,436,62247,060,0002,002,0002,273,280
21Sep 4, 2024 10:054,46070,915,44048,062,0001,001,0002,535,424
22Sep 4, 2024 10:054,46170,388,08448,065,0001,001,0002,420,736
23Sep 4, 2024 10:054,46272,870,72748,078,0001,001,0002,424,832
24Sep 4, 2024 10:054,46268,594,86848,086,0001,001,0002,514,944
25Sep 4, 2024 10:054,46368,895,59247,090,0002,003,0002,433,024
26Sep 4, 2024 10:054,46473,776,58847,098,0002,004,0002,428,928
27Sep 4, 2024 10:034,46470,086,02649,103,00002,433,024
28Sep 4, 2024 10:054,46576,761,60248,109,0001,002,0002,535,424
29Sep 4, 2024 10:054,46774,443,08347,132,0002,005,0002,269,184
30Sep 4, 2024 10:034,48070,639,44247,265,0002,011,0002,428,928