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 listJul 27, 2024 15:55Joad NacerJoad NacerScore: 6,833Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jul 27, 2024 15:574,399117,635,80748,392,97702,289,664
2Jul 27, 2024 15:574,400103,822,52848,402,47102,285,568
3Jul 27, 2024 15:554,401111,696,22448,411,62202,273,280
4Jul 27, 2024 15:554,409113,528,24748,493,97702,281,472
5Jul 27, 2024 15:574,409108,451,04848,495,91502,285,568
6Jul 27, 2024 15:554,416103,397,35548,574,80102,281,472
7Jul 27, 2024 15:576,821102,397,29474,032,0001,000,0002,433,024
8Jul 27, 2024 15:556,82399,022,20674,052,0001,000,0002,535,424
9Jul 27, 2024 15:556,82596,558,09774,072,0001,000,0002,424,832
10Jul 27, 2024 15:576,83196,717,55974,135,0001,001,0002,535,424
11Jul 27, 2024 15:556,83198,355,56474,144,0001,001,0002,273,280
12Jul 27, 2024 15:556,83293,990,93573,151,0002,004,0002,514,944
13Jul 27, 2024 15:576,83396,559,64074,158,0001,002,0002,428,928
14Jul 27, 2024 15:576,83397,652,61974,158,0001,002,0002,535,424
15Jul 27, 2024 15:576,83497,393,29574,167,0001,002,0002,428,928
16Jul 27, 2024 15:556,834102,672,56674,174,0001,002,0002,273,280
17Jul 27, 2024 15:576,83493,006,26174,167,0001,002,0002,428,928
18Jul 27, 2024 15:556,83798,607,25074,201,0001,002,0002,433,024
19Jul 27, 2024 15:556,83899,193,27873,214,0002,005,0002,428,928
20Jul 27, 2024 15:556,838102,912,63573,217,0002,005,0002,535,424
21Jul 27, 2024 15:576,838100,223,11574,217,0001,002,0002,535,424
22Jul 27, 2024 15:576,838102,777,88273,214,0002,005,0002,433,024
23Jul 27, 2024 15:556,84099,537,54574,234,0001,003,0002,433,024
24Jul 27, 2024 15:576,841105,427,93474,247,0001,003,0002,433,024