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 4, 2024 16:33Joad NacerJoad NacerScore: 16,650Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jun 4, 2024 16:3314,222213,850,588156,444,97502,277,376
2Jun 4, 2024 16:3314,237215,377,656156,604,59902,269,184
3Jun 4, 2024 16:3314,265223,084,869156,916,33002,265,088
4Jun 4, 2024 16:3316,620210,745,105180,818,0001,997,0002,285,568
5Jun 4, 2024 16:3316,629204,817,640180,917,0001,999,0002,269,184
6Jun 4, 2024 16:3316,643206,867,861181,078,0002,000,0002,285,568
7Jun 4, 2024 16:3316,650211,860,096181,150,0002,001,0002,531,328
8Jun 4, 2024 16:3316,653208,592,552181,181,0002,002,0002,285,568
9Jun 4, 2024 16:3316,662204,857,138182,282,0001,001,0002,285,568
10Jun 4, 2024 16:3316,672206,920,137182,389,0001,002,0002,285,568
11Jun 4, 2024 16:3316,689206,756,958181,581,0001,995,0002,285,568
12Jun 4, 2024 16:3316,708216,147,803181,794,0001,997,0002,285,568