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 listApr 20, 2024 14:28Joad NacerJoad NacerScore: 7,625Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Apr 20, 2024 14:284,888120,906,82753,768,55002,265,088
2Apr 20, 2024 14:284,896129,853,45953,854,72402,269,184
3Apr 20, 2024 14:284,909113,280,38653,996,09302,260,992
4Apr 20, 2024 14:287,609109,604,43882,690,0001,008,0002,289,664
5Apr 20, 2024 14:287,621109,967,28382,829,000997,0002,289,664
6Apr 20, 2024 14:287,624105,150,89181,867,0001,996,0002,269,184
7Apr 20, 2024 14:287,625106,660,21881,881,0001,997,0002,285,568
8Apr 20, 2024 14:287,627106,977,10482,898,000998,0002,527,232
9Apr 20, 2024 14:287,632106,155,88681,951,0001,998,0002,289,664
10Apr 20, 2024 14:287,633106,337,66481,968,0001,999,0002,289,664
11Apr 20, 2024 14:287,636108,399,73881,996,0001,999,0002,273,280
12Apr 20, 2024 14:287,644108,144,77182,086,0002,002,0002,289,664