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 listJun 4, 2021 14:30Yurkov AlekseyYurkov AlekseyScore: 6,654Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jun 4, 2021 14:296,63994,026,60470,027,0003,001,0002,277,376
2Jun 4, 2021 14:296,64597,749,24571,097,0002,002,0002,277,376
3Jun 4, 2021 14:306,64598,401,20670,089,0003,003,0002,277,376
4Jun 4, 2021 14:296,64798,603,67371,115,0002,003,0002,277,376
5Jun 4, 2021 14:296,647103,041,50971,115,0002,003,0002,527,232
6Jun 4, 2021 14:306,648100,332,94072,129,0001,001,0002,277,376
7Jun 4, 2021 14:306,64998,671,88571,132,0002,003,0002,277,376
8Jun 4, 2021 14:306,650101,233,46471,149,0002,004,0002,277,376
9Jun 4, 2021 14:296,65196,020,98171,153,0002,004,0002,277,376
10Jun 4, 2021 14:296,65294,747,49171,165,0002,004,0002,265,088
11Jun 4, 2021 14:306,65394,337,04771,181,0002,005,0002,277,376
12Jun 4, 2021 14:296,65396,945,97071,176,0002,004,0002,277,376
13Jun 4, 2021 14:306,65496,196,62671,185,0002,005,0002,265,088
14Jun 4, 2021 14:306,66196,287,81971,264,0002,007,0002,277,376
15Jun 4, 2021 14:306,66199,678,96170,265,0003,011,0002,535,424
16Jun 4, 2021 14:296,66497,265,33871,297,0002,008,0002,277,376
17Jun 4, 2021 14:296,66596,555,91871,307,0002,008,0002,273,280
18Jun 4, 2021 14:306,666101,190,28771,318,0002,008,0002,277,376
19Jun 4, 2021 14:307,323136,081,84580,547,87902,269,184
20Jun 4, 2021 14:297,333135,830,79680,663,41202,265,088
21Jun 4, 2021 14:307,352144,920,78980,870,06502,269,184
22Jun 4, 2021 14:297,352139,170,21580,871,53602,265,088
23Jun 4, 2021 14:297,363138,439,45680,996,76502,260,992
24Jun 4, 2021 14:307,370142,735,82381,066,43102,265,088