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 29, 2021 14:52Yuriy LyfenkoYuriy LyfenkoScore: 3,914Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jun 2, 2021 18:513,84373,612,73042,276,00002,527,232
2May 22, 2021 22:043,84367,937,67941,267,0001,006,0002,265,088
3May 24, 2021 19:303,85463,479,78841,386,0001,009,0002,265,088
4May 22, 2021 22:043,85868,105,89841,430,0001,010,0002,527,232
5May 29, 2021 14:523,87576,454,16041,615,0001,015,0002,396,160
6May 24, 2021 19:303,88072,526,74542,683,00002,396,160
7May 24, 2021 19:303,88967,978,04040,794,0001,989,0002,506,752
8May 22, 2021 22:043,89573,375,80641,846,000996,0002,265,088
9May 22, 2021 22:043,89772,322,03640,873,0001,993,0002,527,232
10May 24, 2021 19:303,89868,572,69440,889,0001,994,0002,527,232
11Jun 2, 2021 18:513,89873,699,00141,880,000997,0002,400,256
12May 29, 2021 14:523,89872,740,31641,886,000997,0002,392,064
13May 24, 2021 19:303,89969,110,25441,892,000997,0002,527,232
14Jun 2, 2021 18:513,90368,501,41741,939,000998,0002,527,232
15May 22, 2021 22:043,90574,820,78240,961,0001,998,0002,265,088
16May 22, 2021 22:043,90668,311,79840,969,0001,998,0002,265,088
17May 24, 2021 19:303,90671,760,98441,962,000999,0002,260,992
18Jun 2, 2021 18:513,90869,348,93141,993,000999,0002,527,232
19Jun 2, 2021 18:513,90872,873,58540,993,0001,999,0002,265,088
20May 29, 2021 14:523,91070,537,02742,011,0001,000,0002,387,968
21Jun 2, 2021 18:513,91170,922,20241,017,0002,000,0002,400,256
22May 29, 2021 14:523,91173,500,86641,017,0002,000,0002,265,088
23May 24, 2021 19:303,91372,515,50442,042,0001,001,0002,265,088
24May 24, 2021 19:303,91367,533,10341,046,0002,002,0002,265,088
25May 22, 2021 22:043,91469,512,24141,056,0002,002,0002,265,088
26May 24, 2021 19:303,91667,565,24142,070,0001,001,0002,506,752
27May 22, 2021 22:043,91673,619,71141,077,0002,003,0002,527,232
28Jun 2, 2021 18:513,91976,549,65442,110,0001,002,0002,265,088
29Jun 2, 2021 18:513,92265,639,48342,139,0001,003,0002,265,088
30May 29, 2021 14:523,92676,080,14542,187,0001,004,0002,527,232
31May 22, 2021 22:043,92770,468,74942,193,0001,004,0002,265,088
32Jun 2, 2021 18:513,92979,275,98041,211,0002,010,0002,265,088
33May 29, 2021 14:523,93071,809,45642,222,0001,005,0002,387,968
34May 29, 2021 14:523,93176,309,21641,228,0002,011,0002,392,064
35May 24, 2021 19:303,93291,670,73243,252,83902,236,416
36May 22, 2021 22:043,935115,539,05343,280,75502,228,224
37May 29, 2021 14:523,94069,487,32842,331,0001,007,0002,387,968
38May 22, 2021 22:043,941105,180,40543,346,37102,232,320
39Jun 2, 2021 18:513,94395,800,33443,373,98902,232,320
40May 29, 2021 14:523,94364,030,47042,365,0001,008,0002,392,064
41Jun 2, 2021 18:513,944108,237,71843,382,15602,232,320
42May 29, 2021 14:523,945111,137,95643,397,32202,228,224
43Jun 2, 2021 18:513,945107,460,71343,394,82902,236,416
44May 29, 2021 14:523,946101,037,80743,406,71802,236,416
45May 24, 2021 19:303,955117,174,57443,504,40402,236,416
46May 29, 2021 14:523,956114,559,88343,520,93102,240,512
47May 24, 2021 19:303,96191,975,43143,572,68002,236,416
48May 22, 2021 22:043,963114,798,52043,592,88902,240,512