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 4, 2021 23:32Yurkov AlekseyYurkov AlekseyScore: 6,713Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 4, 2021 23:326,67795,717,54372,443,0001,006,0002,273,280
2May 4, 2021 23:146,677101,068,53472,437,0001,006,0002,269,184
3May 4, 2021 23:146,685101,927,83773,540,00002,277,376
4May 4, 2021 23:326,693102,916,26672,612,0001,008,0002,277,376
5May 4, 2021 23:136,693100,617,49072,619,0001,008,0002,277,376
6May 4, 2021 23:146,69497,098,00970,649,0002,985,0002,277,376
7May 4, 2021 23:326,69799,948,81572,658,0001,009,0002,527,232
8May 4, 2021 23:146,69799,911,34473,669,00002,281,472
9May 4, 2021 23:146,697107,678,89372,662,0001,009,0002,277,376
10May 4, 2021 23:146,697102,553,17773,663,00002,265,088
11May 4, 2021 23:146,698103,684,82873,673,00002,269,184
12May 4, 2021 23:146,69898,641,03872,671,0001,009,0002,273,280
13May 4, 2021 23:146,70196,082,02572,710,000996,0002,273,280
14May 4, 2021 23:326,70298,890,83371,707,0002,019,0002,277,376
15May 4, 2021 23:136,70998,369,11171,810,0001,994,0002,277,376
16May 4, 2021 23:136,71298,702,70872,840,000997,0002,531,328
17May 4, 2021 23:146,712100,406,10370,839,0002,993,0002,277,376
18May 4, 2021 23:136,713103,254,99172,845,000997,0002,277,376
19May 4, 2021 23:146,713100,000,55671,843,0001,995,0002,531,328
20May 4, 2021 23:136,71397,277,61771,849,0001,995,0002,379,776
21May 4, 2021 23:136,713103,788,19370,853,0002,993,0002,359,296
22May 4, 2021 23:146,714105,249,39571,858,0001,996,0002,281,472
23May 4, 2021 23:146,71597,563,46172,865,000998,0002,519,040
24May 4, 2021 23:326,71699,699,64771,876,0001,996,0002,269,184
25May 4, 2021 23:146,71699,501,96271,879,0001,996,0002,273,280
26May 4, 2021 23:136,71698,423,70371,882,0001,996,0002,277,376
27May 4, 2021 23:136,717103,740,68171,888,0001,996,0002,273,280
28May 4, 2021 23:146,718101,579,33671,902,0001,997,0002,277,376
29May 4, 2021 23:146,719100,350,44971,908,0001,997,0002,277,376
30May 4, 2021 23:326,71999,541,16871,909,0001,997,0002,273,280
31May 4, 2021 23:326,720101,686,46972,925,000998,0002,277,376
32May 4, 2021 23:326,72196,959,94371,933,0001,998,0002,277,376
33May 4, 2021 23:326,72398,290,40772,954,000999,0002,277,376
34May 4, 2021 23:146,725101,797,83971,973,0001,999,0002,277,376
35May 4, 2021 23:146,72697,367,25871,987,0001,999,0002,527,232
36May 4, 2021 23:136,72695,503,25672,989,000999,0002,277,376