The TransCompilator

Solved LeetCode program · 964 of 1,000

#1333 · Filter Restaurants by Vegan-Friendly, Price and Distance

Medium Array chunk-20.md

Original English source

Keep a shared rows as an empty list of whole numbers. Keep a shared ids as an empty list of whole numbers. Keep a shared ratings as an empty list of whole numbers. Keep a shared total of 0. Keep a shared winner of 0. Place 1 into rows. Place 4 into rows. Place 1 into rows. Place 40 into rows. Place 10 into rows. Place 2 into rows. Place 8 into rows. Place 0 into rows. Place 50 into rows. Place 5 into rows. Place 3 into rows. Place 8 into rows. Place 1 into rows. Place 30 into rows. Place 4 into rows. Place 4 into rows. Place 10 into rows. Place 0 into rows. Place 10 into rows. Place 3 into rows. Place 5 into rows. Place 1 into rows. Place 1 into rows. Place 15 into rows. Place 1 into rows.

To consider from restaurant (a whole number). The base is restaurant times 5. The vegan is item (base plus 2) of rows. The price is item (base plus 3) of rows. The distance is item (base plus 4) of rows. If vegan is 1 and price is at most 50 and distance is at most 10, Place item base of rows into ids, Place item (base plus 1) of rows into ratings, Add 1 to total.

To better from other (a whole number) with best (a whole number). The rating is item other of ratings. The otherid is item other of ids. If rating is more than item best of ratings or rating is item best of ratings and otherid is more than item best of ids, set winner to other.

To settle from spot (a whole number). Set winner to spot. For every other from spot plus 1 to total minus 1, Better from other with winner. The best is winner. The holdid is item spot of ids. The holdrating is item spot of ratings. Set item spot of ids to item best of ids. Set item spot of ratings to item best of ratings. Set item best of ids to holdid. Set item best of ratings to holdrating.

For every restaurant from 0 to 4, Consider from restaurant. For every spot from 0 to total minus 2, Settle from spot. For every spot from 0 to total minus 1, Show item spot of ids.

Open in Playground Browse all 1,000 problems

Expected stdout

3
1
5