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 listSep 3, 2024 19:06Andrey LikhachevAndrey LikhachevError
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Sep 3, 2024 19:0100000Error: Exit with code 101: thread 'main' panicked at main.rs:520:23: index out of bounds: the len is 11 but the index is 11 note: run with `RUST_BACKTRACE=1` environment variable to display a backtracestderr
2Aug 23, 2024 15:316,55392,432,40670,079,0002,002,0002,289,664
3Sep 3, 2024 19:066,55394,969,69671,084,0001,001,0002,293,760
4Aug 23, 2024 15:316,55499,304,21671,088,0001,001,0002,367,488
5Sep 3, 2024 19:066,55694,543,69270,112,0002,003,0002,473,984
6Sep 3, 2024 19:066,55795,782,02670,129,0002,003,0002,285,568
7Sep 3, 2024 19:066,55995,129,11070,141,0002,004,0002,285,568
8Aug 23, 2024 15:316,56295,817,35770,180,0002,005,0002,363,392
9Aug 23, 2024 15:316,56293,842,21170,178,0002,005,0002,469,888
10Sep 3, 2024 19:066,56293,985,17570,177,0002,005,0002,355,200
11Aug 23, 2024 15:316,56395,768,68571,193,0001,002,0002,289,664
12Sep 3, 2024 19:066,56392,961,22971,189,0001,002,0002,289,664
13Sep 3, 2024 19:066,56494,184,99670,198,0002,005,0002,375,680
14Sep 3, 2024 19:066,56994,486,92470,257,0002,007,0002,289,664
15Sep 3, 2024 19:066,57594,622,15271,323,0001,004,0002,289,664
16Sep 3, 2024 19:066,57593,497,21072,329,00002,367,488
17Sep 3, 2024 19:066,57595,656,97071,322,0001,004,0002,371,584
18Sep 3, 2024 19:066,57799,722,05971,343,0001,004,0002,289,664
19Sep 3, 2024 19:066,579103,227,12772,367,00002,285,568
20Sep 3, 2024 19:066,58094,234,99871,371,0001,005,0002,285,568
21Aug 23, 2024 15:316,582102,347,94472,406,00002,289,664
22Aug 23, 2024 15:316,58394,382,69071,411,0001,005,0002,367,488
23Sep 3, 2024 19:066,58797,412,81671,447,0001,006,0002,281,472
24Aug 23, 2024 15:316,59295,104,25871,507,0001,007,0002,449,408
25Aug 23, 2024 15:316,597101,732,73271,555,0001,007,0002,457,600
26Sep 3, 2024 19:066,606100,431,09071,659,0001,009,0002,289,664
27Aug 23, 2024 15:316,631135,241,28072,938,74902,203,648
28Aug 23, 2024 15:316,636128,646,87972,995,12602,195,456
29Aug 23, 2024 15:316,643139,624,51973,076,20602,203,648
30Sep 3, 2024 19:066,65194,509,03471,158,0002,004,0002,367,488
31Sep 3, 2024 19:066,71398,492,17071,850,0001,995,0002,285,568