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 11, 2021 07:04Sergey StreminSergey StreminScore: 9,400Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 11, 2021 07:059,368127,425,95471,030,00032,013,0002,289,664
2May 11, 2021 07:049,374129,711,48368,073,00035,037,0002,289,664
3May 11, 2021 07:039,378126,547,05564,098,00039,059,0002,375,680
4May 11, 2021 07:049,378136,416,28480,121,00023,034,0002,281,472
5May 11, 2021 07:059,389127,860,46372,193,00031,083,0002,289,664
6May 11, 2021 07:059,391130,852,52061,177,00042,122,0002,371,584
7May 11, 2021 07:059,394127,316,30776,248,00027,088,0002,289,664
8May 11, 2021 07:039,395127,512,38280,264,00023,076,0002,281,472
9May 11, 2021 07:039,397128,101,23383,299,00020,072,0002,379,776
10May 11, 2021 07:059,398131,844,46961,226,00042,156,0002,371,584
11May 11, 2021 07:059,399123,405,09182,309,00021,079,0002,379,776
12May 11, 2021 07:039,399128,441,17586,324,00017,064,0002,379,776
13May 11, 2021 07:039,399134,074,66567,250,00036,134,0002,383,872
14May 11, 2021 07:049,400127,825,16358,227,00045,176,0002,289,664
15May 11, 2021 07:059,402123,851,44157,232,00046,187,0002,367,488
16May 11, 2021 07:049,404126,926,82269,297,00034,146,0002,289,664
17May 11, 2021 07:039,405128,550,02067,296,00036,159,0002,289,664
18May 11, 2021 07:049,406130,988,85571,325,00032,146,0002,375,680
19May 11, 2021 07:049,407127,642,75149,227,00054,251,0002,379,776
20May 11, 2021 07:039,410126,014,41283,413,00020,099,0002,383,872
21May 11, 2021 07:039,413135,438,45067,352,00036,189,0002,289,664
22May 11, 2021 07:049,416134,994,30260,334,00043,239,0002,289,664
23May 11, 2021 07:049,423127,367,54770,442,00033,208,0002,371,584
24May 11, 2021 07:059,426129,166,26682,749,00020,936,0002,289,664
25May 11, 2021 07:039,437128,609,23491,830,00011,977,0002,457,600
26May 11, 2021 07:059,440135,024,76665,895,00037,940,0002,289,664
27May 11, 2021 07:049,445131,469,44866,931,00036,962,0002,281,472