Files
learngo/16-slices/exercises/README.md
2019-08-18 15:43:09 +03:00

96 lines
4.6 KiB
Markdown
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Slice Exercises
## Exercises Level I - Basics — Warm-Up
Let's reinforce your basic knowledge of slices.
1. **[Declare nil slices](https://github.com/inancgumus/learngo/tree/master/16-slices/exercises/01-declare-nil)**
2. **[Assign empty slices](https://github.com/inancgumus/learngo/tree/master/16-slices/exercises/02-empty)**
3. **[Assign slice literals](https://github.com/inancgumus/learngo/tree/master/16-slices/exercises/03-slice-literal)**
4. **[Declare the arrays as slices](https://github.com/inancgumus/learngo/tree/master/16-slices/exercises/04-declare-arrays-as-slices)**
5. **[Fix the Problems](https://github.com/inancgumus/learngo/tree/master/16-slices/exercises/05-fix-the-problems)**
6. **[Compare the slices](https://github.com/inancgumus/learngo/tree/master/16-slices/exercises/06-compare-the-slices)**
---
## Exercises Level II - Appending
Discover the power of the append function.
1. **[Append #1 — Append and compare byte slices](https://github.com/inancgumus/learngo/tree/master/16-slices/exercises/07-append)**
2. **[Append #2 — Append to a nil slice](https://github.com/inancgumus/learngo/tree/master/16-slices/exercises/08-append-2)**
3. **[Append #3 — Fix the problems](https://github.com/inancgumus/learngo/tree/master/16-slices/exercises/09-append-3-fix)**
4. **[Append and Sort Numbers](https://github.com/inancgumus/learngo/tree/master/16-slices/exercises/10-append-sort-nums)**
5. **[Housing Prices](https://github.com/inancgumus/learngo/tree/master/16-slices/exercises/11-housing-prices)**
6. **[Housing Prices and Averages](https://github.com/inancgumus/learngo/tree/master/16-slices/exercises/12-housing-prices-averages)**
---
## Exercises Level III - Slicing
Discover the power of slicing.
1. **[Slice the numbers](https://github.com/inancgumus/learngo/tree/master/16-slices/exercises/13-slicing-basics)**
2. **[Slicing by arguments](https://github.com/inancgumus/learngo/tree/master/16-slices/exercises/14-slicing-by-args)**
3. **[Slicing the Housing Prices](https://github.com/inancgumus/learngo/tree/master/16-slices/exercises/15-slicing-housing-prices)**
---
## Exercises Level IV - Internals
Peek into the internals of the slices and gain more insight. This is necessary for complete command of the slices.
1. **[Fix the backing array problems](https://github.com/inancgumus/learngo/tree/master/16-slices/exercises/16-internals-backing-array-fix)**
2. **[Sort the backing array](https://github.com/inancgumus/learngo/tree/master/16-slices/exercises/17-internals-backing-array-sort)**
3. **[Observe the memory allocations](https://github.com/inancgumus/learngo/tree/master/16-slices/exercises/18-internals-slice-header)**
4. **[Observe the length and capacity](https://github.com/inancgumus/learngo/tree/master/16-slices/exercises/19-observe-len-cap)**
5. **[Observe the capacity growth](https://github.com/inancgumus/learngo/tree/master/16-slices/exercises/20-observe-the-cap-growth)**
6. **[Correct the lyric](https://github.com/inancgumus/learngo/tree/master/16-slices/exercises/21-correct-the-lyric)**
---
## Exercises Level V - Advanced Operations
Commonly used and more advanced operations are available to slices. Now, it's time to test yourself and fix some common problems.
★ WARNING ★
Please update your local copy of the prettyslice package for some examples to work. [Please find the intructions how to do so here](../README.md).
1. **[Practice Advanced Slice Operations](https://github.com/inancgumus/learngo/tree/master/16-slices/exercises/22-adv-ops-practice)**
Let's warm you up for the advanced slice operations, and reinforce your neurons.
2. **[Limit the backing array sharing](https://github.com/inancgumus/learngo/tree/master/16-slices/exercises/23-limit-the-backing-array-sharing)**
Your package needs to control the slices that it shares with the outside world.
3. **[Fix the Memory Leak](https://github.com/inancgumus/learngo/tree/master/16-slices/exercises/24-fix-the-memory-leak)**
A slice retrieved from a package causes a memory leak in your program. You need to fix it.
4. **[Add a newline after each sentence](https://github.com/inancgumus/learngo/tree/master/16-slices/exercises/25-add-lines)**
Use the power of the `copy()` function and add newlines into a new buffer from a string slice. This exercise is more tricky than you might think.
5. **[Print Daily Requests](https://github.com/inancgumus/learngo/tree/master/16-slices/exercises/26-print-daily-requests)**
Group the web request logs into a multi-dimensional slice. Allocate a slice with the exact size needed by doing some wizardary calculations. And lastly, pretty print the result.