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 2, 2021 04:45Yuriy LyfenkoYuriy LyfenkoScore: 12,177Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 2, 2021 04:5912,142159,338,129132,558,0001,004,0002,281,472
2May 2, 2021 04:4512,155159,916,958132,701,0001,005,0002,277,376
3May 2, 2021 04:5912,161156,867,969131,778,0001,996,0002,281,472
4May 2, 2021 04:4512,165166,080,831132,816,000998,0002,281,472
5May 2, 2021 04:4512,165164,096,584133,819,00002,281,472
6May 2, 2021 04:4512,166162,925,188132,827,000998,0002,277,376
7May 2, 2021 04:5912,169159,817,419132,863,000998,0002,277,376
8May 2, 2021 04:5912,169162,630,358130,866,0002,996,0002,269,184
9May 2, 2021 04:4512,169156,284,197132,851,0001,006,0002,277,376
10May 2, 2021 04:4512,169159,315,080132,857,0001,006,0002,269,184
11May 2, 2021 04:5912,175157,013,744131,922,0001,998,0002,281,472
12May 2, 2021 04:5912,177159,285,986131,944,0001,999,0002,527,232
13May 2, 2021 04:5912,177155,386,698131,953,0001,999,0002,289,664
14May 2, 2021 04:4512,177157,278,797131,951,0001,999,0002,289,664
15May 2, 2021 04:4512,178154,133,175130,955,0002,998,0002,363,392
16May 2, 2021 04:4512,178158,070,778132,960,000999,0002,281,472
17May 2, 2021 04:4512,181155,657,999131,991,0001,999,0002,273,280
18May 2, 2021 04:4512,181156,395,272130,988,0002,999,0002,277,376
19May 2, 2021 04:4512,182155,092,454132,006,0002,000,0002,281,472
20May 2, 2021 04:4512,182157,987,593132,002,0002,000,0002,281,472
21May 2, 2021 04:4512,183159,090,397131,012,0003,000,0002,281,472
22May 2, 2021 04:4512,184156,806,505133,023,0001,000,0002,281,472
23May 2, 2021 04:4512,188156,014,826131,068,0003,001,0002,527,232
24May 2, 2021 04:4512,192164,717,478131,108,0003,002,0002,281,472
25May 2, 2021 04:5912,192160,840,438131,108,0003,002,0002,273,280
26May 2, 2021 04:5912,195163,966,558131,141,0003,003,0002,281,472
27May 2, 2021 04:4512,207158,255,636132,269,0002,004,0002,269,184