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:13Joad NacerJoad NacerScore: 7,387Success
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:134,806120,169,49752,868,85702,265,088
2Apr 20, 2024 14:134,809108,286,88752,895,90002,265,088
3Apr 20, 2024 14:134,825116,118,89053,073,45502,269,184
4Apr 20, 2024 14:137,369109,661,57979,058,0002,001,0002,289,664
5Apr 20, 2024 14:137,379109,203,37280,165,0001,002,0002,289,664
6Apr 20, 2024 14:137,382109,373,64680,203,0001,002,0002,269,184
7Apr 20, 2024 14:137,387106,348,76580,255,0001,003,0002,289,664
8Apr 20, 2024 14:137,392103,821,21279,310,0002,007,0002,273,280
9Apr 20, 2024 14:137,394103,406,04979,321,0002,008,0002,289,664
10Apr 20, 2024 14:137,397102,455,02880,366,0001,004,0002,289,664
11Apr 20, 2024 14:137,402104,384,61879,414,0002,010,0002,289,664
12Apr 20, 2024 14:137,419108,716,09880,606,0001,007,0002,269,184