Question: Implementation in python 3.9.2 Problem H: Sarfaranga Rally Sarfaranga is a desert in the northern areas of Pakistan. It is a major town in the

Implementation in python 3.9.2
Problem H: Sarfaranga Rally Sarfaranga is a desert in the northern areas of Pakistan. It is a major town in the Baltistan region which abounds in natural beauty. Located at the foothills of the mighty Karakoram Range, it is often the last town where mountaineers gather to give final touches to their K2 (the second highest peak in the world) expedition. Sarfaranga is located just outside of Skardu and every year a jeep rally event is organized there to see the best drivers and cars that can cross the desert. Many drivers from far and wide participate in this rally both for passion and for the prestige The rally has been on-going for several years with familiar faces and many times, familiar winners. This year its organizers thought of a way to "spice things up a bit. They thought that in addition to seeing who's got the best car and driving skills, they will also see who the smartest driver is. To achieve that they came up with an interesting plan. The rally has been divided into N stages each consisting of M blocks like a 2D grid fashion. Stages are numbered from 1 to N (top to bottom) and blocks of each stage are numbered from 1 to M (left to right). Each block has an entry/exit gate to an adjacent block such that a driver can only move to a top, bottom, left, or right block from his/her current block position. Each block has a penalty to cross through that block. All drivers must start from the 1st block of the 1st stage and end up in the Mth block of Nth stage. Note that, drivers can not move out of the grid as it will cause immediate disqualification. You are a rally driver in the Sarfaranga desert rally. Just before the start of the race, each driver is provided with a map of the rally stage that includes the penalty associated with each block. You job is to quickly figure out the path that will result in the least penalty to win the race. Input The first line in the input file is an integer T (1 ST 550) denoting the number of test cases. Each test case starts with two integers N and M (15N, M = 20). Next line of the test case contains stage-wise entry of the penalty of each block (O S Penalty of each block $ 200) Output For each test case, print a single line with the case number followed by the minimal penalty incurred if we follow the optimal path. See samples below for more clarification. Sample Input Output for Sample Input case 1: Penalty = 12 Case 2: Penalty = 4 3 3 1 2 354 3105 11 4 4 4 0 5 7 8 1
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
