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 19, 2021 20:52Yuriy LyfenkoYuriy LyfenkoScore: 5,612Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 19, 2021 20:525,5841,590,341,00660,433,000990,0002,527,232
2May 19, 2021 20:525,5941,220,620,54759,547,0001,984,0002,265,088
3May 19, 2021 19:105,5971,616,587,99360,576,000993,0002,523,136
4May 19, 2021 20:525,597811,005,55160,555,0001,009,0002,392,064
5May 19, 2021 19:105,6012,914,888,74959,625,0001,987,0002,269,184
6May 19, 2021 19:105,6032,699,235,47860,628,0001,010,0002,527,232
7May 19, 2021 19:105,6031,808,901,12859,641,0001,988,0002,265,088
8May 19, 2021 19:105,6064,754,914,49859,673,0001,989,0002,265,088
9May 19, 2021 20:525,608797,416,17661,686,00002,269,184
10May 19, 2021 20:525,6082,492,864,57559,700,0001,990,0002,260,992
11May 19, 2021 19:105,6122,179,343,49459,741,0001,991,0002,265,088
12May 19, 2021 20:525,612640,412,92058,790,0002,939,0002,269,184
13May 19, 2021 20:525,6123,221,857,64959,739,0001,991,0002,523,136
14May 19, 2021 19:105,6152,298,371,86360,772,000996,0002,527,232
15May 19, 2021 19:105,6174,263,194,51959,791,0001,993,0002,265,088
16May 19, 2021 20:525,6222,684,497,34559,851,0001,995,0002,265,088
17May 19, 2021 19:105,626226,899,77060,892,000998,0002,265,088
18May 19, 2021 20:525,6312,968,321,85760,954,000983,0002,265,088
19May 19, 2021 20:525,8743,213,490,03564,611,04602,248,704
20May 19, 2021 20:525,8881,896,742,08264,769,15302,256,896
21May 19, 2021 20:525,8922,398,337,63064,807,97102,256,896
22May 19, 2021 19:105,8984,083,137,56564,877,95302,244,608
23May 19, 2021 19:105,9052,120,721,30964,949,96002,240,512
24May 19, 2021 19:105,9122,033,030,53365,027,21602,252,800