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 8, 2021 15:55Yuriy LyfenkoYuriy LyfenkoScore: 8,630Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 8, 2021 15:568,609121,566,35793,693,0001,007,0002,523,136
2May 8, 2021 15:568,619120,767,16092,813,0001,995,0002,334,720
3May 8, 2021 15:558,621120,787,75593,838,000998,0002,330,624
4May 8, 2021 15:508,622125,529,67693,845,000998,0002,527,232
5May 8, 2021 15:518,623121,174,69594,849,00002,519,040
6May 8, 2021 15:508,623122,020,60593,852,000998,0002,527,232
7May 8, 2021 15:518,623122,696,14391,857,0002,995,0002,527,232
8May 8, 2021 15:558,623119,175,76892,859,0001,996,0002,527,232
9May 8, 2021 15:568,623122,239,30892,855,0001,996,0002,334,720
10May 8, 2021 15:568,623124,013,09794,858,00002,330,624
11May 8, 2021 15:558,624119,561,02791,869,0002,995,0002,527,232
12May 8, 2021 15:508,624119,614,57392,867,0001,997,0002,351,104
13May 8, 2021 15:518,624121,354,70593,863,000998,0002,330,624
14May 8, 2021 15:508,626119,720,98793,887,000998,0002,330,624
15May 8, 2021 15:568,626119,890,38393,885,000998,0002,527,232
16May 8, 2021 15:508,628124,823,98692,910,0001,998,0002,330,624
17May 8, 2021 15:518,628121,532,81691,916,0002,997,0002,330,624
18May 8, 2021 15:568,629123,509,64492,922,0001,998,0002,334,720
19May 8, 2021 15:568,630118,066,26892,933,0001,998,0002,330,624
20May 8, 2021 15:558,631128,089,63093,945,000999,0002,334,720
21May 8, 2021 15:558,632124,464,74393,955,000999,0002,330,624
22May 8, 2021 15:518,632125,004,27193,950,000999,0002,527,232
23May 8, 2021 15:568,633124,192,10893,969,000999,0002,531,328
24May 8, 2021 15:558,633128,375,84692,960,0001,999,0002,330,624
25May 8, 2021 15:508,635128,545,19191,984,0002,999,0002,322,432
26May 8, 2021 15:508,636121,618,68493,001,0002,000,0002,531,328
27May 8, 2021 15:518,637117,641,93593,003,0002,000,0002,330,624
28May 8, 2021 15:508,638123,942,68093,015,0002,000,0002,330,624
29May 8, 2021 15:518,639122,708,33592,025,0003,000,0002,330,624
30May 8, 2021 15:518,639121,121,58694,032,0001,000,0002,531,328
31May 8, 2021 15:558,639123,525,25594,024,0001,000,0002,523,136
32May 8, 2021 15:568,640123,182,19394,043,0001,000,0002,330,624
33May 8, 2021 15:518,641120,658,96493,054,0002,001,0002,334,720
34May 8, 2021 15:508,642122,494,38991,056,0004,002,0002,531,328
35May 8, 2021 15:558,645121,005,49692,094,0003,003,0002,527,232
36May 8, 2021 15:558,649122,258,04491,138,0004,006,0002,330,624