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 20:51Sergey StreminSergey StreminScore: 14,815Success
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 20:5114,784187,978,138134,518,00028,108,0002,289,664
2May 8, 2021 20:5114,801195,484,413130,847,00031,962,0002,371,584
3May 8, 2021 20:5114,808193,170,314131,910,00030,978,0002,289,664
4May 8, 2021 20:5114,810188,180,718131,927,00030,982,0002,375,680
5May 8, 2021 20:5114,815192,529,377131,970,00030,993,0002,371,584
6May 8, 2021 20:5114,818189,236,207133,001,00030,000,0002,367,488
7May 8, 2021 20:5114,841187,408,491134,203,00029,043,0002,375,680
8May 8, 2021 20:5114,843194,140,376129,213,00034,056,0002,289,664
9May 8, 2021 20:5114,843188,401,411133,225,00030,050,0002,289,664