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 listNov 6, 2024 19:25bruHFTbruHFTScore: 608,132Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Nov 6, 2024 19:25592,3466,546,089,1316,485,822,00029,985,0002,289,664
2Nov 6, 2024 19:25593,5006,557,000,0116,473,534,00054,970,0002,273,280
3Nov 6, 2024 19:25599,9816,630,448,9076,549,812,00049,975,0002,281,472
4Nov 6, 2024 19:25607,7546,719,422,2716,653,315,00031,977,0002,289,664
5Nov 6, 2024 19:25608,1326,724,873,0666,658,474,00030,983,0002,265,088
6Nov 6, 2024 19:25611,5406,760,013,5636,681,961,00044,979,0002,281,472
7Nov 6, 2024 19:25612,0016,768,124,0036,503,217,000228,796,0002,523,136
8Nov 6, 2024 19:25621,4526,862,502,6946,796,992,00038,977,0002,281,472
9Nov 6, 2024 19:25627,1936,925,676,6726,862,142,00036,979,0002,281,472