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 16:31Yuriy LyfenkoYuriy LyfenkoScore: 8,257Success
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 16:508,232112,757,98290,557,00002,531,328
2May 8, 2021 16:348,235118,121,44789,583,0001,006,0002,519,040
3May 8, 2021 16:508,236121,852,37090,598,00002,330,624
4May 8, 2021 16:348,236118,973,06389,587,0001,006,0002,531,328
5May 8, 2021 16:318,238117,557,58590,614,00002,531,328
6May 8, 2021 16:348,239117,328,71590,627,00002,527,232
7May 8, 2021 16:318,239117,632,71090,633,00002,531,328
8May 8, 2021 16:358,240114,580,87889,630,0001,007,0002,531,328
9May 8, 2021 16:358,240115,934,60589,638,0001,007,0002,330,624
10May 8, 2021 16:358,241116,414,55090,650,00002,330,624
11May 8, 2021 16:358,242114,842,98889,660,0001,007,0002,396,160
12May 8, 2021 16:508,242121,220,66088,651,0002,014,0002,531,328
13May 8, 2021 16:348,242118,913,55988,646,0002,014,0002,334,720
14May 8, 2021 16:358,245116,487,75590,691,00002,330,624
15May 8, 2021 16:318,245121,880,70989,690,0001,007,0002,330,624
16May 8, 2021 16:508,245123,526,87990,690,00002,330,624
17May 8, 2021 16:358,254118,506,37888,804,0001,995,0002,527,232
18May 8, 2021 16:508,255121,137,36687,815,0002,993,0002,334,720
19May 8, 2021 16:508,257121,230,16588,831,0001,996,0002,523,136
20May 8, 2021 16:348,257118,910,35587,830,0002,994,0002,330,624
21May 8, 2021 16:318,257118,637,57388,812,0002,018,0002,519,040
22May 8, 2021 16:358,258114,662,18987,847,0002,994,0002,527,232
23May 8, 2021 16:318,258117,679,57286,844,0003,992,0002,531,328
24May 8, 2021 16:318,258117,711,60389,840,000998,0002,392,064
25May 8, 2021 16:358,259117,723,22087,857,0002,995,0002,334,720
26May 8, 2021 16:348,259115,463,46189,851,000998,0002,535,424
27May 8, 2021 16:508,259115,922,85987,857,0002,995,0002,330,624
28May 8, 2021 16:508,259116,782,96287,851,0002,994,0002,531,328
29May 8, 2021 16:348,260126,492,16189,866,000998,0002,334,720
30May 8, 2021 16:358,262122,877,67687,884,0002,996,0002,326,528
31May 8, 2021 16:318,262115,966,51887,884,0002,996,0002,330,624
32May 8, 2021 16:348,266123,108,02188,931,0001,998,0002,367,488
33May 8, 2021 16:508,268124,365,03988,946,0001,998,0002,330,624
34May 8, 2021 16:318,268117,140,76288,951,0001,998,0002,330,624
35May 8, 2021 16:348,270116,964,25388,971,0001,999,0002,334,720
36May 8, 2021 16:318,273118,598,14586,999,0003,999,0002,330,624