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 2, 2021 16:16Yuriy LyfenkoYuriy LyfenkoScore: 8,394Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 2, 2021 16:138,370117,575,77689,064,0003,002,0002,269,184
2May 2, 2021 16:218,374119,875,97190,111,0002,002,0002,281,472
3May 2, 2021 16:218,377116,637,10791,143,0001,001,0002,281,472
4May 2, 2021 16:168,378118,240,76889,154,0003,005,0002,269,184
5May 2, 2021 16:138,378116,578,52790,159,0002,003,0002,289,664
6May 2, 2021 16:138,380115,942,05591,174,0001,001,0002,281,472
7May 2, 2021 16:138,381111,863,57488,182,0004,008,0002,265,088
8May 2, 2021 16:138,384121,129,52390,223,0002,004,0002,277,376
9May 2, 2021 16:138,387112,148,38192,262,00002,379,776
10May 2, 2021 16:218,388117,623,63690,259,0002,005,0002,281,472
11May 2, 2021 16:138,392119,659,73592,313,00002,269,184
12May 2, 2021 16:168,392117,237,05791,310,0001,003,0002,277,376
13May 2, 2021 16:218,393114,226,43990,317,0002,007,0002,289,664
14May 2, 2021 16:218,394114,872,13291,336,0001,003,0002,273,280
15May 2, 2021 16:168,394117,943,85791,329,0001,003,0002,269,184
16May 2, 2021 16:218,395114,057,67691,339,0001,003,0002,392,064
17May 2, 2021 16:168,396116,237,93790,352,0002,007,0002,281,472
18May 2, 2021 16:168,396117,701,00791,348,0001,003,0002,269,184
19May 2, 2021 16:168,397120,589,88890,364,0002,008,0002,281,472
20May 2, 2021 16:138,397112,507,76592,366,00002,383,872
21May 2, 2021 16:168,399113,872,34490,382,0002,008,0002,273,280
22May 2, 2021 16:138,400113,283,25491,398,0001,004,0002,281,472
23May 2, 2021 16:218,401116,740,95991,406,0001,004,0002,281,472
24May 2, 2021 16:168,406114,411,07691,461,0001,005,0002,269,184
25May 2, 2021 16:168,407113,776,78291,475,0001,005,0002,269,184
26May 2, 2021 16:218,416120,189,15391,573,0001,006,0002,281,472
27May 2, 2021 16:218,417118,626,57591,584,0001,006,0002,273,280