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 7, 2025 20:10Aleksey ShvetsAleksey ShvetsScore: 120,537Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 7, 2025 18:36120,2321,353,426,4261,319,553,0002,998,0002,301,952
2May 7, 2025 18:36120,2621,350,345,2611,316,889,0005,994,0002,461,696
3May 7, 2025 18:36120,3021,355,630,6521,316,326,0006,996,0002,437,120
4May 7, 2025 18:36120,3081,346,641,2721,317,387,0005,997,0002,437,120
5May 7, 2025 20:10120,3281,355,611,0851,319,605,0003,998,0002,424,832
6May 7, 2025 20:10120,3461,350,532,1621,320,805,0002,997,0002,437,120
7May 7, 2025 18:37120,3561,351,484,4241,314,920,0008,992,0002,314,240
8May 7, 2025 18:36120,4391,356,911,2231,317,839,0006,993,0002,424,832
9May 7, 2025 18:36120,4421,358,847,5241,320,864,0003,996,0002,523,136
10May 7, 2025 18:37120,4541,352,845,1041,318,001,0006,994,0002,314,240
11May 7, 2025 18:37120,4671,356,734,1601,319,137,0005,996,0002,297,856
12May 7, 2025 20:10120,4761,352,354,0681,318,237,0006,995,0002,527,232
13May 7, 2025 18:37120,5061,353,700,5291,320,568,0004,998,0002,527,232
14May 7, 2025 18:37120,5371,354,327,0491,321,906,0003,999,0002,506,752
15May 7, 2025 20:10120,6341,354,864,8041,321,981,0004,996,0002,424,832
16May 7, 2025 20:10120,7961,358,710,9541,321,762,0006,993,0002,486,272
17May 7, 2025 18:37120,8771,362,577,4951,324,651,0004,998,0002,424,832
18May 7, 2025 20:10120,9911,360,417,7621,323,912,0006,994,0002,318,336
19May 7, 2025 20:10122,0861,369,796,0501,339,951,0002,997,0002,338,816
20May 7, 2025 18:36122,9431,382,479,2051,349,373,0002,998,0002,445,312
21May 7, 2025 18:37122,9831,384,134,1311,345,824,0006,993,0002,428,928
22May 7, 2025 18:37123,0741,380,536,6651,348,823,0004,995,0002,322,432
23May 7, 2025 18:36123,1651,389,010,0981,350,814,0003,996,0002,342,912
24May 7, 2025 20:10123,2491,381,229,2391,351,742,0003,996,0002,420,736
25May 7, 2025 20:10123,4351,386,354,4571,346,789,00010,998,0002,461,696
26May 7, 2025 18:37125,3311,406,296,0081,373,639,0004,998,0002,412,544
27May 7, 2025 18:36126,3911,422,632,2741,384,306,0005,996,0002,449,408