Question: This is the problem that I am trying to solve and this is my code: using System; using System.IO; namespace Lazy_Fox { class Program {

 This is the problem that I am trying to solve andthis is my code: using System; using System.IO; namespace Lazy_Fox { class

This is the problem that I am trying to solve and this is my code:

using System; using System.IO;

namespace Lazy_Fox { class Program { static void Main(string[] args) { Console.WriteLine("Enter the number of neighbours: "); int N = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Enter the coordinates for all the neighbours: ");

int[] x = new int[N]; int[] y = new int[N];

for(int i=0; i

double totalTreats = calculations(0, 0, x, y, N, 9999999); Console.WriteLine(); Console.WriteLine("The total number of treats that the fox gathers is: "+totalTreats); }

static int calculations(int currentX, int currentY, int[] x, int[] y, int N, double lastDistance) { if (lastDistance == 0) { return 1; }

double maxDistance = 0; double distance; int index = 0;

for (int i = 0; i

if (distance maxDistance) { maxDistance = distance; index = i; } } }

if(maxDistance != 0) { return (1 + calculations(x[index], y[index], x, y, N, maxDistance)); } else { return 1; } } } }

I am not sure what I am doing wrong but when i put in the sample input I am getting the right output but when i put in the input that my teacher has asked which is:

10 75 1 55 70 53 92 37 46 47 6 49 86 80 14 79 50 0 71 13 27

The output I am getting out of this is 12...when the right output for this input is 17. I am not sure what I am doing wrong here...I would really appreciate if someone could help me out here...THANK YOU

NOTE: CODE USING C#

Problem S5: Lazy Fox Problem Description You have a pet Fox who loves treats. You have N neighbours at distinct locations described as points on the Cartesian plane) which hand out treats to your pet Fox, and each neighbour has an unlimited number of treats to give out. The origin (which is where the Fox starts) will not be one of these N locations. What does the Fox say, in order to get these treats? That is a good question, but not our concern. The Fox moves from location to location to gather exactly one treat from each location on each visit. He can revisit any previous location, but cannot visit the same location on two consecutive visits. Your Fox is very lazy. The distance your Fox is willing to travel after each treat will strictly decrease. Specifically, the distance from the origin to his first treat location must be larger than the distance from his first treat location to his second treat location, which in turn is larger than the distance between his second treat location and his third treat location, and so on. What is the largest number of treats your Fox gathers? Input Specification The first line contains the integer N (1 SN S 2000). The next N lines each contain X, followed by a space, followed by Y., for i = 1..N (-10000 S X, Y, S 10 000) representing the coordinates of the ith location. The following additional constraints will apply. At least 20% of the marks will be for test cases where N

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!