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 21:03Sergey StreminSergey StreminScore: 12,720Success
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 21:0312,682161,075,960106,385,00033,120,0002,367,488
2May 8, 2021 21:0312,692172,596,874105,463,00034,150,0002,289,664
3May 8, 2021 21:0312,712163,379,700108,867,00030,962,0002,379,776
4May 8, 2021 21:0312,714165,050,445109,882,00029,967,0002,375,680
5May 8, 2021 21:0312,720171,640,541108,942,00030,983,0002,289,664
6May 8, 2021 21:0312,732161,278,318111,044,00029,011,0002,281,472
7May 8, 2021 21:0312,734159,785,441109,060,00031,017,0002,367,488
8May 8, 2021 21:0312,736173,243,624110,080,00030,021,0002,375,680
9May 8, 2021 21:0313,077173,363,147113,882,00029,969,0002,363,392