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 1, 2021 13:49Yurkov AlekseyYurkov AlekseyScore: 11,008Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 1, 2021 13:5110,985145,938,825119,839,000998,0002,531,328
2May 1, 2021 13:5110,986144,262,480118,851,0001,997,0002,277,376
3May 1, 2021 13:5010,989145,928,087119,884,000999,0002,277,376
4May 1, 2021 13:5110,990145,060,853119,895,000999,0002,277,376
5May 1, 2021 13:5010,993148,855,312119,926,000999,0002,269,184
6May 1, 2021 13:4910,993142,866,699118,929,0001,998,0002,277,376
7May 1, 2021 13:5110,994146,455,442117,931,0002,998,0002,281,472
8May 1, 2021 13:5110,994154,349,124118,935,0001,998,0002,273,280
9May 1, 2021 13:4910,997142,583,313118,965,0001,999,0002,265,088
10May 1, 2021 13:5110,998142,734,595118,984,0001,999,0002,277,376
11May 1, 2021 13:5111,000148,001,463119,002,0002,000,0002,277,376
12May 1, 2021 13:4911,002150,800,360119,027,0002,000,0002,269,184
13May 1, 2021 13:5111,004148,972,610119,048,0002,000,0002,277,376
14May 1, 2021 13:4911,008146,108,873119,091,0002,001,0002,523,136
15May 1, 2021 13:5011,010149,038,793119,111,0002,001,0002,277,376
16May 1, 2021 13:5011,010144,399,007120,111,0001,000,0002,367,488
17May 1, 2021 13:5011,010142,893,881119,108,0002,001,0002,281,472
18May 1, 2021 13:4911,012152,823,654119,134,0002,002,0002,277,376
19May 1, 2021 13:4911,013146,917,299119,144,0002,002,0002,273,280
20May 1, 2021 13:5011,019147,630,294120,210,0001,001,0002,277,376
21May 1, 2021 13:5011,020141,724,782119,220,0002,003,0002,379,776
22May 1, 2021 13:5111,020149,199,187120,217,0001,001,0002,269,184
23May 1, 2021 13:4911,020150,952,038119,216,0002,003,0002,277,376
24May 1, 2021 13:5011,022145,916,365119,235,0002,003,0002,277,376
25May 1, 2021 13:5011,024143,026,508119,262,0002,004,0002,277,376
26May 1, 2021 13:4911,035144,098,638119,384,0002,006,0002,531,328
27May 1, 2021 13:4911,039152,424,101120,431,0001,003,0002,265,088