fix: some typos in slices adv. ops.
This commit is contained in:
		| @@ -78,12 +78,11 @@ func main() { | |||||||
| 	// | 	// | ||||||
| 	// #4: Copy elements from an array to the `names` slice. | 	// #4: Copy elements from an array to the `names` slice. | ||||||
| 	// | 	// | ||||||
| 	//     Currently, `cap(names)` is 5. So, copy only | 	//     Copy only the first two elements of the following | ||||||
| 	//     the first two elements of the following array | 	//     array to the last two elements of the `names` slice. | ||||||
| 	//     to the last two elements of the `names` slice. |  | ||||||
| 	// | 	// | ||||||
| 	//     Print the names slice (do not forget extending it). | 	//     Print the names slice (do not forget extending it | ||||||
| 	//     You should print 5 elements. | 	//     after appending). You should print 5 elements. | ||||||
| 	// | 	// | ||||||
| 	//     Observe how the backing array stays the same. | 	//     Observe how the backing array stays the same. | ||||||
| 	// | 	// | ||||||
|   | |||||||
| @@ -5,6 +5,7 @@ var temps = []int{5, 10, 3, 25, 45, 80, 90} | |||||||
| // Read returns a range of temperature readings beginning from | // Read returns a range of temperature readings beginning from | ||||||
| // the `start` until to the `stop`. | // the `start` until to the `stop`. | ||||||
| func Read(start, stop int) []int { | func Read(start, stop int) []int { | ||||||
|  | 	// | ||||||
| 	// Uses a full slice expression to control the length of the | 	// Uses a full slice expression to control the length of the | ||||||
| 	// backing array (or the capacity of the returned slice). | 	// backing array (or the capacity of the returned slice). | ||||||
| 	// | 	// | ||||||
|   | |||||||
| @@ -17,7 +17,7 @@ import ( | |||||||
| // --------------------------------------------------------- | // --------------------------------------------------------- | ||||||
| // EXERCISE: Fix the memory leak | // EXERCISE: Fix the memory leak | ||||||
| // | // | ||||||
| //  You're receiving millions of temperature data points from | //  You receive millions of temperature data points from | ||||||
| //  an API, but you only need the last 10 data points. | //  an API, but you only need the last 10 data points. | ||||||
| // | // | ||||||
| //  Currently, there is a memory leak in your program. | //  Currently, there is a memory leak in your program. | ||||||
| @@ -33,7 +33,7 @@ import ( | |||||||
| // EXPECTED OUTPUT EXPLANATION | // EXPECTED OUTPUT EXPLANATION | ||||||
| // | // | ||||||
| //   Your output will be different. Your goal is to reduce the | //   Your output will be different. Your goal is to reduce the | ||||||
| //   difference between the two measurements of the memory usage. | //   difference between two measurements of the memory usage. | ||||||
| // | // | ||||||
| //   For the expected output above: | //   For the expected output above: | ||||||
| // | // | ||||||
|   | |||||||
| @@ -15,9 +15,9 @@ import ( | |||||||
| //  each sentence of the lyric to the new buffer, then | //  each sentence of the lyric to the new buffer, then | ||||||
| //  after each sentence adding a newline character. | //  after each sentence adding a newline character. | ||||||
| // | // | ||||||
| //  You cannot guess how many times you will get across | //  You will get across something like this all the time | ||||||
| //  something like this. Believe me, learning this will | //  in your gopher life. Believe me, learning how to | ||||||
| //  make you a better Gopher. | //  solve this exercise will make you a better hopher. | ||||||
| // | // | ||||||
| // | // | ||||||
| // RESTRICTIONS | // RESTRICTIONS | ||||||
| @@ -26,14 +26,14 @@ import ( | |||||||
| // | // | ||||||
| //  	. Instead, only use the `copy()` func. | //  	. Instead, only use the `copy()` func. | ||||||
| // | // | ||||||
| //  . You cannot use slicing for printing the sentences. | //  . Don't use slicing for printing the sentences. | ||||||
| // | // | ||||||
| //    . Instead, use slicing to fill the new buffer, then print it. | //    . Instead, use slicing for filling the new buffer. | ||||||
| // | // | ||||||
| // | // | ||||||
| // STEPS | // STEPS | ||||||
| // | // | ||||||
| //  . Follow the instructions inside the code. | //  . Please follow the instructions inside the code. | ||||||
| // | // | ||||||
| // | // | ||||||
| // EXPECTED OUTPUT | // EXPECTED OUTPUT | ||||||
| @@ -51,7 +51,7 @@ func main() { | |||||||
| 	// This inits some options for the prettyslice package. | 	// This inits some options for the prettyslice package. | ||||||
| 	// You can change the options if you want. | 	// You can change the options if you want. | ||||||
| 	// | 	// | ||||||
| 	// s.Colors(false)     // if your editor is light colored then enable this | 	// s.Colors(false)     // if your editor is light background color then enable this | ||||||
| 	s.PrintBacking = true  // prints the backing arrays | 	s.PrintBacking = true  // prints the backing arrays | ||||||
| 	s.MaxPerLine = 15      // prints max 15 elements per line | 	s.MaxPerLine = 15      // prints max 15 elements per line | ||||||
| 	s.SpaceCharacter = "*" // print this instead of printing a newline (for debugging) | 	s.SpaceCharacter = "*" // print this instead of printing a newline (for debugging) | ||||||
| @@ -65,10 +65,10 @@ func main() { | |||||||
| 	// | 	// | ||||||
| 	// RESTRICTION EXPLANATION: | 	// RESTRICTION EXPLANATION: | ||||||
| 	// | 	// | ||||||
| 	// Don't do something like this: | 	// Do not use slicing for printing the sentences. | ||||||
| 	// (Do not use slicing for printing the sentences) | 	// | ||||||
|  | 	// For example, don't do something like this: | ||||||
| 	// | 	// | ||||||
|  |  | ||||||
| 	// fmt.Println(lyric[:8]) | 	// fmt.Println(lyric[:8]) | ||||||
| 	// fmt.Println(lyric[8:18]) | 	// fmt.Println(lyric[8:18]) | ||||||
| 	// fmt.Println(lyric[18:23]) | 	// fmt.Println(lyric[18:23]) | ||||||
| @@ -77,7 +77,8 @@ func main() { | |||||||
| 	// | 	// | ||||||
| 	// #1: CREATE A LARGE ENOUGH BUFFER (A NEW SLICE) | 	// #1: CREATE A LARGE ENOUGH BUFFER (A NEW SLICE) | ||||||
| 	// | 	// | ||||||
| 	//     You need to put each lyric sentence + a newline into this buffer | 	//     You need to put each lyric sentence | ||||||
|  | 	//     + a newline character into this buffer | ||||||
| 	// | 	// | ||||||
|  |  | ||||||
| 	// I name the buffer: `fix`, you can name it however you want | 	// I name the buffer: `fix`, you can name it however you want | ||||||
|   | |||||||
| @@ -4,10 +4,10 @@ package main | |||||||
| // EXERCISE: Print daily requests | // EXERCISE: Print daily requests | ||||||
| // | // | ||||||
| //  You've got a requests log for a system in a slice: `reqs`. | //  You've got a requests log for a system in a slice: `reqs`. | ||||||
| //  The log contains the total requests counts per 8 hours. | //  The log contains the total request counts per 8 hours. | ||||||
| // | // | ||||||
| //  The reqs slice is a single-dimensional slice but you need | //  The reqs slice is a single-dimensional slice but you need | ||||||
| //  to group the daily into a slice named: `daily`. | //  to group the requests daily into a slice named: `daily`. | ||||||
| // | // | ||||||
| //  Please follow the instructions inside the code to solve | //  Please follow the instructions inside the code to solve | ||||||
| //  the exercise. | //  the exercise. | ||||||
| @@ -40,10 +40,15 @@ func main() { | |||||||
| 	// | 	// | ||||||
|  |  | ||||||
| 	// reqs := []int{ | 	// reqs := []int{ | ||||||
|  | 	//	// 1st day | ||||||
| 	//	500, 600, 250, | 	//	500, 600, 250, | ||||||
|  | 	//	// 2nd day | ||||||
| 	//	200, 400, 50, | 	//	200, 400, 50, | ||||||
|  | 	//	// 3rd day | ||||||
| 	//	900, 800, 600, | 	//	900, 800, 600, | ||||||
|  | 	//	// 4th day | ||||||
| 	//	750, 250, 100, | 	//	750, 250, 100, | ||||||
|  | 	//	// last day | ||||||
| 	//	100, 150, | 	//	100, 150, | ||||||
| 	// } | 	// } | ||||||
|  |  | ||||||
| @@ -93,12 +98,12 @@ func main() { | |||||||
| 	// | 	// | ||||||
| 	// ❤️ NOTE ❤️ | 	// ❤️ NOTE ❤️ | ||||||
| 	// | 	// | ||||||
| 	// If you could't solve this challenge. Please do not get discouraged. | 	// If you could't solve this challenge, please do not get discouraged. | ||||||
| 	// | 	// | ||||||
| 	// Look at the solution, then try to solve it again. This is valuable too. | 	// Look at the solution, then try to solve it again. This is valuable too. | ||||||
| 	// | 	// | ||||||
| 	// Then ️change the request data, the number of requests per day (now it's 3), etc | 	// Then ️change the request data, the number of requests per day (now it's 3), | ||||||
| 	// and then try to solve it again. | 	// etc., and then try to solve it again. | ||||||
| 	// | 	// | ||||||
| 	// ------------------------------------------------------------------------ | 	// ------------------------------------------------------------------------ | ||||||
| } | } | ||||||
|   | |||||||
| @@ -79,7 +79,7 @@ Commonly used and more advanced operations are available to slices. Now, it's ti | |||||||
|  |  | ||||||
|     Your API does not control the slices that it share with the outside world. You need to fix it. |     Your API does not control the slices that it share with the outside world. You need to fix it. | ||||||
|  |  | ||||||
| 3. **[Fix the Memory Leak](https://github.com/inancgumus/learngo/tree/master/16-slices/exercises/25-fix-the-memory-leak)** | 3. **[Fix the Memory Leak](https://github.com/inancgumus/learngo/tree/master/16-slices/exercises/24-fix-the-memory-leak)** | ||||||
|  |  | ||||||
|     A slice retrieved from an API causes a memory leak in your program. You need to fix it. |     A slice retrieved from an API causes a memory leak in your program. You need to fix it. | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user