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 3, 2021 00:53Yuriy LyfenkoYuriy LyfenkoScore: 5,733Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 3, 2021 00:535,71293,128,38060,841,0001,994,0002,281,472
2May 3, 2021 00:525,71387,428,45360,851,0001,995,0002,289,664
3May 3, 2021 00:525,71490,599,11558,861,0003,990,0002,269,184
4May 3, 2021 00:535,71593,191,73561,870,000997,0002,281,472
5May 3, 2021 00:525,71587,076,45759,875,0002,993,0002,273,280
6May 3, 2021 00:535,71884,617,64660,906,0001,996,0002,277,376
7May 3, 2021 00:525,72286,377,22060,942,0001,998,0002,281,472
8May 3, 2021 00:525,72390,778,00360,957,0001,998,0002,281,472
9May 3, 2021 00:525,72590,344,54559,980,0002,999,0002,269,184
10May 3, 2021 00:535,72789,335,98861,000,0002,000,0002,281,472
11May 3, 2021 00:525,72984,806,94161,014,0002,000,0002,375,680
12May 3, 2021 00:525,73184,647,31261,038,0002,001,0002,273,280
13May 3, 2021 00:535,73289,239,05960,047,0003,002,0002,281,472
14May 3, 2021 00:535,73382,947,30861,063,0002,002,0002,277,376
15May 3, 2021 00:525,73485,051,60561,072,0002,002,0002,277,376
16May 3, 2021 00:535,73486,043,51862,069,0001,001,0002,273,280
17May 3, 2021 00:535,73786,755,04261,102,0002,003,0002,527,232
18May 3, 2021 00:535,73885,735,87161,114,0002,003,0002,273,280
19May 3, 2021 00:535,92888,436,67564,204,0001,003,0002,269,184
20May 3, 2021 00:535,95186,346,71064,453,0001,007,0002,289,664
21May 3, 2021 00:535,95891,517,25162,512,0003,024,0002,269,184
22May 3, 2021 00:535,98496,621,94064,832,000997,0002,527,232
23May 3, 2021 00:535,98688,853,92363,850,0001,995,0002,277,376
24May 3, 2021 00:535,99094,278,51563,891,0001,996,0002,281,472
25May 3, 2021 00:535,99089,751,27163,890,0001,996,0002,281,472
26May 3, 2021 00:535,99294,691,48563,917,0001,997,0002,281,472
27May 3, 2021 00:536,00691,401,50064,068,0002,002,0002,269,184