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:44Joad NacerJoad NacerScore: 16,622Success
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:4414,195213,242,703156,146,73102,273,280
2Jun 4, 2024 16:4414,544214,013,474159,983,05502,265,088
3Jun 4, 2024 16:4414,563222,291,268160,194,31002,269,184
4Jun 4, 2024 16:4416,594205,441,640181,534,0001,002,0002,527,232
5Jun 4, 2024 16:4416,618208,607,320180,800,0001,997,0002,531,328
6Jun 4, 2024 16:4416,619210,588,363180,813,0001,997,0002,531,328
7Jun 4, 2024 16:4416,622207,914,709181,841,000999,0002,535,424
8Jun 4, 2024 16:4416,625203,406,293180,872,0001,998,0002,392,064
9Jun 4, 2024 16:4416,630207,885,763180,932,0001,999,0002,285,568
10Jun 4, 2024 16:4416,631214,771,556181,937,000999,0002,527,232
11Jun 4, 2024 16:4416,633205,975,620180,961,0001,999,0002,285,568
12Jun 4, 2024 16:4416,891211,389,277184,802,000998,0002,285,568