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,844Success
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:554,533108,121,17749,860,27202,277,376
2Jul 27, 2024 15:554,533107,819,98949,864,40602,285,568
3Jul 27, 2024 15:554,540119,256,18049,943,83202,285,568
4Jul 27, 2024 15:556,84096,756,08074,237,0001,003,0002,514,944
5Jul 27, 2024 15:556,84296,423,25574,259,0001,003,0002,424,832
6Jul 27, 2024 15:556,84296,800,74374,259,0001,003,0002,535,424
7Jul 27, 2024 15:556,84497,194,04375,286,00002,441,216
8Jul 27, 2024 15:556,84598,843,17575,290,00002,433,024
9Jul 27, 2024 15:556,84898,334,54275,331,00002,535,424
10Jul 27, 2024 15:556,84994,802,76875,338,00002,433,024
11Jul 27, 2024 15:556,850102,430,20375,345,00002,273,280
12Jul 27, 2024 15:556,85094,914,89175,350,00002,273,280