diff --git a/14-arrays/13-project-clock/01-printing-the-digits/README.md b/15-project-retro-led-clock/01-printing-the-digits/README.md similarity index 100% rename from 14-arrays/13-project-clock/01-printing-the-digits/README.md rename to 15-project-retro-led-clock/01-printing-the-digits/README.md diff --git a/14-arrays/13-project-clock/01-printing-the-digits/main.go b/15-project-retro-led-clock/01-printing-the-digits/main.go similarity index 100% rename from 14-arrays/13-project-clock/01-printing-the-digits/main.go rename to 15-project-retro-led-clock/01-printing-the-digits/main.go diff --git a/14-arrays/13-project-clock/01-printing-the-digits/solution/main.go b/15-project-retro-led-clock/01-printing-the-digits/solution/main.go similarity index 100% rename from 14-arrays/13-project-clock/01-printing-the-digits/solution/main.go rename to 15-project-retro-led-clock/01-printing-the-digits/solution/main.go diff --git a/14-arrays/13-project-clock/02-printing-the-clock/README.md b/15-project-retro-led-clock/02-printing-the-clock/README.md similarity index 100% rename from 14-arrays/13-project-clock/02-printing-the-clock/README.md rename to 15-project-retro-led-clock/02-printing-the-clock/README.md diff --git a/14-arrays/13-project-clock/02-printing-the-clock/main.go b/15-project-retro-led-clock/02-printing-the-clock/main.go similarity index 100% rename from 14-arrays/13-project-clock/02-printing-the-clock/main.go rename to 15-project-retro-led-clock/02-printing-the-clock/main.go diff --git a/14-arrays/13-project-clock/02-printing-the-clock/solution/main.go b/15-project-retro-led-clock/02-printing-the-clock/solution/main.go similarity index 100% rename from 14-arrays/13-project-clock/02-printing-the-clock/solution/main.go rename to 15-project-retro-led-clock/02-printing-the-clock/solution/main.go diff --git a/14-arrays/13-project-clock/03-animating-the-clock/README.md b/15-project-retro-led-clock/03-animating-the-clock/README.md similarity index 100% rename from 14-arrays/13-project-clock/03-animating-the-clock/README.md rename to 15-project-retro-led-clock/03-animating-the-clock/README.md diff --git a/14-arrays/13-project-clock/03-animating-the-clock/main.go b/15-project-retro-led-clock/03-animating-the-clock/main.go similarity index 100% rename from 14-arrays/13-project-clock/03-animating-the-clock/main.go rename to 15-project-retro-led-clock/03-animating-the-clock/main.go diff --git a/14-arrays/13-project-clock/03-animating-the-clock/solution/main.go b/15-project-retro-led-clock/03-animating-the-clock/solution/main.go similarity index 100% rename from 14-arrays/13-project-clock/03-animating-the-clock/solution/main.go rename to 15-project-retro-led-clock/03-animating-the-clock/solution/main.go diff --git a/14-arrays/13-project-clock/04-blinking-the-separators/README.md b/15-project-retro-led-clock/04-blinking-the-separators/README.md similarity index 100% rename from 14-arrays/13-project-clock/04-blinking-the-separators/README.md rename to 15-project-retro-led-clock/04-blinking-the-separators/README.md diff --git a/14-arrays/13-project-clock/04-blinking-the-separators/main.go b/15-project-retro-led-clock/04-blinking-the-separators/main.go similarity index 100% rename from 14-arrays/13-project-clock/04-blinking-the-separators/main.go rename to 15-project-retro-led-clock/04-blinking-the-separators/main.go diff --git a/14-arrays/13-project-clock/04-blinking-the-separators/solution/main.go b/15-project-retro-led-clock/04-blinking-the-separators/solution/main.go similarity index 100% rename from 14-arrays/13-project-clock/04-blinking-the-separators/solution/main.go rename to 15-project-retro-led-clock/04-blinking-the-separators/solution/main.go diff --git a/14-arrays/13-project-clock/05-full-annotated-solution/main.go b/15-project-retro-led-clock/05-full-annotated-solution/main.go similarity index 100% rename from 14-arrays/13-project-clock/05-full-annotated-solution/main.go rename to 15-project-retro-led-clock/05-full-annotated-solution/main.go diff --git a/14-arrays/13-project-clock/README.md b/15-project-retro-led-clock/README.md similarity index 76% rename from 14-arrays/13-project-clock/README.md rename to 15-project-retro-led-clock/README.md index 088ec60..9353567 100644 --- a/14-arrays/13-project-clock/README.md +++ b/15-project-retro-led-clock/README.md @@ -11,26 +11,26 @@ ## GOALS: -### πŸ‘‰ [STEP #1 β€” Print the Digits](https://github.com/inancgumus/learngo/tree/master/14-arrays/13-project-clock/01-printing-the-digits/) +### πŸ‘‰ [STEP #1 β€” Print the Digits](https://github.com/inancgumus/learngo/tree/master/15-project-retro-clock/01-printing-the-digits/) - [ ] Define a new placeholder type - [ ] Create the digit arrays from 0 to 9 - [ ] Put them into the "digits" array - [ ] Print them side-by-side -### πŸ‘‰ [STEP #2 β€” Print the Clock](https://github.com/inancgumus/learngo/tree/master/14-arrays/13-project-clock/02-printing-the-clock/) +### πŸ‘‰ [STEP #2 β€” Print the Clock](https://github.com/inancgumus/learngo/tree/master/15-project-retro-clock/02-printing-the-clock/) - [ ] Get the current time - [ ] Create the clock array - [ ] Print the clock - [ ] Add the separators -### πŸ‘‰ [STEP #3 β€” Animate the Clock](https://github.com/inancgumus/learngo/tree/master/14-arrays/13-project-clock/03-animating-the-clock/) +### πŸ‘‰ [STEP #3 β€” Animate the Clock](https://github.com/inancgumus/learngo/tree/master/15-project-retro-clock/03-animating-the-clock/) - [ ] Create an infinite loop to update the clock - [ ] Update the clock every second - [ ] Clear the screen before the infinite loop - [ ] Move the cursor to the top-left corner of the screen before each step of the infinite loop -### πŸ‘‰ [BONUS: STEP #4 β€” Blink the Clock](https://github.com/inancgumus/learngo/tree/master/14-arrays/13-project-clock/04-blinking-the-separators/) +### πŸ‘‰ [BONUS: STEP #4 β€” Blink the Clock](https://github.com/inancgumus/learngo/tree/master/15-project-retro-clock/04-blinking-the-separators/) - [ ] Blink the separators -### πŸ‘‰ [FULL ANNOTATED SOLUTION](https://github.com/inancgumus/learngo/tree/master/14-arrays/13-project-clock/05-full-annotated-solution/main.go) \ No newline at end of file +### πŸ‘‰ [FULL ANNOTATED SOLUTION](https://github.com/inancgumus/learngo/tree/master/15-project-retro-clock/05-full-annotated-solution/main.go) \ No newline at end of file diff --git a/14-arrays/13-project-clock/exercises/01-refactor/main.go b/15-project-retro-led-clock/exercises/01-refactor/main.go similarity index 100% rename from 14-arrays/13-project-clock/exercises/01-refactor/main.go rename to 15-project-retro-led-clock/exercises/01-refactor/main.go diff --git a/14-arrays/13-project-clock/exercises/01-refactor/solution/main.go b/15-project-retro-led-clock/exercises/01-refactor/solution/main.go similarity index 100% rename from 14-arrays/13-project-clock/exercises/01-refactor/solution/main.go rename to 15-project-retro-led-clock/exercises/01-refactor/solution/main.go diff --git a/14-arrays/13-project-clock/exercises/01-refactor/solution/placeholders.go b/15-project-retro-led-clock/exercises/01-refactor/solution/placeholders.go similarity index 100% rename from 14-arrays/13-project-clock/exercises/01-refactor/solution/placeholders.go rename to 15-project-retro-led-clock/exercises/01-refactor/solution/placeholders.go diff --git a/14-arrays/13-project-clock/exercises/02-alarm/main.go b/15-project-retro-led-clock/exercises/02-alarm/main.go similarity index 100% rename from 14-arrays/13-project-clock/exercises/02-alarm/main.go rename to 15-project-retro-led-clock/exercises/02-alarm/main.go diff --git a/14-arrays/13-project-clock/exercises/02-alarm/placeholders.go b/15-project-retro-led-clock/exercises/02-alarm/placeholders.go similarity index 100% rename from 14-arrays/13-project-clock/exercises/02-alarm/placeholders.go rename to 15-project-retro-led-clock/exercises/02-alarm/placeholders.go diff --git a/14-arrays/13-project-clock/exercises/02-alarm/solution/main.go b/15-project-retro-led-clock/exercises/02-alarm/solution/main.go similarity index 100% rename from 14-arrays/13-project-clock/exercises/02-alarm/solution/main.go rename to 15-project-retro-led-clock/exercises/02-alarm/solution/main.go diff --git a/14-arrays/13-project-clock/exercises/02-alarm/solution/placeholders.go b/15-project-retro-led-clock/exercises/02-alarm/solution/placeholders.go similarity index 100% rename from 14-arrays/13-project-clock/exercises/02-alarm/solution/placeholders.go rename to 15-project-retro-led-clock/exercises/02-alarm/solution/placeholders.go diff --git a/14-arrays/13-project-clock/exercises/03-split-second/main.go b/15-project-retro-led-clock/exercises/03-split-second/main.go similarity index 100% rename from 14-arrays/13-project-clock/exercises/03-split-second/main.go rename to 15-project-retro-led-clock/exercises/03-split-second/main.go diff --git a/14-arrays/13-project-clock/exercises/03-split-second/placeholders.go b/15-project-retro-led-clock/exercises/03-split-second/placeholders.go similarity index 100% rename from 14-arrays/13-project-clock/exercises/03-split-second/placeholders.go rename to 15-project-retro-led-clock/exercises/03-split-second/placeholders.go diff --git a/14-arrays/13-project-clock/exercises/03-split-second/solution/main.go b/15-project-retro-led-clock/exercises/03-split-second/solution/main.go similarity index 100% rename from 14-arrays/13-project-clock/exercises/03-split-second/solution/main.go rename to 15-project-retro-led-clock/exercises/03-split-second/solution/main.go diff --git a/14-arrays/13-project-clock/exercises/03-split-second/solution/placeholders.go b/15-project-retro-led-clock/exercises/03-split-second/solution/placeholders.go similarity index 100% rename from 14-arrays/13-project-clock/exercises/03-split-second/solution/placeholders.go rename to 15-project-retro-led-clock/exercises/03-split-second/solution/placeholders.go diff --git a/14-arrays/13-project-clock/exercises/04-ticker/main.go b/15-project-retro-led-clock/exercises/04-ticker/main.go similarity index 100% rename from 14-arrays/13-project-clock/exercises/04-ticker/main.go rename to 15-project-retro-led-clock/exercises/04-ticker/main.go diff --git a/14-arrays/13-project-clock/exercises/04-ticker/placeholders.go b/15-project-retro-led-clock/exercises/04-ticker/placeholders.go similarity index 100% rename from 14-arrays/13-project-clock/exercises/04-ticker/placeholders.go rename to 15-project-retro-led-clock/exercises/04-ticker/placeholders.go diff --git a/14-arrays/13-project-clock/exercises/04-ticker/solution/main.go b/15-project-retro-led-clock/exercises/04-ticker/solution/main.go similarity index 100% rename from 14-arrays/13-project-clock/exercises/04-ticker/solution/main.go rename to 15-project-retro-led-clock/exercises/04-ticker/solution/main.go diff --git a/14-arrays/13-project-clock/exercises/04-ticker/solution/placeholders.go b/15-project-retro-led-clock/exercises/04-ticker/solution/placeholders.go similarity index 100% rename from 14-arrays/13-project-clock/exercises/04-ticker/solution/placeholders.go rename to 15-project-retro-led-clock/exercises/04-ticker/solution/placeholders.go diff --git a/14-arrays/13-project-clock/exercises/README.md b/15-project-retro-led-clock/exercises/README.md similarity index 80% rename from 14-arrays/13-project-clock/exercises/README.md rename to 15-project-retro-led-clock/exercises/README.md index c206544..65aebd4 100644 --- a/14-arrays/13-project-clock/exercises/README.md +++ b/15-project-retro-led-clock/exercises/README.md @@ -2,20 +2,20 @@ These exercises will reinforce your knowledge of manipulating arrays. You will prove yourself that you can write easy to maintain Go programs. -1. **[Refactor](https://github.com/inancgumus/learngo/tree/master/14-arrays/13-project-clock/exercises/01-refactor)** +1. **[Refactor](https://github.com/inancgumus/learngo/tree/master/15-project-retro-led-clock/exercises/01-refactor)** In this exercise, you will refactor the project to multiple files by moving all the placeholders. This will make the project easy to maintain down the road. -2. **[Set an Alarm](https://github.com/inancgumus/learngo/tree/master/14-arrays/13-project-clock/exercises/02-alarm)** +2. **[Set an Alarm](https://github.com/inancgumus/learngo/tree/master/15-project-retro-led-clock/exercises/02-alarm)** You will print " ALARM! " every 10 seconds. -3. **[Split Second](https://github.com/inancgumus/learngo/tree/master/14-arrays/13-project-clock/exercises/03-split-second)** +3. **[Split Second](https://github.com/inancgumus/learngo/tree/master/15-project-retro-led-clock/exercises/03-split-second)** You will display the split second in the clock, you will need to update the clock every 1/10th of a second instead of every second. -4. **[Ticker](https://github.com/inancgumus/learngo/tree/master/14-arrays/13-project-clock/exercises/04-ticker)** +4. **[Ticker](https://github.com/inancgumus/learngo/tree/master/15-project-retro-led-clock/exercises/04-ticker)** This is an HARD EXERCISE. You will slide the clock animation from right-to-left. After this exercise, you will truly feel that you've mastered everything you've learned so far. \ No newline at end of file diff --git a/15-slices/exercises/README.md b/15-slices/exercises/README.md deleted file mode 100644 index 2d40194..0000000 --- a/15-slices/exercises/README.md +++ /dev/null @@ -1,31 +0,0 @@ -# Slice Exercises - -## Exercises Level I - Basics β€” Warm-Up - -1. **[Declare nil slices](https://github.com/inancgumus/learngo/tree/master/15-slices/exercises/01-declare-nil)** - -2. **[Assign empty slices](https://github.com/inancgumus/learngo/tree/master/15-slices/exercises/02-empty)** - -3. **[Assign slice literals](https://github.com/inancgumus/learngo/tree/master/15-slices/exercises/03-slice-literal)** - -4. **[Declare the arrays as slices](https://github.com/inancgumus/learngo/tree/master/15-slices/exercises/04-declare-arrays-as-slices)** - -5. **[Fix the Problems](https://github.com/inancgumus/learngo/tree/master/15-slices/exercises/05-fix-the-problems)** - -6. **[Compare the slices](https://github.com/inancgumus/learngo/tree/master/15-slices/exercises/06-compare-the-slices)** - ---- - -## Exercises Level II - Appending - -1. **[Append #1 β€” Append and compare byte slices](https://github.com/inancgumus/learngo/tree/master/15-slices/exercises/07-append)** - -2. **[Append #2 β€”Β Append to a nil slice](https://github.com/inancgumus/learngo/tree/master/15-slices/exercises/08-append-2)** - -3. **[Append #3 β€” Fix the problems](https://github.com/inancgumus/learngo/tree/master/15-slices/exercises/09-append-3-fix)** - -4. **[Append #4 β€” Sort and write items to a file](https://github.com/inancgumus/learngo/tree/master/15-slices/exercises/10-append-4-sort-to-a-file)** - -5. **[Append #5 β€” Sort and write items to a file with their ordinals](https://github.com/inancgumus/learngo/tree/master/15-slices/exercises/11-append-5-sort-to-a-file)** - -5. **[Append #6 β€” Find and write the names of subdirectories to a file](https://github.com/inancgumus/learngo/tree/master/15-slices/exercises/12-append-6-print-directories)** \ No newline at end of file diff --git a/15-slices/01-slices-vs-arrays/main.go b/16-slices/01-slices-vs-arrays/main.go similarity index 100% rename from 15-slices/01-slices-vs-arrays/main.go rename to 16-slices/01-slices-vs-arrays/main.go diff --git a/15-slices/02-slices-vs-arrays/main.go b/16-slices/02-slices-vs-arrays/main.go similarity index 100% rename from 15-slices/02-slices-vs-arrays/main.go rename to 16-slices/02-slices-vs-arrays/main.go diff --git a/15-slices/03-slices-vs-arrays-examples/main.go b/16-slices/03-slices-vs-arrays-examples/main.go similarity index 100% rename from 15-slices/03-slices-vs-arrays-examples/main.go rename to 16-slices/03-slices-vs-arrays-examples/main.go diff --git a/15-slices/04-slices-vs-arrays-unique-nums/01-with-arrays/main.go b/16-slices/04-slices-vs-arrays-unique-nums/01-with-arrays/main.go similarity index 100% rename from 15-slices/04-slices-vs-arrays-unique-nums/01-with-arrays/main.go rename to 16-slices/04-slices-vs-arrays-unique-nums/01-with-arrays/main.go diff --git a/15-slices/04-slices-vs-arrays-unique-nums/02-with-slices/main.go b/16-slices/04-slices-vs-arrays-unique-nums/02-with-slices/main.go similarity index 100% rename from 15-slices/04-slices-vs-arrays-unique-nums/02-with-slices/main.go rename to 16-slices/04-slices-vs-arrays-unique-nums/02-with-slices/main.go diff --git a/15-slices/05-append/1-theory/main.go b/16-slices/05-append/1-theory/main.go similarity index 100% rename from 15-slices/05-append/1-theory/main.go rename to 16-slices/05-append/1-theory/main.go diff --git a/15-slices/05-append/2-example/main.go b/16-slices/05-append/2-example/main.go similarity index 100% rename from 15-slices/05-append/2-example/main.go rename to 16-slices/05-append/2-example/main.go diff --git a/15-slices/08-slice-expressions/1-theory/main.go b/16-slices/06-slice-expressions/1-theory/main.go similarity index 100% rename from 15-slices/08-slice-expressions/1-theory/main.go rename to 16-slices/06-slice-expressions/1-theory/main.go diff --git a/15-slices/08-slice-expressions/2-example/main.go b/16-slices/06-slice-expressions/2-example/main.go similarity index 100% rename from 15-slices/08-slice-expressions/2-example/main.go rename to 16-slices/06-slice-expressions/2-example/main.go diff --git a/15-slices/09-slice-expressions-pagination/main.go b/16-slices/07-slice-expressions-pagination/main.go similarity index 100% rename from 15-slices/09-slice-expressions-pagination/main.go rename to 16-slices/07-slice-expressions-pagination/main.go diff --git a/15-slices/README.md b/16-slices/README.md similarity index 100% rename from 15-slices/README.md rename to 16-slices/README.md diff --git a/15-slices/exercises/01-declare-nil/main.go b/16-slices/exercises/01-declare-nil/main.go similarity index 100% rename from 15-slices/exercises/01-declare-nil/main.go rename to 16-slices/exercises/01-declare-nil/main.go diff --git a/15-slices/exercises/01-declare-nil/solution/main.go b/16-slices/exercises/01-declare-nil/solution/main.go similarity index 100% rename from 15-slices/exercises/01-declare-nil/solution/main.go rename to 16-slices/exercises/01-declare-nil/solution/main.go diff --git a/15-slices/exercises/02-empty/main.go b/16-slices/exercises/02-empty/main.go similarity index 100% rename from 15-slices/exercises/02-empty/main.go rename to 16-slices/exercises/02-empty/main.go diff --git a/15-slices/exercises/02-empty/solution/main.go b/16-slices/exercises/02-empty/solution/main.go similarity index 100% rename from 15-slices/exercises/02-empty/solution/main.go rename to 16-slices/exercises/02-empty/solution/main.go diff --git a/15-slices/exercises/03-slice-literal/main.go b/16-slices/exercises/03-slice-literal/main.go similarity index 100% rename from 15-slices/exercises/03-slice-literal/main.go rename to 16-slices/exercises/03-slice-literal/main.go diff --git a/15-slices/exercises/03-slice-literal/solution/main.go b/16-slices/exercises/03-slice-literal/solution/main.go similarity index 100% rename from 15-slices/exercises/03-slice-literal/solution/main.go rename to 16-slices/exercises/03-slice-literal/solution/main.go diff --git a/15-slices/exercises/04-declare-arrays-as-slices/main.go b/16-slices/exercises/04-declare-arrays-as-slices/main.go similarity index 100% rename from 15-slices/exercises/04-declare-arrays-as-slices/main.go rename to 16-slices/exercises/04-declare-arrays-as-slices/main.go diff --git a/15-slices/exercises/04-declare-arrays-as-slices/solution/main.go b/16-slices/exercises/04-declare-arrays-as-slices/solution/main.go similarity index 100% rename from 15-slices/exercises/04-declare-arrays-as-slices/solution/main.go rename to 16-slices/exercises/04-declare-arrays-as-slices/solution/main.go diff --git a/15-slices/exercises/05-fix-the-problems/main.go b/16-slices/exercises/05-fix-the-problems/main.go similarity index 100% rename from 15-slices/exercises/05-fix-the-problems/main.go rename to 16-slices/exercises/05-fix-the-problems/main.go diff --git a/15-slices/exercises/05-fix-the-problems/solution/main.go b/16-slices/exercises/05-fix-the-problems/solution/main.go similarity index 100% rename from 15-slices/exercises/05-fix-the-problems/solution/main.go rename to 16-slices/exercises/05-fix-the-problems/solution/main.go diff --git a/15-slices/exercises/06-compare-the-slices/main.go b/16-slices/exercises/06-compare-the-slices/main.go similarity index 100% rename from 15-slices/exercises/06-compare-the-slices/main.go rename to 16-slices/exercises/06-compare-the-slices/main.go diff --git a/15-slices/exercises/06-compare-the-slices/solution/main.go b/16-slices/exercises/06-compare-the-slices/solution/main.go similarity index 100% rename from 15-slices/exercises/06-compare-the-slices/solution/main.go rename to 16-slices/exercises/06-compare-the-slices/solution/main.go diff --git a/15-slices/exercises/07-append/main.go b/16-slices/exercises/07-append/main.go similarity index 100% rename from 15-slices/exercises/07-append/main.go rename to 16-slices/exercises/07-append/main.go diff --git a/15-slices/exercises/07-append/solution/main.go b/16-slices/exercises/07-append/solution/main.go similarity index 100% rename from 15-slices/exercises/07-append/solution/main.go rename to 16-slices/exercises/07-append/solution/main.go diff --git a/15-slices/exercises/08-append-2/main.go b/16-slices/exercises/08-append-2/main.go similarity index 100% rename from 15-slices/exercises/08-append-2/main.go rename to 16-slices/exercises/08-append-2/main.go diff --git a/15-slices/exercises/08-append-2/solution/main.go b/16-slices/exercises/08-append-2/solution/main.go similarity index 100% rename from 15-slices/exercises/08-append-2/solution/main.go rename to 16-slices/exercises/08-append-2/solution/main.go diff --git a/15-slices/exercises/09-append-3-fix/main.go b/16-slices/exercises/09-append-3-fix/main.go similarity index 100% rename from 15-slices/exercises/09-append-3-fix/main.go rename to 16-slices/exercises/09-append-3-fix/main.go diff --git a/15-slices/exercises/09-append-3-fix/solution/main.go b/16-slices/exercises/09-append-3-fix/solution/main.go similarity index 100% rename from 15-slices/exercises/09-append-3-fix/solution/main.go rename to 16-slices/exercises/09-append-3-fix/solution/main.go diff --git a/16-slices/exercises/README.md b/16-slices/exercises/README.md new file mode 100644 index 0000000..d03b9d5 --- /dev/null +++ b/16-slices/exercises/README.md @@ -0,0 +1,25 @@ +# Slice Exercises + +## Exercises Level I - Basics β€” Warm-Up + +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 + +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)** \ No newline at end of file diff --git a/15-slices/questions/1-slices-vs-arrays.md b/16-slices/questions/1-slices-vs-arrays.md similarity index 100% rename from 15-slices/questions/1-slices-vs-arrays.md rename to 16-slices/questions/1-slices-vs-arrays.md diff --git a/15-slices/questions/2-appending.md b/16-slices/questions/2-appending.md similarity index 100% rename from 15-slices/questions/2-appending.md rename to 16-slices/questions/2-appending.md diff --git a/15-slices/questions/README.md b/16-slices/questions/README.md similarity index 100% rename from 15-slices/questions/README.md rename to 16-slices/questions/README.md diff --git a/x-tba/slices/07-slice-expressions/1-theory/main.go b/x-tba/slices/07-slice-expressions/1-theory/main.go deleted file mode 100644 index 6951b2b..0000000 --- a/x-tba/slices/07-slice-expressions/1-theory/main.go +++ /dev/null @@ -1,38 +0,0 @@ -// For more tutorials: https://blog.learngoprogramming.com -// -// Copyright Β© 2018 Inanc Gumus -// Learn Go Programming Course -// License: https://creativecommons.org/licenses/by-nc-sa/4.0/ -// - -package main - -import ( - s "github.com/inancgumus/prettyslice" -) - -func main() { - msg := []byte{'h', 'e', 'l', 'l', 'o'} - s.Show("msg", msg) - - s.Show("msg[0:1]", msg[0:1]) - s.Show("msg[0:2]", msg[0:2]) - s.Show("msg[0:3]", msg[0:3]) - s.Show("msg[0:4]", msg[0:4]) - s.Show("msg[0:5]", msg[0:5]) - - // default indexes - s.Show("msg[0:]", msg[0:]) - s.Show("msg[:5]", msg[:5]) - s.Show("msg[:]", msg[:]) - - // error: beyond - // s.Show("msg", msg)[:6] - - s.Show("msg[1:4]", msg[1:4]) - - s.Show("msg[1:5]", msg[1:5]) - s.Show("msg[1:]", msg[1:]) - - s.Show("append(msg)", append(msg[:4], '!')) -} diff --git a/x-tba/slices/07-slice-expressions/2-example/main.go b/x-tba/slices/07-slice-expressions/2-example/main.go deleted file mode 100644 index b30172b..0000000 --- a/x-tba/slices/07-slice-expressions/2-example/main.go +++ /dev/null @@ -1,59 +0,0 @@ -// For more tutorials: https://blog.learngoprogramming.com -// -// Copyright Β© 2018 Inanc Gumus -// Learn Go Programming Course -// License: https://creativecommons.org/licenses/by-nc-sa/4.0/ -// - -package main - -import ( - "fmt" - - s "github.com/inancgumus/prettyslice" -) - -func main() { - // think of this as search results of a search engine. - // it could have been fetched from a database - items := []string{ - "pacman", - "mario", - "tetris", - "doom", - "galaga", - "frogger", - "asteroids", - "simcity", - "metroid", - "defender", - "rayman", - "tempest", - "ultima", - } - - s.MaxPerLine = 4 - s.Show("All items", items) - - top3 := items[:3] - s.Show("Top 3 items", top3) - - l := len(items) - - // you can use variables in a slice expression - last4 := items[l-4:] - s.Show("Last 4 items", last4) - - // reslicing: slicing another sliced slice - mid := last4[1:3] - s.Show("Last4[1:3]", mid) - - // the same elements can be in different indexes - // fmt.Println(items[9], last4[0]) - - // slicing returns a slice with the same type of the sliced slice - fmt.Printf("slicing : %T %[1]q\n", items[2:3]) - - // indexing returns a single element with the type of the indexed slice's element type - fmt.Printf("indexing: %T %[1]q\n", items[2]) -} diff --git a/x-tba/slices/08-slice-expressions-pagination/main.go b/x-tba/slices/08-slice-expressions-pagination/main.go deleted file mode 100644 index 531407b..0000000 --- a/x-tba/slices/08-slice-expressions-pagination/main.go +++ /dev/null @@ -1,58 +0,0 @@ -// For more tutorials: https://blog.learngoprogramming.com -// -// Copyright Β© 2018 Inanc Gumus -// Learn Go Programming Course -// License: https://creativecommons.org/licenses/by-nc-sa/4.0/ -// - -package main - -import ( - "fmt" - - s "github.com/inancgumus/prettyslice" -) - -func main() { - // think of this as search results of a search engine. - // it could have been fetched from a database - items := []string{ - "pacman", - "mario", - "tetris", - "doom", - "galaga", - "frogger", - "asteroids", - "simcity", - "metroid", - "defender", - "rayman", - "tempest", - "ultima", - } - - // s.Show("0:4", items[0:4]) - // s.Show("4:8", items[4:8]) - // s.Show("8:12", items[8:12]) - // s.Show("12:13", items[12:13]) - // s.Show("12:14", items[12:14]) // error - - l := len(items) - - const pageSize = 4 - - for from := 0; from < l; from += pageSize { - to := from + pageSize - if to > l { - to = l - } - - // fmt.Printf("%d:%d\n", from, to) - - currentPage := items[from:to] - - head := fmt.Sprintf("Page #%d", (from/pageSize)+1) - s.Show(head, currentPage) - } -} diff --git a/x-tba/slices/13-png-parser/2-png-anatomy-example.md b/x-tba/slices/13-png-parser/2-png-anatomy-example.md deleted file mode 100644 index 7d4df1a..0000000 --- a/x-tba/slices/13-png-parser/2-png-anatomy-example.md +++ /dev/null @@ -1,26 +0,0 @@ -# The Brief Anatomy of a PNG image - -``` -The first 24 bytes: - -PNG HEADER: -╔═════╗╔════╗╔════╗╔════╗╔════╗╔════╗╔════╗╔════╗ -β•‘ 137 β•‘β•‘ 80 β•‘β•‘ 78 β•‘β•‘ 71 β•‘β•‘ 13 β•‘β•‘ 10 β•‘β•‘ 26 β•‘β•‘ 10 β•‘ -β•šβ•β•β•β•β•β•β•šβ•β•β•β•β•β•šβ•β•β•β•β•β•šβ•β•β•β•β•β•šβ•β•β•β•β•β•šβ•β•β•β•β•β•šβ•β•β•β•β•β•šβ•β•β•β•β• - 0 1 2 3 4 5 6 7 - -CHUNK LENGTH CHUNK TYPE (IHDR) -╔═══╗╔═══╗╔═══╗╔════╗╔════╗╔════╗╔════╗╔════╗ -β•‘ 0 β•‘β•‘ 0 β•‘β•‘ 0 β•‘β•‘ 13 β•‘β•‘ 73 β•‘β•‘ 72 β•‘β•‘ 68 β•‘β•‘ 82 β•‘ -β•šβ•β•β•β•β•šβ•β•β•β•β•šβ•β•β•β•β•šβ•β•β•β•β•β•šβ•β•β•β•β•β•šβ•β•β•β•β•β•šβ•β•β•β•β•β•šβ•β•β•β•β• - 8 9 10 11 12 13 14 15 - -( Unsigned 32-bit integers ) -WIDTH HEIGHT -╔═══╗╔═══╗╔═══╗╔════╗╔═══╗╔═══╗╔═══╗╔════╗ -β•‘ 0 β•‘β•‘ 0 β•‘β•‘ 2 β•‘β•‘ 76 β•‘β•‘ 0 β•‘β•‘ 0 β•‘β•‘ 3 β•‘β•‘ 32 β•‘ -β•šβ•β•β•β•β•šβ•β•β•β•β•šβ•β•β•β•β•šβ•β•β•β•β•β•šβ•β•β•β•β•šβ•β•β•β•β•šβ•β•β•β•β•šβ•β•β•β•β• - 16 17 18 19 20 21 22 23 - -... Other bytes in the png image ... -``` \ No newline at end of file diff --git a/15-slices/06-empty-file-finder-project-reading-empty-files/files/empty1.txt b/x-tba/slices/19-empty-file-finder-project/1st-version-reading-empty-files/files/empty1.txt similarity index 100% rename from 15-slices/06-empty-file-finder-project-reading-empty-files/files/empty1.txt rename to x-tba/slices/19-empty-file-finder-project/1st-version-reading-empty-files/files/empty1.txt diff --git a/15-slices/06-empty-file-finder-project-reading-empty-files/files/empty2.txt b/x-tba/slices/19-empty-file-finder-project/1st-version-reading-empty-files/files/empty2.txt similarity index 100% rename from 15-slices/06-empty-file-finder-project-reading-empty-files/files/empty2.txt rename to x-tba/slices/19-empty-file-finder-project/1st-version-reading-empty-files/files/empty2.txt diff --git a/15-slices/06-empty-file-finder-project-reading-empty-files/files/empty3.txt b/x-tba/slices/19-empty-file-finder-project/1st-version-reading-empty-files/files/empty3.txt similarity index 100% rename from 15-slices/06-empty-file-finder-project-reading-empty-files/files/empty3.txt rename to x-tba/slices/19-empty-file-finder-project/1st-version-reading-empty-files/files/empty3.txt diff --git a/15-slices/06-empty-file-finder-project-reading-empty-files/files/nonEmpty1.txt b/x-tba/slices/19-empty-file-finder-project/1st-version-reading-empty-files/files/nonEmpty1.txt similarity index 100% rename from 15-slices/06-empty-file-finder-project-reading-empty-files/files/nonEmpty1.txt rename to x-tba/slices/19-empty-file-finder-project/1st-version-reading-empty-files/files/nonEmpty1.txt diff --git a/15-slices/06-empty-file-finder-project-reading-empty-files/files/nonEmpty2.txt b/x-tba/slices/19-empty-file-finder-project/1st-version-reading-empty-files/files/nonEmpty2.txt similarity index 100% rename from 15-slices/06-empty-file-finder-project-reading-empty-files/files/nonEmpty2.txt rename to x-tba/slices/19-empty-file-finder-project/1st-version-reading-empty-files/files/nonEmpty2.txt diff --git a/15-slices/06-empty-file-finder-project-reading-empty-files/files/nonEmpty3.txt b/x-tba/slices/19-empty-file-finder-project/1st-version-reading-empty-files/files/nonEmpty3.txt similarity index 100% rename from 15-slices/06-empty-file-finder-project-reading-empty-files/files/nonEmpty3.txt rename to x-tba/slices/19-empty-file-finder-project/1st-version-reading-empty-files/files/nonEmpty3.txt diff --git a/15-slices/06-empty-file-finder-project-reading-empty-files/main.go b/x-tba/slices/19-empty-file-finder-project/1st-version-reading-empty-files/main.go similarity index 100% rename from 15-slices/06-empty-file-finder-project-reading-empty-files/main.go rename to x-tba/slices/19-empty-file-finder-project/1st-version-reading-empty-files/main.go diff --git a/15-slices/07-empty-file-finder-project-writing-to-a-file/files/empty1.txt b/x-tba/slices/19-empty-file-finder-project/2nd-version-writing-to-a-file/files/empty1.txt similarity index 100% rename from 15-slices/07-empty-file-finder-project-writing-to-a-file/files/empty1.txt rename to x-tba/slices/19-empty-file-finder-project/2nd-version-writing-to-a-file/files/empty1.txt diff --git a/15-slices/07-empty-file-finder-project-writing-to-a-file/files/empty2.txt b/x-tba/slices/19-empty-file-finder-project/2nd-version-writing-to-a-file/files/empty2.txt similarity index 100% rename from 15-slices/07-empty-file-finder-project-writing-to-a-file/files/empty2.txt rename to x-tba/slices/19-empty-file-finder-project/2nd-version-writing-to-a-file/files/empty2.txt diff --git a/15-slices/07-empty-file-finder-project-writing-to-a-file/files/empty3.txt b/x-tba/slices/19-empty-file-finder-project/2nd-version-writing-to-a-file/files/empty3.txt similarity index 100% rename from 15-slices/07-empty-file-finder-project-writing-to-a-file/files/empty3.txt rename to x-tba/slices/19-empty-file-finder-project/2nd-version-writing-to-a-file/files/empty3.txt diff --git a/15-slices/07-empty-file-finder-project-writing-to-a-file/files/nonEmpty1.txt b/x-tba/slices/19-empty-file-finder-project/2nd-version-writing-to-a-file/files/nonEmpty1.txt similarity index 100% rename from 15-slices/07-empty-file-finder-project-writing-to-a-file/files/nonEmpty1.txt rename to x-tba/slices/19-empty-file-finder-project/2nd-version-writing-to-a-file/files/nonEmpty1.txt diff --git a/15-slices/07-empty-file-finder-project-writing-to-a-file/files/nonEmpty2.txt b/x-tba/slices/19-empty-file-finder-project/2nd-version-writing-to-a-file/files/nonEmpty2.txt similarity index 100% rename from 15-slices/07-empty-file-finder-project-writing-to-a-file/files/nonEmpty2.txt rename to x-tba/slices/19-empty-file-finder-project/2nd-version-writing-to-a-file/files/nonEmpty2.txt diff --git a/15-slices/07-empty-file-finder-project-writing-to-a-file/files/nonEmpty3.txt b/x-tba/slices/19-empty-file-finder-project/2nd-version-writing-to-a-file/files/nonEmpty3.txt similarity index 100% rename from 15-slices/07-empty-file-finder-project-writing-to-a-file/files/nonEmpty3.txt rename to x-tba/slices/19-empty-file-finder-project/2nd-version-writing-to-a-file/files/nonEmpty3.txt diff --git a/15-slices/07-empty-file-finder-project-writing-to-a-file/main.go b/x-tba/slices/19-empty-file-finder-project/2nd-version-writing-to-a-file/main.go similarity index 100% rename from 15-slices/07-empty-file-finder-project-writing-to-a-file/main.go rename to x-tba/slices/19-empty-file-finder-project/2nd-version-writing-to-a-file/main.go diff --git a/15-slices/exercises/10-append-4-sort-to-a-file/main.go b/x-tba/slices/19-empty-file-finder-project/exercises/1-sort-to-a-file/main.go similarity index 95% rename from 15-slices/exercises/10-append-4-sort-to-a-file/main.go rename to x-tba/slices/19-empty-file-finder-project/exercises/1-sort-to-a-file/main.go index f2079a6..71eb476 100644 --- a/15-slices/exercises/10-append-4-sort-to-a-file/main.go +++ b/x-tba/slices/19-empty-file-finder-project/exercises/1-sort-to-a-file/main.go @@ -1,7 +1,7 @@ package main // --------------------------------------------------------- -// EXERCISE: Append #4 β€” Sort to a file +// EXERCISE: Sort to a file // // 1. Get arguments from command-line // diff --git a/15-slices/exercises/10-append-4-sort-to-a-file/solution/main.go b/x-tba/slices/19-empty-file-finder-project/exercises/1-sort-to-a-file/solution/main.go similarity index 100% rename from 15-slices/exercises/10-append-4-sort-to-a-file/solution/main.go rename to x-tba/slices/19-empty-file-finder-project/exercises/1-sort-to-a-file/solution/main.go diff --git a/15-slices/exercises/11-append-5-sort-to-a-file/main.go b/x-tba/slices/19-empty-file-finder-project/exercises/2-sort-to-a-file-2/main.go similarity index 95% rename from 15-slices/exercises/11-append-5-sort-to-a-file/main.go rename to x-tba/slices/19-empty-file-finder-project/exercises/2-sort-to-a-file-2/main.go index 315e51b..84e7954 100644 --- a/15-slices/exercises/11-append-5-sort-to-a-file/main.go +++ b/x-tba/slices/19-empty-file-finder-project/exercises/2-sort-to-a-file-2/main.go @@ -8,7 +8,7 @@ import ( ) // --------------------------------------------------------- -// EXERCISE: Append #5 β€” Sort to a file with ordinals +// EXERCISE: Sort to a file with ordinals // // Use the previous exercise: Append #4 // diff --git a/15-slices/exercises/11-append-5-sort-to-a-file/solution/main.go b/x-tba/slices/19-empty-file-finder-project/exercises/2-sort-to-a-file-2/solution/main.go similarity index 100% rename from 15-slices/exercises/11-append-5-sort-to-a-file/solution/main.go rename to x-tba/slices/19-empty-file-finder-project/exercises/2-sort-to-a-file-2/solution/main.go diff --git a/15-slices/exercises/12-append-6-print-directories/main.go b/x-tba/slices/19-empty-file-finder-project/exercises/3-print-directories/main.go similarity index 96% rename from 15-slices/exercises/12-append-6-print-directories/main.go rename to x-tba/slices/19-empty-file-finder-project/exercises/3-print-directories/main.go index 03a005e..11f3153 100644 --- a/15-slices/exercises/12-append-6-print-directories/main.go +++ b/x-tba/slices/19-empty-file-finder-project/exercises/3-print-directories/main.go @@ -1,7 +1,7 @@ package main // --------------------------------------------------------- -// EXERCISE: Append #6 β€” Print the directories +// EXERCISE: Print the directories // // Create a program that can get multiple directory paths from // the command-line, and prints only their subdirectories into a diff --git a/15-slices/exercises/12-append-6-print-directories/solution/dir/.gitignore b/x-tba/slices/19-empty-file-finder-project/exercises/3-print-directories/solution/dir/.gitignore similarity index 100% rename from 15-slices/exercises/12-append-6-print-directories/solution/dir/.gitignore rename to x-tba/slices/19-empty-file-finder-project/exercises/3-print-directories/solution/dir/.gitignore diff --git a/15-slices/exercises/12-append-6-print-directories/solution/dir/subdir1/.gitignore b/x-tba/slices/19-empty-file-finder-project/exercises/3-print-directories/solution/dir/subdir1/.gitignore similarity index 100% rename from 15-slices/exercises/12-append-6-print-directories/solution/dir/subdir1/.gitignore rename to x-tba/slices/19-empty-file-finder-project/exercises/3-print-directories/solution/dir/subdir1/.gitignore diff --git a/15-slices/exercises/12-append-6-print-directories/solution/dir/subdir2/.gitignore b/x-tba/slices/19-empty-file-finder-project/exercises/3-print-directories/solution/dir/subdir2/.gitignore similarity index 100% rename from 15-slices/exercises/12-append-6-print-directories/solution/dir/subdir2/.gitignore rename to x-tba/slices/19-empty-file-finder-project/exercises/3-print-directories/solution/dir/subdir2/.gitignore diff --git a/15-slices/exercises/12-append-6-print-directories/solution/dir2/.gitignore b/x-tba/slices/19-empty-file-finder-project/exercises/3-print-directories/solution/dir2/.gitignore similarity index 100% rename from 15-slices/exercises/12-append-6-print-directories/solution/dir2/.gitignore rename to x-tba/slices/19-empty-file-finder-project/exercises/3-print-directories/solution/dir2/.gitignore diff --git a/15-slices/exercises/12-append-6-print-directories/solution/dir2/subdir1/.gitignore b/x-tba/slices/19-empty-file-finder-project/exercises/3-print-directories/solution/dir2/subdir1/.gitignore similarity index 100% rename from 15-slices/exercises/12-append-6-print-directories/solution/dir2/subdir1/.gitignore rename to x-tba/slices/19-empty-file-finder-project/exercises/3-print-directories/solution/dir2/subdir1/.gitignore diff --git a/15-slices/exercises/12-append-6-print-directories/solution/dir2/subdir2/.gitignore b/x-tba/slices/19-empty-file-finder-project/exercises/3-print-directories/solution/dir2/subdir2/.gitignore similarity index 100% rename from 15-slices/exercises/12-append-6-print-directories/solution/dir2/subdir2/.gitignore rename to x-tba/slices/19-empty-file-finder-project/exercises/3-print-directories/solution/dir2/subdir2/.gitignore diff --git a/15-slices/exercises/12-append-6-print-directories/solution/dir2/subdir3/.gitignore b/x-tba/slices/19-empty-file-finder-project/exercises/3-print-directories/solution/dir2/subdir3/.gitignore similarity index 100% rename from 15-slices/exercises/12-append-6-print-directories/solution/dir2/subdir3/.gitignore rename to x-tba/slices/19-empty-file-finder-project/exercises/3-print-directories/solution/dir2/subdir3/.gitignore diff --git a/15-slices/exercises/12-append-6-print-directories/solution/dirs.txt b/x-tba/slices/19-empty-file-finder-project/exercises/3-print-directories/solution/dirs.txt similarity index 100% rename from 15-slices/exercises/12-append-6-print-directories/solution/dirs.txt rename to x-tba/slices/19-empty-file-finder-project/exercises/3-print-directories/solution/dirs.txt diff --git a/15-slices/exercises/12-append-6-print-directories/solution/main.go b/x-tba/slices/19-empty-file-finder-project/exercises/3-print-directories/solution/main.go similarity index 100% rename from 15-slices/exercises/12-append-6-print-directories/solution/main.go rename to x-tba/slices/19-empty-file-finder-project/exercises/3-print-directories/solution/main.go diff --git a/x-tba/slices/19-empty-file-finder-project/exercises/README.md b/x-tba/slices/19-empty-file-finder-project/exercises/README.md new file mode 100644 index 0000000..942cec5 --- /dev/null +++ b/x-tba/slices/19-empty-file-finder-project/exercises/README.md @@ -0,0 +1,7 @@ +# File Append Exercises + +1. **[Sort and write items to a file](https://github.com/inancgumus/learngo/tree/master/15-slices/19-empty-file-finder-project/exercises/1-sort-to-a-file)** + +2. **[Sort and write items to a file with their ordinals](https://github.com/inancgumus/learngo/tree/master/15-slices/19-empty-file-finder-project/exercises/2-sort-to-a-file)** + +3. **[Find and write the names of subdirectories to a file](https://github.com/inancgumus/learngo/tree/master/15-slices/19-empty-file-finder-project/exercises/3-print-directories)** \ No newline at end of file diff --git a/x-tba/slices/13-png-parser/1-png-anatomy-format.md b/x-tba/slices/20-png-parser-project/1-png-anatomy-format.md similarity index 59% rename from x-tba/slices/13-png-parser/1-png-anatomy-format.md rename to x-tba/slices/20-png-parser-project/1-png-anatomy-format.md index 53eb0a8..52b10ee 100644 --- a/x-tba/slices/13-png-parser/1-png-anatomy-format.md +++ b/x-tba/slices/20-png-parser-project/1-png-anatomy-format.md @@ -4,14 +4,14 @@ The first 24 bytes: +=================================+ -| PNG Header | 8 bytes | -> 137 80 78 71 13 10 26 10 +| PNG Header | 8 bytes | -> 89 50 4e 47 0d 0a 1a 0a +---------------------+-----------+ | IHDR Chunk Header | | | Chunk Length | 4 bytes | -> The length of the IHDR Chunk Data -| Chunk Type | 4 bytes | -> 73 72 68 82 +| Chunk Type | 4 bytes | -> 49 48 44 52 +---------------------+-----------+ | IHDR Chunk Data | | -| Width | 4 bytes | -> Unsigned 32-bit integer -| Height | 4 bytes | -> Unsigned 32-bit integer +| Width | 4 bytes | -> uint32 β€” big endian +| Height | 4 bytes | -> uint32 β€” big endian +=================================+ ``` \ No newline at end of file diff --git a/x-tba/slices/20-png-parser-project/2-png-anatomy-example.md b/x-tba/slices/20-png-parser-project/2-png-anatomy-example.md new file mode 100644 index 0000000..d6165e2 --- /dev/null +++ b/x-tba/slices/20-png-parser-project/2-png-anatomy-example.md @@ -0,0 +1,26 @@ +# The Brief Anatomy of a PNG image + +``` +The first 24 bytes: +(all numbers are uint32 big-endian) + +PNG HEADER +╔════╗╔════╗╔════╗╔════╗╔════╗╔════╗╔════╗╔════╗ +β•‘ 89 β•‘β•‘ 50 β•‘β•‘ 4e β•‘β•‘ 47 β•‘β•‘ 0d β•‘β•‘ 0a β•‘β•‘ 1a β•‘β•‘ 0a β•‘ +β•šβ•β•β•β•β•β•šβ•β•β•β•β•β•šβ•β•β•β•β•β•šβ•β•β•β•β•β•šβ•β•β•β•β•β•šβ•β•β•β•β•β•šβ•β•β•β•β•β•šβ•β•β•β•β• + 0 1 2 3 4 5 6 7 + +CHUNK LENGTH CHUNK TYPE (IHDR) +╔════╗╔════╗╔════╗╔════╗╔════╗╔════╗╔════╗╔════╗ +β•‘ 00 β•‘β•‘ 00 β•‘β•‘ 00 β•‘β•‘ 0d β•‘β•‘ 49 β•‘β•‘ 48 β•‘β•‘ 44 β•‘β•‘ 52 β•‘ +β•šβ•β•β•β•β•β•šβ•β•β•β•β•β•šβ•β•β•β•β•β•šβ•β•β•β•β•β•šβ•β•β•β•β•β•šβ•β•β•β•β•β•šβ•β•β•β•β•β•šβ•β•β•β•β• + 8 9 10 11 12 13 14 15 + +WIDTH HEIGHT +╔════╗╔════╗╔════╗╔════╗╔════╗╔════╗╔════╗╔════╗ +β•‘ 00 β•‘β•‘ 00 β•‘β•‘ 02 β•‘β•‘ 4c β•‘β•‘ 00 β•‘β•‘ 00 β•‘β•‘ 03 β•‘β•‘ 20 β•‘ +β•šβ•β•β•β•β•β•šβ•β•β•β•β•β•šβ•β•β•β•β•β•šβ•β•β•β•β•β•šβ•β•β•β•β•β•šβ•β•β•β•β•β•šβ•β•β•β•β•β•šβ•β•β•β•β• + 16 17 18 19 20 21 22 23 + +... rest of the bytes in the png image ... +``` \ No newline at end of file diff --git a/x-tba/slices/13-png-parser/images/broken-missing-ihdr.png b/x-tba/slices/20-png-parser-project/images/broken-missing-ihdr.png similarity index 100% rename from x-tba/slices/13-png-parser/images/broken-missing-ihdr.png rename to x-tba/slices/20-png-parser-project/images/broken-missing-ihdr.png diff --git a/x-tba/slices/13-png-parser/images/broken-missing-png-header.png b/x-tba/slices/20-png-parser-project/images/broken-missing-png-header.png similarity index 100% rename from x-tba/slices/13-png-parser/images/broken-missing-png-header.png rename to x-tba/slices/20-png-parser-project/images/broken-missing-png-header.png diff --git a/x-tba/slices/13-png-parser/images/gopher.png b/x-tba/slices/20-png-parser-project/images/gopher.png similarity index 100% rename from x-tba/slices/13-png-parser/images/gopher.png rename to x-tba/slices/20-png-parser-project/images/gopher.png diff --git a/x-tba/slices/13-png-parser/main.go b/x-tba/slices/20-png-parser-project/main.go similarity index 80% rename from x-tba/slices/13-png-parser/main.go rename to x-tba/slices/20-png-parser-project/main.go index 6431060..ce91f6c 100644 --- a/x-tba/slices/13-png-parser/main.go +++ b/x-tba/slices/20-png-parser-project/main.go @@ -6,16 +6,10 @@ import ( "fmt" "io/ioutil" "os" - - ps "github.com/inancgumus/prettyslice" + "runtime" ) func main() { - var ( - pngHeader = [...]byte{137, 80, 78, 71, 13, 10, 26, 10} - ihdrChunkType = [...]byte{73, 72, 68, 82} - ) - args := os.Args[1:] if len(args) == 0 { fmt.Println("run with a PNG file") @@ -31,10 +25,19 @@ func main() { return } - // limit the capacity to prevent the errors downward - // 'cause we only need the first 24 bytes + img = append([]byte(nil), img[:24]...) img = img[:24:24] - // ps.Show("first 24 bytes", img) + + // s.PrintBacking = true + // s.MaxPerLine = 8 + // s.MaxElements = 24 + // s.PrintBytesHex = true + // s.Show("first 24 bytes", img) + + var ( + pngHeader = [...]byte{0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a} + ihdrChunkType = [...]byte{0x49, 0x48, 0x44, 0x52} + ) // ------------------------------------------ // Read the PNG header @@ -78,9 +81,9 @@ func main() { binary.BigEndian.Uint32(ihdr[4:8])) } -func init() { - ps.PrintBacking = true - ps.PrettyByteRune = false - ps.MaxPerLine = 8 - ps.MaxElements = 32 +func report() { + var m runtime.MemStats + runtime.GC() + runtime.ReadMemStats(&m) + fmt.Printf(" > Memory Usage: %v KB\n", m.Alloc/1024) } diff --git a/x-tba/slices/19-bouncing-ball-challenge/01-solution-draw-the-board/main.go b/x-tba/slices/21-bouncing-ball-project/01-solution-draw-the-board/main.go similarity index 100% rename from x-tba/slices/19-bouncing-ball-challenge/01-solution-draw-the-board/main.go rename to x-tba/slices/21-bouncing-ball-project/01-solution-draw-the-board/main.go diff --git a/x-tba/slices/19-bouncing-ball-challenge/02-solution-drawing-loop/main.go b/x-tba/slices/21-bouncing-ball-project/02-solution-drawing-loop/main.go similarity index 100% rename from x-tba/slices/19-bouncing-ball-challenge/02-solution-drawing-loop/main.go rename to x-tba/slices/21-bouncing-ball-project/02-solution-drawing-loop/main.go diff --git a/x-tba/slices/19-bouncing-ball-challenge/03-solution-final/main.go b/x-tba/slices/21-bouncing-ball-project/03-solution-final/main.go similarity index 100% rename from x-tba/slices/19-bouncing-ball-challenge/03-solution-final/main.go rename to x-tba/slices/21-bouncing-ball-project/03-solution-final/main.go diff --git a/x-tba/slices/19-bouncing-ball-challenge/04-solution-final-optimize/main.go b/x-tba/slices/21-bouncing-ball-project/04-solution-final-optimize/main.go similarity index 100% rename from x-tba/slices/19-bouncing-ball-challenge/04-solution-final-optimize/main.go rename to x-tba/slices/21-bouncing-ball-project/04-solution-final-optimize/main.go diff --git a/x-tba/slices/19-bouncing-ball-challenge/README.md b/x-tba/slices/21-bouncing-ball-project/README.md similarity index 100% rename from x-tba/slices/19-bouncing-ball-challenge/README.md rename to x-tba/slices/21-bouncing-ball-project/README.md