Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Can someone please help with problem 5? I have to write a code that follows the step-by-step instructions seen in red in the Linux Mint

image text in transcribedCan someone please help with problem 5? I have to write a code that follows the step-by-step instructions seen in red in the Linux Mint software.

Problem 5. (Closest Point) Write a program that takes three floats x, y, and z from the command line, reads from standard input a sequence of coordinates (i, yi, 2i), and writes the coordinates of the point closest to (r,y, z). Recall that the square of the distance between (z, y, z) and (zi yi, 2i) is (z-ri)2 + (y Vi)2 + (z &J2 For efficiency, do not use either math sqrt() or theoperator S python3 closest py 1.0 5.0 1.0 3.0 9.0 5.0 3.0 2.5 9.0 6.0 2.0 2.O 6.0 3.0 5.0 6.0 5.0 closest point (2.000000, 6.000000, 3.000000) Linux Mint [Running] closest.py (/coursework/homework5) File Edit View Search Tools Documents Help closest.py: takes three floats x, y, and z from the command line, reads from # standard input a sequence of coordinates (xi, yi, z-1), and writes the # coordinates of the point closest to (x, y, z). import stdio import sys # Read x, y, and z from command line, as floats. # closest squared-distance so far, initialized to infinity bestDist2 = float(' inf . ) # Read coordinates (xi, yi, zi) from standard input and calculate its # squared-distance to the point (x, y, z). Check if that value is smaller # than bestDist2, and if so, update bestDist2 to the new value, and # let (bestx, besty, bestz) be (xi, yi, zi). while .. . : # Write the closest point (bestx, besty, bestz). stdio.writef ( "closest point (%f, %f , %f ) ., ) , , Problem 5. (Closest Point) Write a program that takes three floats x, y, and z from the command line, reads from standard input a sequence of coordinates (i, yi, 2i), and writes the coordinates of the point closest to (r,y, z). Recall that the square of the distance between (z, y, z) and (zi yi, 2i) is (z-ri)2 + (y Vi)2 + (z &J2 For efficiency, do not use either math sqrt() or theoperator S python3 closest py 1.0 5.0 1.0 3.0 9.0 5.0 3.0 2.5 9.0 6.0 2.0 2.O 6.0 3.0 5.0 6.0 5.0 closest point (2.000000, 6.000000, 3.000000) Linux Mint [Running] closest.py (/coursework/homework5) File Edit View Search Tools Documents Help closest.py: takes three floats x, y, and z from the command line, reads from # standard input a sequence of coordinates (xi, yi, z-1), and writes the # coordinates of the point closest to (x, y, z). import stdio import sys # Read x, y, and z from command line, as floats. # closest squared-distance so far, initialized to infinity bestDist2 = float(' inf . ) # Read coordinates (xi, yi, zi) from standard input and calculate its # squared-distance to the point (x, y, z). Check if that value is smaller # than bestDist2, and if so, update bestDist2 to the new value, and # let (bestx, besty, bestz) be (xi, yi, zi). while .. . : # Write the closest point (bestx, besty, bestz). stdio.writef ( "closest point (%f, %f , %f ) ., )

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions