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 listJul 29, 2024 22:29Andrey LikhachevAndrey LikhachevScore: 7,390Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jul 29, 2024 22:297,351114,810,20579,859,000998,0002,367,488
2Jul 29, 2024 22:297,370103,095,06780,071,0001,000,0002,289,664
3Jul 29, 2024 22:297,371104,601,32479,084,0002,002,0002,289,664
4Jul 29, 2024 22:297,380103,926,61280,175,0001,002,0002,367,488
5Jul 29, 2024 22:297,382139,438,19681,205,57902,215,936
6Jul 29, 2024 22:297,389105,735,25681,277,00002,371,584
7Jul 29, 2024 22:297,390108,834,20980,291,0001,003,0002,289,664
8Jul 29, 2024 22:297,393136,932,79381,326,83002,207,744
9Jul 29, 2024 22:297,396144,306,64881,352,56402,199,552
10Jul 29, 2024 22:297,400103,632,92280,392,0001,004,0002,367,488
11Jul 29, 2024 22:297,417101,656,70581,586,00002,494,464
12Jul 29, 2024 22:297,450106,537,85880,949,000999,0002,371,584