Skip to content
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

Update square-root description.md #2495

Merged
merged 22 commits into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from 13 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
xanni marked this conversation as resolved.
Outdated
Show resolved Hide resolved

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 calculate 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…
xanni marked this conversation as resolved.
Show resolved Hide resolved
- You also only need to output a positive whole number.
xanni marked this conversation as resolved.
Show resolved Hide resolved
xanni marked this conversation as resolved.
Show resolved Hide resolved

Some potential approaches:

- 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.
xanni marked this conversation as resolved.
Show resolved Hide resolved

[integer-square-root]: https://en.wikipedia.org/wiki/Integer_square_root
xanni marked this conversation as resolved.
Show resolved Hide resolved
[computing-square-roots]: https://en.wikipedia.org/wiki/Methods_of_computing_square_roots
10 changes: 10 additions & 0 deletions exercises/square-root/introduction.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Introduction

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

As the first step in our calculation, we take a number and find its square root—that is, the number that, when multiplied by itself, equals the given number.
xanni marked this conversation as resolved.
Show resolved Hide resolved

The journey will be very long.
To make the batteries last as long as possible, we had to make our rocket’s onboard computer very power efficient.
Unfortunately that means that we can’t rely on fancy math libraries and functions, as they use more power.
xanni marked this conversation as resolved.
Show resolved Hide resolved
Instead we want to calculate or approximate the square root directly.
xanni marked this conversation as resolved.
Show resolved Hide resolved