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 18, 2024 22:04Joad NacerJoad NacerScore: 8,189Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Apr 18, 2024 22:015,643126,203,51162,073,91502,260,992
2Apr 18, 2024 22:045,646125,766,10462,107,44702,260,992
3Apr 18, 2024 22:045,647123,541,15062,122,31702,265,088
4Apr 18, 2024 22:015,654130,513,41862,189,91902,265,088
5Apr 18, 2024 22:015,655127,966,10262,206,73902,273,280
6Apr 18, 2024 22:045,660117,497,06762,255,84702,265,088
7Apr 18, 2024 22:018,174111,868,64988,920,000999,0002,531,328
8Apr 18, 2024 22:048,175112,173,03187,928,0001,998,0002,289,664
9Apr 18, 2024 22:018,180112,583,36188,981,000999,0002,289,664
10Apr 18, 2024 22:018,184115,253,42988,026,0002,000,0002,273,280
11Apr 18, 2024 22:018,189115,702,48289,081,0001,000,0002,527,232
12Apr 18, 2024 22:018,189113,011,48988,073,0002,001,0002,289,664
13Apr 18, 2024 22:048,189112,538,42389,084,0001,000,0002,289,664
14Apr 18, 2024 22:048,189119,833,75088,076,0002,001,0002,289,664
15Apr 18, 2024 22:048,191113,314,41388,094,0002,002,0002,289,664
16Apr 18, 2024 22:018,193117,311,92289,120,0001,001,0002,289,664
17Apr 18, 2024 22:018,193112,501,29589,119,0001,001,0002,392,064
18Apr 18, 2024 22:048,194118,591,22489,136,0001,001,0002,289,664
19Apr 18, 2024 22:048,194115,965,21988,131,0002,002,0002,289,664
20Apr 18, 2024 22:048,196114,566,61588,148,0002,003,0002,531,328
21Apr 18, 2024 22:018,199114,095,30388,189,0002,004,0002,367,488
22Apr 18, 2024 22:018,202119,784,13288,220,0002,005,0002,273,280
23Apr 18, 2024 22:048,203116,351,89789,226,0001,002,0002,289,664
24Apr 18, 2024 22:048,208116,480,53188,278,0002,006,0002,289,664