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 listMay 2, 2021 19:15Yuriy LyfenkoYuriy LyfenkoScore: 5,960Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 2, 2021 19:155,93791,120,46863,295,0002,009,0002,269,184
2May 2, 2021 19:155,93791,215,21963,294,0002,009,0002,289,664
3May 2, 2021 19:155,94391,094,62564,367,0001,005,0002,281,472
4May 2, 2021 19:155,94888,455,11664,423,0001,006,0002,281,472
5May 2, 2021 19:155,94886,594,15864,418,0001,006,0002,269,184
6May 2, 2021 19:155,95490,991,79964,489,0001,007,0002,273,280
7May 2, 2021 19:155,95592,075,68163,485,0002,015,0002,281,472
8May 2, 2021 19:155,95589,852,36664,495,0001,007,0002,269,184
9May 2, 2021 19:155,95692,065,71865,514,00002,527,232
10May 2, 2021 19:155,96096,645,74563,548,0002,017,0002,523,136
11May 2, 2021 19:155,96193,672,02964,563,0001,008,0002,273,280
12May 2, 2021 19:155,96195,131,26264,561,0001,008,0002,527,232
13May 2, 2021 19:155,96497,045,76564,594,0001,009,0002,277,376
14May 2, 2021 19:155,96697,180,87965,625,00002,281,472
15May 2, 2021 19:155,97192,675,50564,675,0001,010,0002,281,472
16May 2, 2021 19:155,98493,531,12563,834,0001,994,0002,265,088
17May 2, 2021 19:155,98493,857,47964,822,000997,0002,269,184
18May 2, 2021 19:155,98695,126,28763,846,0001,995,0002,273,280