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:57Joad NacerJoad NacerScore: 6,874Success
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,506115,184,79549,568,27602,289,664
2Jul 27, 2024 15:574,518108,588,30849,703,45202,281,472
3Jul 27, 2024 15:574,523106,702,90349,752,60802,281,472
4Jul 27, 2024 15:576,86496,411,31774,494,0001,006,0002,428,928
5Jul 27, 2024 15:576,864100,204,97774,495,0001,006,0002,273,280
6Jul 27, 2024 15:576,86796,698,57474,531,0001,007,0002,428,928
7Jul 27, 2024 15:576,874103,854,75474,606,0001,008,0002,441,216
8Jul 27, 2024 15:576,87799,644,69775,649,00002,273,280
9Jul 27, 2024 15:576,879104,233,95175,668,00002,273,280
10Jul 27, 2024 15:576,883104,515,83674,701,0001,009,0002,428,928
11Jul 27, 2024 15:576,89597,015,70074,848,000997,0002,428,928
12Jul 27, 2024 15:576,895100,725,99374,848,000997,0002,519,040