From 9e3b244f88f2f5e7c479222894973c8ccbe98e20 Mon Sep 17 00:00:00 2001 From: Droid-An Date: Thu, 10 Jul 2025 19:24:40 +0100 Subject: [PATCH 1/6] done cat --- individual-shell-tools/cat/script-01.sh | 1 + individual-shell-tools/cat/script-02.sh | 1 + individual-shell-tools/cat/script-03.sh | 1 + individual-shell-tools/cat/script-04-stretch.sh | 1 + 4 files changed, 4 insertions(+) diff --git a/individual-shell-tools/cat/script-01.sh b/individual-shell-tools/cat/script-01.sh index c85053e0..1a63b662 100755 --- a/individual-shell-tools/cat/script-01.sh +++ b/individual-shell-tools/cat/script-01.sh @@ -4,3 +4,4 @@ set -euo pipefail # TODO: Write a command to output the contents of the helper-1.txt file inside the helper-files directory to the terminal. # The output of this command should be "Once upon a time...". +cat ../ls/child-directory/helper-1.txt \ No newline at end of file diff --git a/individual-shell-tools/cat/script-02.sh b/individual-shell-tools/cat/script-02.sh index 01bbd5ea..16a490a3 100755 --- a/individual-shell-tools/cat/script-02.sh +++ b/individual-shell-tools/cat/script-02.sh @@ -11,3 +11,4 @@ set -euo pipefail # It looked delicious. # I was tempted to take a bite of it. # But this seemed like a bad idea... +cat ../ls/child-directory/*.txt \ No newline at end of file diff --git a/individual-shell-tools/cat/script-03.sh b/individual-shell-tools/cat/script-03.sh index 37573b0c..e3886b58 100755 --- a/individual-shell-tools/cat/script-03.sh +++ b/individual-shell-tools/cat/script-03.sh @@ -9,3 +9,4 @@ set -euo pipefail # 1 It looked delicious. # 2 I was tempted to take a bite of it. # 3 But this seemed like a bad idea... +cat -n ../ls/child-directory/helper-3.txt \ No newline at end of file diff --git a/individual-shell-tools/cat/script-04-stretch.sh b/individual-shell-tools/cat/script-04-stretch.sh index 00fe3c48..252eb3b5 100755 --- a/individual-shell-tools/cat/script-04-stretch.sh +++ b/individual-shell-tools/cat/script-04-stretch.sh @@ -13,3 +13,4 @@ set -euo pipefail # 3 It looked delicious. # 4 I was tempted to take a bite of it. # 5 But this seemed like a bad idea... +# cat -n ../ls/child-directory/* <<------ not working From 1d28fee52d200a9de079b8e46451dd67e7688a56 Mon Sep 17 00:00:00 2001 From: Droid-An Date: Thu, 10 Jul 2025 19:28:20 +0100 Subject: [PATCH 2/6] done stretch --- individual-shell-tools/cat/script-04-stretch.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/individual-shell-tools/cat/script-04-stretch.sh b/individual-shell-tools/cat/script-04-stretch.sh index 252eb3b5..855275d1 100755 --- a/individual-shell-tools/cat/script-04-stretch.sh +++ b/individual-shell-tools/cat/script-04-stretch.sh @@ -13,4 +13,4 @@ set -euo pipefail # 3 It looked delicious. # 4 I was tempted to take a bite of it. # 5 But this seemed like a bad idea... -# cat -n ../ls/child-directory/* <<------ not working +cat ../ls/child-directory/* | nl From b19297c4b95fdc4f0f79bb34259137c2932b2918 Mon Sep 17 00:00:00 2001 From: Droid-An Date: Fri, 11 Jul 2025 17:23:57 +0100 Subject: [PATCH 3/6] Revert "done stretch" This reverts commit 1d28fee52d200a9de079b8e46451dd67e7688a56. --- individual-shell-tools/cat/script-04-stretch.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/individual-shell-tools/cat/script-04-stretch.sh b/individual-shell-tools/cat/script-04-stretch.sh index 855275d1..252eb3b5 100755 --- a/individual-shell-tools/cat/script-04-stretch.sh +++ b/individual-shell-tools/cat/script-04-stretch.sh @@ -13,4 +13,4 @@ set -euo pipefail # 3 It looked delicious. # 4 I was tempted to take a bite of it. # 5 But this seemed like a bad idea... -cat ../ls/child-directory/* | nl +# cat -n ../ls/child-directory/* <<------ not working From ccd9af75ea1c727dc2dc9eef3e950411029241fc Mon Sep 17 00:00:00 2001 From: Droid-An Date: Fri, 11 Jul 2025 17:26:10 +0100 Subject: [PATCH 4/6] Revert "done cat" This reverts commit 9e3b244f88f2f5e7c479222894973c8ccbe98e20. --- individual-shell-tools/cat/script-01.sh | 1 - individual-shell-tools/cat/script-02.sh | 1 - individual-shell-tools/cat/script-03.sh | 1 - individual-shell-tools/cat/script-04-stretch.sh | 1 - 4 files changed, 4 deletions(-) diff --git a/individual-shell-tools/cat/script-01.sh b/individual-shell-tools/cat/script-01.sh index 1a63b662..c85053e0 100755 --- a/individual-shell-tools/cat/script-01.sh +++ b/individual-shell-tools/cat/script-01.sh @@ -4,4 +4,3 @@ set -euo pipefail # TODO: Write a command to output the contents of the helper-1.txt file inside the helper-files directory to the terminal. # The output of this command should be "Once upon a time...". -cat ../ls/child-directory/helper-1.txt \ No newline at end of file diff --git a/individual-shell-tools/cat/script-02.sh b/individual-shell-tools/cat/script-02.sh index 16a490a3..01bbd5ea 100755 --- a/individual-shell-tools/cat/script-02.sh +++ b/individual-shell-tools/cat/script-02.sh @@ -11,4 +11,3 @@ set -euo pipefail # It looked delicious. # I was tempted to take a bite of it. # But this seemed like a bad idea... -cat ../ls/child-directory/*.txt \ No newline at end of file diff --git a/individual-shell-tools/cat/script-03.sh b/individual-shell-tools/cat/script-03.sh index e3886b58..37573b0c 100755 --- a/individual-shell-tools/cat/script-03.sh +++ b/individual-shell-tools/cat/script-03.sh @@ -9,4 +9,3 @@ set -euo pipefail # 1 It looked delicious. # 2 I was tempted to take a bite of it. # 3 But this seemed like a bad idea... -cat -n ../ls/child-directory/helper-3.txt \ No newline at end of file diff --git a/individual-shell-tools/cat/script-04-stretch.sh b/individual-shell-tools/cat/script-04-stretch.sh index 252eb3b5..00fe3c48 100755 --- a/individual-shell-tools/cat/script-04-stretch.sh +++ b/individual-shell-tools/cat/script-04-stretch.sh @@ -13,4 +13,3 @@ set -euo pipefail # 3 It looked delicious. # 4 I was tempted to take a bite of it. # 5 But this seemed like a bad idea... -# cat -n ../ls/child-directory/* <<------ not working From 6a2932e7f66e6df82c0b6eb8fedb990938f8824b Mon Sep 17 00:00:00 2001 From: Andrei Filippov Date: Fri, 11 Jul 2025 18:37:14 +0100 Subject: [PATCH 5/6] done exercises --- number-systems/README.md | 56 ++++++++++++++++++++++++++-------------- 1 file changed, 36 insertions(+), 20 deletions(-) diff --git a/number-systems/README.md b/number-systems/README.md index 77a3bde9..6fdab188 100644 --- a/number-systems/README.md +++ b/number-systems/README.md @@ -5,61 +5,77 @@ Do not convert any binary numbers to decimal when solving a question unless the The goal of these exercises is for you to gain an intuition for binary numbers. Using tools to solve the problems defeats the point. Convert the decimal number 14 to binary. -Answer: +``` +14 is equals 8 + 4 + 2 + 0 +``` +Answer: 1110 Convert the binary number 101101 to decimal: -Answer: +``` +32 + 0 + 8 + 4 + 0 + 1 +``` +Answer: 45 Which is larger: 1000 or 0111? -Answer: +Answer: 1000 Which is larger: 00100 or 01011? -Answer: +Answer: 01011 What is 10101 + 01010? -Answer: +Answer: 11111 What is 10001 + 10001? -Answer: +Answer: 100010 What's the largest number you can store with 4 bits, if you want to be able to represent the number 0? -Answer: +Answer: 15 How many bits would you need in order to store the numbers between 0 and 255 inclusive? -Answer: +Answer: 7 How many bits would you need in order to store the numbers between 0 and 3 inclusive? -Answer: +Answer: 2 How many bits would you need in order to store the numbers between 0 and 1000 inclusive? -Answer: +Answer: 9 How can you test if a binary number is a power of two (e.g. 1, 2, 4, 8, 16, ...)? -Answer: +Answer: If the number have only one '1' digit at the start and other digits are 0 - the number is a power of two Convert the decimal number 14 to hex. -Answer: +Answer: F Convert the decimal number 386 to hex. -Answer: +``` +386 / 16 = 24 reminder 2 +24 / 16 = 1 remider 8 +``` +Answer: 182 Convert the hex number 386 to decimal. -Answer: +``` +3 * 16^2 = 3 * 256 = 768 +8 * 16^1 = 128 +6 * 16^0 = 6 +768 + 128 + 6 = 902 +``` +Answer: 902 Convert the hex number B to decimal. -Answer: +Answer: 11 If reading the byte 0x21 as a number, what decimal number would it mean? -Answer: +Answer: 33 If reading the byte 0x21 as an ASCII character, what character would it mean? -Answer: +Answer: ! If reading the byte 0x21 as a greyscale colour, as described in "Approaches for Representing Colors and Images", what colour would it mean? -Answer: +Answer: Gray colour with light intensity equals 33 If reading the bytes 0xAA00FF as an RGB colour, as described in "Approaches for Representing Colors and Images", what colour would it mean? -Answer: +Answer: Shade of purple, since this number represent the mix of red an blue colour, without green If reading the bytes 0xAA00FF as a sequence of three one-byte decimal numbers, what decimal numbers would they be? -Answer: +Answer: 170 , 0, 255 From 9e9d514483f0115f1deb416fe092eb3f17541084 Mon Sep 17 00:00:00 2001 From: Andrei Filippov Date: Tue, 22 Jul 2025 16:52:00 +0100 Subject: [PATCH 6/6] Update README.md --- number-systems/README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/number-systems/README.md b/number-systems/README.md index 6fdab188..57b96a7e 100644 --- a/number-systems/README.md +++ b/number-systems/README.md @@ -32,19 +32,19 @@ What's the largest number you can store with 4 bits, if you want to be able to r Answer: 15 How many bits would you need in order to store the numbers between 0 and 255 inclusive? -Answer: 7 +Answer: 8 How many bits would you need in order to store the numbers between 0 and 3 inclusive? Answer: 2 How many bits would you need in order to store the numbers between 0 and 1000 inclusive? -Answer: 9 +Answer: 10 How can you test if a binary number is a power of two (e.g. 1, 2, 4, 8, 16, ...)? Answer: If the number have only one '1' digit at the start and other digits are 0 - the number is a power of two Convert the decimal number 14 to hex. -Answer: F +Answer: E Convert the decimal number 386 to hex. ```