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 19:17Yuriy LyfenkoYuriy LyfenkoScore: 6,012Success
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 19:175,98692,284,15464,844,000997,0002,273,280
2May 2, 2021 18:455,99087,057,13163,890,0001,996,0002,269,184
3May 2, 2021 18:455,99888,720,54263,978,0001,999,0002,281,472
4May 2, 2021 18:455,99891,437,97463,974,0001,999,0002,281,472
5May 2, 2021 19:176,00693,255,75064,061,0002,001,0002,281,472
6May 2, 2021 18:456,00789,235,12362,072,0004,004,0002,273,280
7May 2, 2021 19:176,00991,414,72164,099,0002,003,0002,273,280
8May 2, 2021 18:456,00989,092,95264,096,0002,003,0002,269,184
9May 2, 2021 19:176,01288,563,58465,130,0001,002,0002,277,376
10May 2, 2021 18:456,01288,352,29463,125,0003,005,0002,277,376
11May 2, 2021 18:456,01393,495,90564,141,0002,004,0002,281,472
12May 2, 2021 19:176,01789,358,75462,180,0004,011,0002,269,184
13May 2, 2021 18:456,02489,648,08464,258,0002,008,0002,269,184
14May 2, 2021 19:176,03590,576,50265,384,0001,005,0002,273,280
15May 2, 2021 19:176,03587,697,27566,390,00002,273,280
16May 2, 2021 18:456,04388,161,33864,460,0002,014,0002,277,376
17May 2, 2021 19:176,04789,600,03265,510,0001,007,0002,273,280
18May 2, 2021 19:176,04893,656,32065,525,0001,008,0002,281,472