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 listApr 19, 2024 00:33Joad NacerJoad NacerScore: 7,696Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Apr 19, 2024 00:334,818110,580,67053,001,83302,273,280
2Apr 19, 2024 00:334,827119,905,19253,092,82302,277,376
3Apr 19, 2024 00:334,833133,889,08253,164,87602,260,992
4Apr 19, 2024 00:324,834120,656,21053,177,11502,269,184
5Apr 19, 2024 00:324,834130,416,24653,169,50602,260,992
6Apr 19, 2024 00:324,837111,260,18653,207,23202,273,280
7Apr 19, 2024 00:327,665115,497,08083,309,0001,003,0002,265,088
8Apr 19, 2024 00:337,677106,644,06583,440,0001,005,0002,289,664
9Apr 19, 2024 00:327,677111,153,98683,447,0001,005,0002,289,664
10Apr 19, 2024 00:337,681109,267,33683,487,0001,005,0002,289,664
11Apr 19, 2024 00:337,685109,057,31383,528,0001,006,0002,289,664
12Apr 19, 2024 00:327,687109,020,38084,562,00002,531,328
13Apr 19, 2024 00:337,696112,396,26484,655,00002,289,664
14Apr 19, 2024 00:327,696108,840,91083,653,0001,007,0002,375,680
15Apr 19, 2024 00:337,711114,131,46982,831,0001,995,0002,289,664
16Apr 19, 2024 00:327,711115,486,19783,823,000997,0002,289,664
17Apr 19, 2024 00:327,712112,041,35282,838,0001,996,0002,265,088
18Apr 19, 2024 00:327,713107,781,77183,842,000998,0002,265,088
19Apr 19, 2024 00:337,714111,146,19082,859,0001,996,0002,523,136
20Apr 19, 2024 00:327,720108,414,69282,925,0001,998,0002,289,664
21Apr 19, 2024 00:337,721112,686,53882,930,0001,998,0002,289,664
22Apr 19, 2024 00:327,723106,840,86783,949,000999,0002,269,184
23Apr 19, 2024 00:337,724108,897,90984,968,00002,273,280
24Apr 19, 2024 00:337,726109,782,41983,985,000999,0002,273,280