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 20, 2021 05:59Yuriy LyfenkoYuriy LyfenkoScore: 5,581Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 20, 2021 05:595,55190,896,82258,054,0003,002,0002,260,992
2May 20, 2021 06:005,55285,924,76059,067,0002,002,0002,260,992
3May 20, 2021 06:005,56587,062,59860,210,0001,003,0002,387,968
4May 20, 2021 06:005,56782,196,37159,232,0002,007,0002,506,752
5May 20, 2021 06:005,56887,692,08760,245,0001,004,0002,392,064
6May 20, 2021 06:005,57284,654,44361,297,00002,392,064
7May 20, 2021 06:005,57280,657,14260,288,0001,004,0002,510,848
8May 20, 2021 06:005,57387,044,12759,295,0002,010,0002,387,968
9May 20, 2021 05:595,57588,279,02460,318,0001,005,0002,523,136
10May 20, 2021 05:595,57684,601,73361,331,00002,260,992
11May 20, 2021 06:005,57784,636,96060,340,0001,005,0002,527,232
12May 20, 2021 05:595,58085,071,46059,364,0002,012,0002,469,888
13May 20, 2021 05:595,58187,757,25461,388,00002,519,040
14May 20, 2021 05:595,58181,820,40360,383,0001,006,0002,260,992
15May 20, 2021 05:595,58190,274,10061,391,00002,392,064
16May 20, 2021 05:595,58784,139,55361,454,00002,523,136
17May 20, 2021 06:005,58989,635,23761,484,00002,523,136
18May 20, 2021 05:595,59591,686,01059,557,0001,985,0002,383,872
19May 20, 2021 05:595,869129,471,50364,558,13002,248,704
20May 20, 2021 06:005,879127,553,06464,671,04002,248,704
21May 20, 2021 06:005,882115,933,20964,701,71402,252,800
22May 20, 2021 05:595,887126,062,37064,756,38502,232,320
23May 20, 2021 05:595,892119,519,21364,813,23902,244,608
24May 20, 2021 06:005,897126,762,06764,871,33102,236,416