Skip to content

Update square-root description.md #2495

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 22 commits into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 0 additions & 13 deletions exercises/square-root/description.md

This file was deleted.

18 changes: 18 additions & 0 deletions exercises/square-root/instructions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Instructions

Your task is to implement a calculation of the square root of a given number.

- Try to avoid using the pre-existing math libraries of your language.
- As input you’ll be given a positive whole number, i.e. 1, 2, 3, 4…
- You also only need to output a positive whole number.

Examples of some approaches you could consider are:

- Linear or binary search for a number that gives the input number when squared
- Successive approximation using Newton's or Heron's method
- Calculating one digit at a time or one bit at a time

You can check out the Wikipedia pages on [integer square root][integer-square-root] and [methods of computing square roots][computing-square-roots] to help with choosing a method of calculation.

[integer-square-root]: https://en.wikipedia.org/wiki/Integer_square_root
[computing-square-roots]: https://en.wikipedia.org/wiki/Methods_of_computing_square_roots
9 changes: 9 additions & 0 deletions exercises/square-root/introduction.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Introduction

We are launching a deep space exploration rocket and we need a way to make sure the navigation system stays on target.

The first step in our coordinate calculation involves taking a number as input and finding another number which multiplied by itself will equal our input number, or in other words, finding the square root of our input number.

Because the journey will be very long, we had to make our rocket’s onboard computer very power efficient so it wouldn’t drain the batteries.
Unfortunately that means that we can’t rely on fancy math libraries and functions, as they would take more power.
Instead we want to calculate or approximate the square root directly.