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 listJun 20, 2021 18:19Sergey StreminSergey StreminScore: 8,093Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jun 20, 2021 18:198,074116,236,92587,820,000997,0002,289,664
2Jun 20, 2021 18:198,077114,175,23088,842,00002,367,488
3Jun 20, 2021 18:198,078118,439,72386,866,0001,996,0002,289,664
4Jun 20, 2021 18:198,079118,864,54986,876,0001,997,0002,375,680
5Jun 20, 2021 18:198,085115,672,83686,940,0001,998,0002,375,680
6Jun 20, 2021 18:198,089115,949,34187,983,000999,0002,289,664
7Jun 20, 2021 18:198,093114,310,99688,024,0001,000,0002,363,392
8Jun 20, 2021 18:198,095120,435,19787,046,0002,001,0002,289,664
9Jun 20, 2021 18:198,101112,205,01687,109,0002,002,0002,289,664
10Jun 20, 2021 18:198,155156,398,20189,707,72602,195,456
11Jun 20, 2021 18:198,164156,482,04189,800,35502,191,360
12Jun 20, 2021 18:198,204152,482,01190,245,19202,203,648