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 19, 2024 00:40Joad NacerJoad NacerScore: 7,851Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Apr 19, 2024 00:404,758113,662,27452,341,78802,269,184
2Apr 19, 2024 00:404,768113,854,47752,447,09902,265,088
3Apr 19, 2024 00:404,778114,550,33852,554,27902,269,184
4Apr 19, 2024 00:407,836113,044,99284,196,0002,004,0002,289,664
5Apr 19, 2024 00:407,844112,562,16784,274,0002,006,0002,523,136
6Apr 19, 2024 00:407,850107,458,02384,338,0002,008,0002,289,664
7Apr 19, 2024 00:407,851111,475,25385,359,0001,004,0002,289,664
8Apr 19, 2024 00:407,872113,649,32285,588,0001,006,0002,519,040
9Apr 19, 2024 00:407,947110,644,97587,422,00002,269,184
10Apr 19, 2024 00:407,960115,823,70086,555,0001,006,0002,265,088
11Apr 19, 2024 00:407,961113,854,48986,567,0001,006,0002,281,472
12Apr 19, 2024 00:407,969113,718,17986,656,0001,007,0002,527,232