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:48Yuriy LyfenkoYuriy LyfenkoScore: 8,299Success
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:478,287114,689,41189,156,0002,003,0002,531,328
2May 8, 2021 16:488,288116,452,51989,164,0002,003,0002,330,624
3May 8, 2021 16:478,289111,184,16289,173,0002,003,0002,330,624
4May 8, 2021 16:478,292112,043,02490,211,0001,002,0002,330,624
5May 8, 2021 16:478,292112,526,21989,206,0002,004,0002,531,328
6May 8, 2021 16:488,297114,904,27988,260,0003,008,0002,330,624
7May 8, 2021 16:488,298117,074,26588,272,0003,009,0002,330,624
8May 8, 2021 16:478,298114,984,74890,273,0001,003,0002,334,720
9May 8, 2021 16:478,298116,936,76188,269,0003,009,0002,330,624
10May 8, 2021 16:488,299110,062,11789,280,0002,006,0002,330,624
11May 8, 2021 16:478,304114,192,72989,333,0002,007,0002,334,720
12May 8, 2021 16:488,306114,583,43088,356,0003,012,0002,330,624
13May 8, 2021 16:488,307120,433,92791,376,00002,531,328
14May 8, 2021 16:488,307114,021,26491,382,00002,527,232
15May 8, 2021 16:488,307113,376,60791,372,00002,330,624
16May 8, 2021 16:488,314112,188,07890,446,0001,004,0002,527,232
17May 8, 2021 16:478,314115,024,17090,450,0001,005,0002,330,624
18May 8, 2021 16:478,322112,627,63789,532,0002,011,0002,334,720