From 9f69078142cb0722ddd5c3264af0af5c12d50541 Mon Sep 17 00:00:00 2001 From: katarzynakaz Date: Sat, 15 Nov 2025 00:19:35 +0000 Subject: [PATCH 1/6] number systems done --- number-systems/README.md | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/number-systems/README.md b/number-systems/README.md index 77a3bde94..4f546c78e 100644 --- a/number-systems/README.md +++ b/number-systems/README.md @@ -5,61 +5,61 @@ 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: +Answer:1110 Convert the binary number 101101 to decimal: -Answer: +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:1111 so 15 How many bits would you need in order to store the numbers between 0 and 255 inclusive? -Answer: +Answer:8 as 2 **8 = 256 0-255 How many bits would you need in order to store the numbers between 0 and 3 inclusive? -Answer: +Answer: 2 **2 0 1 2 3 How many bits would you need in order to store the numbers between 0 and 1000 inclusive? -Answer: +Answer:2** 10 = 1024 so 10 How can you test if a binary number is a power of two (e.g. 1, 2, 4, 8, 16, ...)? -Answer: +Answer: number /2 until it reaches 1, check remainder at each division Convert the decimal number 14 to hex. -Answer: +Answer: E Convert the decimal number 386 to hex. -Answer: +Answer:0x182 863/16 =24 %2 24/16=1 %8 Convert the hex number 386 to decimal. -Answer: +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:33 intensity so grey dark 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:RGB(170, 0, 255) 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 abb6c89836553b3a33bec4ac927dc2a3ec9cb3db Mon Sep 17 00:00:00 2001 From: katarzynakaz Date: Sun, 22 Feb 2026 14:18:20 +0000 Subject: [PATCH 2/6] cat, ls and wc tasks compelted --- .DS_Store | Bin 0 -> 10244 bytes implement-shell-tools/.DS_Store | Bin 0 -> 6148 bytes implement-shell-tools/cat/cat.py | 44 +++++++++++++++++++++++++ implement-shell-tools/ls/ls.py | 34 ++++++++++++++++++++ implement-shell-tools/wc/wc.py | 53 +++++++++++++++++++++++++++++++ 5 files changed, 131 insertions(+) create mode 100644 .DS_Store create mode 100644 implement-shell-tools/.DS_Store create mode 100644 implement-shell-tools/cat/cat.py create mode 100644 implement-shell-tools/ls/ls.py create mode 100644 implement-shell-tools/wc/wc.py diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..c681e567ab1b50ebc22e100f45553eb3958324e7 GIT binary patch literal 10244 zcmeHMTWl0n7(U;$zzoA>sO2h~-CDVoC2Y%G6qaqP+{&ff(hHYmcW0m@)0wg}yQMbO z`lJCh@kQhPji?W(Q51bL@tznT2ofbGnwXe)dC`EHm>B;vXST5m#PHBS%*^JT|D6B) z|C#;2{lA&~XBlHi74=5OVvI4F8kgEM>aKC|b>6PJq(C#7B*>pJgY{Fhna5UKWgRL) z1VRKt1VRKt1VRLE1qA4w%`aIMGVDVHLIgqt#t`7ohZr?3lYtx+(tmVN=a&E^t4Zx& zG^RSh_lX5E8OTu~eOKC3R1XMT5tJAZ?zA4`<|LDW92HWyGYEHv;LZpt6!>>1znE{% zkQ6fPLj*zuu10{@?z5Rmb^8Fb#?|jG>!Z0vpA}TkJM^)bn;Ucoa+Z@LuXDKp%XGa& z;v%G~>PeHQ$WvrhKA7%v2Gd^FE4ry{VLzXBIF6MokF&XbrZJe&YMUL~%bK=P@EuIu zAd>@KrmZ`JDW_=buJ4-`3$h|B8ExM1aMSw6cx=tO#7I0gyrC%(kF8#{c4S16XV^%jeM1gnZ9jn-H)5@%T*2)*j*w|uOY4ZVLoi8|+wa0Ny z&vfjbZqGR3@io5DxTWr1*C}|-{$|}K?Julq_&s(HaA$X)QE*8r%9$B+qjxS{(X{UF zWb3wF?H6Whvue~@bxv2wbj_S)bPk%j*VmJE^My|V28x}@hjwd$tlj4gKZMa{HJCJ}*t1HlKmzMP5m$p$g3 zf4}drKk_lIPbP%AR*12lzZ@eh!BT8HJ48esVyD?QUVJImf?AF(gkMfMH*f&I#U zV^`Sk>@QSfDr&J1i?9Ssu?$UEg*8}(INz0@LX}PpX z+AM9A_Da1{M(PtWNM$k}9E-^xNJAuU;PFFb3?4tynQN0Vdf(P<+js1|Wy$#U3{Jn> zYG==x8(Y+{a`pOqwu~jI$mwz#|C=5@BgXN_XM~?MmDwzKszy7BGRBGP(N&wmsV!gN z)^&HNQEd{DN=z3oq3L8Il$b7$N28iVJQmYLV^r0uh^30}yCzOk1d|PSsj5~@d=+b( zA~a>eB-KpYaQ4X)#e>h-dG;0ij{QPB_#0J_F&8l`Mx63~6OxqsEoi0O--C9f(Sd`= zAd4I^!Gete97h4e7{Nmr#lysd$M86wz|(k!xbQr&;WS>xD|i)e;w;|5IlSw$;&Xh7 zOZdJb&)df5IWFH=o|n=E+j8uq>cCh|E<^m|9=9%LAZ5@K#0K2MgY|<>6R3Ii*l7-`GxpddyLv)YW(7MqeA*F z)cMEpB>m%fn(*WJrPR1>aH`>tlYwqjNZ*}oe0P%KG=IYX47hoRabf)**8l%~%wAC+ IPelFy5AW{;)Bpeg literal 0 HcmV?d00001 diff --git a/implement-shell-tools/.DS_Store b/implement-shell-tools/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..1d079c52ea9b4d3e418ccadb5d8e0d247b4c3489 GIT binary patch literal 6148 zcmeHK%SyvQ6rHivrW7Fyg)Rr&7EJ3KHzC#^Fro{UnwX-&m?=$a7NwB2{*Yhd_jvEj z1T1DPV(*2SbDuMr1DOY7jC-@F&zQ{^v!EezRB8m>wV^eWjL30}Y!W6i1nVQ5nAl$j z{PqTWU;)d+;`{d}ah5yICtqtc*Ed>L%j#Hn{*x^HJjiF67ff%^x|A{rD?JFW;&Cyu zx6Wjm2XQ){s)9HgL(1)SoJO+nAfPW@0>Hq1q^p8DE>MR&*I=m;M?t?T Q2c(ODB7{0(;1?M90!2tkWB>pF literal 0 HcmV?d00001 diff --git a/implement-shell-tools/cat/cat.py b/implement-shell-tools/cat/cat.py new file mode 100644 index 000000000..b866e9d34 --- /dev/null +++ b/implement-shell-tools/cat/cat.py @@ -0,0 +1,44 @@ +import sys +from pathlib import Path + +def cleanInput(listOfFiles): + cleanLinesArr = [] + + for file in listOfFiles: + grabbedText = Path(file).read_text(encoding="utf-8") + splitLines = grabbedText.split("\n") + cleanLinesArr.extend(splitLines) + + return cleanLinesArr + +args = sys.argv[1:] +flag = None +restIsFiles = [] + +if len(args) > 0 and args[0] and args[0][0] == "-": + flag = args[0] + restIsFiles = args[1:] +else: + flag = None + restIsFiles = args + +def takeSpecifiedAction(cleanLinesArr, flag): + countingOnlyFullLines = 1 + + for file in cleanLinesArr: + if not flag: + print(file) + elif flag == "-n": + print(f"{countingOnlyFullLines} {file}") + countingOnlyFullLines += 1 + elif flag == "-b": + if file == "": + print("") + else: + print(f"{countingOnlyFullLines} {file}") + countingOnlyFullLines += 1 + else: + print("incorrect flag") + +lines = cleanInput(restIsFiles) +takeSpecifiedAction(lines, flag) \ No newline at end of file diff --git a/implement-shell-tools/ls/ls.py b/implement-shell-tools/ls/ls.py new file mode 100644 index 000000000..f3cbabb2e --- /dev/null +++ b/implement-shell-tools/ls/ls.py @@ -0,0 +1,34 @@ +import sys +import os + +# `ls -1` +def showAllFilesInDir(directory): + listOfFiles = os.listdir(directory) + + for eachFile in listOfFiles: + if eachFile[0] != ".": + print(eachFile) + +# `ls -1 sample-files` +def showVisibleInSampleFiles(): + listOfFiles = os.listdir("sample-files") + + for eachFile in listOfFiles: + if eachFile[0] != ".": + print(eachFile) + +# `ls -1 -a sample-files` +def showAllInSampleFiles(): + listOfFiles = os.listdir("sample-files") + + for eachFile in listOfFiles: + print(eachFile) + +argv = sys.argv[1:] + +if "-a" in argv: + showAllInSampleFiles() +elif "sample-files" in argv: + showVisibleInSampleFiles() +else: + showAllFilesInDir(".") \ No newline at end of file diff --git a/implement-shell-tools/wc/wc.py b/implement-shell-tools/wc/wc.py new file mode 100644 index 000000000..b91bd73d0 --- /dev/null +++ b/implement-shell-tools/wc/wc.py @@ -0,0 +1,53 @@ +import sys +from pathlib import Path + +def calculateCounts(inputFiles): + return { + "lines": len(inputFiles.split("\n")) - 1, + "words": len(inputFiles.split()), + "bytes": len(inputFiles), + } + +# * `wc -l sample-files/3.txt` +# * `wc -l sample-files/*` +def countLines(listOfFiles): + for file in listOfFiles: + content = Path(file).read_text(encoding="utf-8") + + counts = calculateCounts(content) + print(f"{counts['lines']} {file}") + +# * `wc -w sample-files/3.txt` +def countWords(listOfFiles): + for file in listOfFiles: + content = Path(file).read_text(encoding="utf-8") + + # const wordsCounted = content.split(" ").filter(word => word !== "").length; + counts = calculateCounts(content) + print(f"{counts['words']} {file}") + +# * `wc -c sample-files/3.txt` +def countBytes(listOfFiles): + for file in listOfFiles: + content = Path(file).read_text(encoding="utf-8") + counts = calculateCounts(content) + print(f"{counts['bytes']} {file}") + +# * `wc sample-files/*` +def countAll(listOfFiles): + for file in listOfFiles: + content = Path(file).read_text(encoding="utf-8") + counts = calculateCounts(content) + print(f"{counts['lines']} {counts['words']} {counts['bytes']} {file}") + +argv = sys.argv[1:] +files = [arg for arg in argv if not arg.startswith("-")] + +if "-l" in argv: + countLines(files) +elif "-w" in argv: + countWords(files) +elif "-c" in argv: + countBytes(files) +else: + countAll(files) \ No newline at end of file From 15f45490815a3211f11bd155378a5147a50fe037 Mon Sep 17 00:00:00 2001 From: katarzynakaz Date: Mon, 2 Mar 2026 08:56:47 +0000 Subject: [PATCH 3/6] Remove tracked .DS_Store files --- .DS_Store | Bin 10244 -> 0 bytes implement-shell-tools/.DS_Store | Bin 6148 -> 0 bytes 2 files changed, 0 insertions(+), 0 deletions(-) delete mode 100644 .DS_Store delete mode 100644 implement-shell-tools/.DS_Store diff --git a/.DS_Store b/.DS_Store deleted file mode 100644 index c681e567ab1b50ebc22e100f45553eb3958324e7..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 10244 zcmeHMTWl0n7(U;$zzoA>sO2h~-CDVoC2Y%G6qaqP+{&ff(hHYmcW0m@)0wg}yQMbO z`lJCh@kQhPji?W(Q51bL@tznT2ofbGnwXe)dC`EHm>B;vXST5m#PHBS%*^JT|D6B) z|C#;2{lA&~XBlHi74=5OVvI4F8kgEM>aKC|b>6PJq(C#7B*>pJgY{Fhna5UKWgRL) z1VRKt1VRKt1VRLE1qA4w%`aIMGVDVHLIgqt#t`7ohZr?3lYtx+(tmVN=a&E^t4Zx& zG^RSh_lX5E8OTu~eOKC3R1XMT5tJAZ?zA4`<|LDW92HWyGYEHv;LZpt6!>>1znE{% zkQ6fPLj*zuu10{@?z5Rmb^8Fb#?|jG>!Z0vpA}TkJM^)bn;Ucoa+Z@LuXDKp%XGa& z;v%G~>PeHQ$WvrhKA7%v2Gd^FE4ry{VLzXBIF6MokF&XbrZJe&YMUL~%bK=P@EuIu zAd>@KrmZ`JDW_=buJ4-`3$h|B8ExM1aMSw6cx=tO#7I0gyrC%(kF8#{c4S16XV^%jeM1gnZ9jn-H)5@%T*2)*j*w|uOY4ZVLoi8|+wa0Ny z&vfjbZqGR3@io5DxTWr1*C}|-{$|}K?Julq_&s(HaA$X)QE*8r%9$B+qjxS{(X{UF zWb3wF?H6Whvue~@bxv2wbj_S)bPk%j*VmJE^My|V28x}@hjwd$tlj4gKZMa{HJCJ}*t1HlKmzMP5m$p$g3 zf4}drKk_lIPbP%AR*12lzZ@eh!BT8HJ48esVyD?QUVJImf?AF(gkMfMH*f&I#U zV^`Sk>@QSfDr&J1i?9Ssu?$UEg*8}(INz0@LX}PpX z+AM9A_Da1{M(PtWNM$k}9E-^xNJAuU;PFFb3?4tynQN0Vdf(P<+js1|Wy$#U3{Jn> zYG==x8(Y+{a`pOqwu~jI$mwz#|C=5@BgXN_XM~?MmDwzKszy7BGRBGP(N&wmsV!gN z)^&HNQEd{DN=z3oq3L8Il$b7$N28iVJQmYLV^r0uh^30}yCzOk1d|PSsj5~@d=+b( zA~a>eB-KpYaQ4X)#e>h-dG;0ij{QPB_#0J_F&8l`Mx63~6OxqsEoi0O--C9f(Sd`= zAd4I^!Gete97h4e7{Nmr#lysd$M86wz|(k!xbQr&;WS>xD|i)e;w;|5IlSw$;&Xh7 zOZdJb&)df5IWFH=o|n=E+j8uq>cCh|E<^m|9=9%LAZ5@K#0K2MgY|<>6R3Ii*l7-`GxpddyLv)YW(7MqeA*F z)cMEpB>m%fn(*WJrPR1>aH`>tlYwqjNZ*}oe0P%KG=IYX47hoRabf)**8l%~%wAC+ IPelFy5AW{;)Bpeg diff --git a/implement-shell-tools/.DS_Store b/implement-shell-tools/.DS_Store deleted file mode 100644 index 1d079c52ea9b4d3e418ccadb5d8e0d247b4c3489..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeHK%SyvQ6rHivrW7Fyg)Rr&7EJ3KHzC#^Fro{UnwX-&m?=$a7NwB2{*Yhd_jvEj z1T1DPV(*2SbDuMr1DOY7jC-@F&zQ{^v!EezRB8m>wV^eWjL30}Y!W6i1nVQ5nAl$j z{PqTWU;)d+;`{d}ah5yICtqtc*Ed>L%j#Hn{*x^HJjiF67ff%^x|A{rD?JFW;&Cyu zx6Wjm2XQ){s)9HgL(1)SoJO+nAfPW@0>Hq1q^p8DE>MR&*I=m;M?t?T Q2c(ODB7{0(;1?M90!2tkWB>pF From cb9b93b28c8835bd704354d27b86cfdfc40ee857 Mon Sep 17 00:00:00 2001 From: katarzynakaz Date: Mon, 2 Mar 2026 08:57:15 +0000 Subject: [PATCH 4/6] task completed --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 3c3629e64..7ef75e11b 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,4 @@ node_modules +.DS_Store +.DS_Store +**/.DS_Store From 2ee678b3bed1d0e5f7a717eeb28b76d600e87056 Mon Sep 17 00:00:00 2001 From: katarzynakaz Date: Mon, 2 Mar 2026 09:37:57 +0000 Subject: [PATCH 5/6] cat, la and wc changes done, removed other sprint work --- implement-shell-tools/cat/cat.py | 41 +++++++++++++------------ implement-shell-tools/ls/ls.py | 25 +++++++++------- implement-shell-tools/wc/wc.py | 51 ++++++++------------------------ number-systems/README.md | 20 ------------- 4 files changed, 49 insertions(+), 88 deletions(-) diff --git a/implement-shell-tools/cat/cat.py b/implement-shell-tools/cat/cat.py index b866e9d34..686fe8ed0 100644 --- a/implement-shell-tools/cat/cat.py +++ b/implement-shell-tools/cat/cat.py @@ -6,39 +6,42 @@ def cleanInput(listOfFiles): for file in listOfFiles: grabbedText = Path(file).read_text(encoding="utf-8") - splitLines = grabbedText.split("\n") + splitLines = grabbedText.splitlines() cleanLinesArr.extend(splitLines) return cleanLinesArr -args = sys.argv[1:] -flag = None -restIsFiles = [] - -if len(args) > 0 and args[0] and args[0][0] == "-": - flag = args[0] - restIsFiles = args[1:] -else: - flag = None - restIsFiles = args - def takeSpecifiedAction(cleanLinesArr, flag): countingOnlyFullLines = 1 - for file in cleanLinesArr: + if flag not in (None, "-n", "-b"): + print("incorrect flag") + return + + for line in cleanLinesArr: if not flag: - print(file) + print(line) elif flag == "-n": - print(f"{countingOnlyFullLines} {file}") + print(f"{countingOnlyFullLines} {line}") countingOnlyFullLines += 1 elif flag == "-b": - if file == "": + if line == "": print("") else: - print(f"{countingOnlyFullLines} {file}") + print(f"{countingOnlyFullLines} {line}") countingOnlyFullLines += 1 - else: - print("incorrect flag") + + +args = sys.argv[1:] +flag = None +restIsFiles = [] + +if len(args) > 0 and args[0] and args[0][0] == "-": + flag = args[0] + restIsFiles = args[1:] +else: + flag = None + restIsFiles = args lines = cleanInput(restIsFiles) takeSpecifiedAction(lines, flag) \ No newline at end of file diff --git a/implement-shell-tools/ls/ls.py b/implement-shell-tools/ls/ls.py index f3cbabb2e..1f85e729f 100644 --- a/implement-shell-tools/ls/ls.py +++ b/implement-shell-tools/ls/ls.py @@ -10,25 +10,30 @@ def showAllFilesInDir(directory): print(eachFile) # `ls -1 sample-files` -def showVisibleInSampleFiles(): - listOfFiles = os.listdir("sample-files") +def showVisibleInSampleFiles(directory): + listOfFiles = os.listdir(directory) for eachFile in listOfFiles: if eachFile[0] != ".": print(eachFile) # `ls -1 -a sample-files` -def showAllInSampleFiles(): - listOfFiles = os.listdir("sample-files") +def showAllInSampleFiles(directory): + listOfFiles = os.listdir(directory) for eachFile in listOfFiles: print(eachFile) argv = sys.argv[1:] -if "-a" in argv: - showAllInSampleFiles() -elif "sample-files" in argv: - showVisibleInSampleFiles() -else: - showAllFilesInDir(".") \ No newline at end of file +show_all = "-a" in argv + +directories = [arg for arg in argv if arg != "-a"] +if not directories: + directories = ["."] + +for directory in directories: + if show_all: + showAllInSampleFiles(directory) + else: + showVisibleInSampleFiles(directory) \ No newline at end of file diff --git a/implement-shell-tools/wc/wc.py b/implement-shell-tools/wc/wc.py index b91bd73d0..42738869f 100644 --- a/implement-shell-tools/wc/wc.py +++ b/implement-shell-tools/wc/wc.py @@ -1,53 +1,26 @@ import sys from pathlib import Path -def calculateCounts(inputFiles): - return { - "lines": len(inputFiles.split("\n")) - 1, - "words": len(inputFiles.split()), - "bytes": len(inputFiles), - } - -# * `wc -l sample-files/3.txt` -# * `wc -l sample-files/*` -def countLines(listOfFiles): - for file in listOfFiles: - content = Path(file).read_text(encoding="utf-8") - - counts = calculateCounts(content) - print(f"{counts['lines']} {file}") - -# * `wc -w sample-files/3.txt` -def countWords(listOfFiles): - for file in listOfFiles: - content = Path(file).read_text(encoding="utf-8") - - # const wordsCounted = content.split(" ").filter(word => word !== "").length; - counts = calculateCounts(content) - print(f"{counts['words']} {file}") - -# * `wc -c sample-files/3.txt` -def countBytes(listOfFiles): - for file in listOfFiles: - content = Path(file).read_text(encoding="utf-8") - counts = calculateCounts(content) - print(f"{counts['bytes']} {file}") - -# * `wc sample-files/*` -def countAll(listOfFiles): +def countAll(listOfFiles, flag=None): for file in listOfFiles: content = Path(file).read_text(encoding="utf-8") - counts = calculateCounts(content) - print(f"{counts['lines']} {counts['words']} {counts['bytes']} {file}") + if flag == "-l": + print(f"{len(content.splitlines())} {file}") + elif flag == "-w": + print(f"{len(content.split())} {file}") + elif flag == "-c": + print(f"{len(content)} {file}") + else: + print(f"{len(content.splitlines())} {len(content.split())} {len(content)} {file}") argv = sys.argv[1:] files = [arg for arg in argv if not arg.startswith("-")] if "-l" in argv: - countLines(files) + countAll(files, "-l") elif "-w" in argv: - countWords(files) + countAll(files, "-w") elif "-c" in argv: - countBytes(files) + countAll(files, "-c") else: countAll(files) \ No newline at end of file diff --git a/number-systems/README.md b/number-systems/README.md index 4f546c78e..5d8c78266 100644 --- a/number-systems/README.md +++ b/number-systems/README.md @@ -5,61 +5,41 @@ 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:1110 Convert the binary number 101101 to decimal: -Answer:45 Which is larger: 1000 or 0111? -Answer:1000 Which is larger: 00100 or 01011? -Answer:01011 What is 10101 + 01010? -Answer:11111 What is 10001 + 10001? -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:1111 so 15 How many bits would you need in order to store the numbers between 0 and 255 inclusive? -Answer:8 as 2 **8 = 256 0-255 How many bits would you need in order to store the numbers between 0 and 3 inclusive? -Answer: 2 **2 0 1 2 3 How many bits would you need in order to store the numbers between 0 and 1000 inclusive? -Answer:2** 10 = 1024 so 10 How can you test if a binary number is a power of two (e.g. 1, 2, 4, 8, 16, ...)? -Answer: number /2 until it reaches 1, check remainder at each division Convert the decimal number 14 to hex. -Answer: E Convert the decimal number 386 to hex. -Answer:0x182 863/16 =24 %2 24/16=1 %8 Convert the hex number 386 to decimal. -Answer:902 Convert the hex number B to decimal. -Answer:11 If reading the byte 0x21 as a number, what decimal number would it mean? -Answer: 33 If reading the byte 0x21 as an ASCII character, what character would it mean? -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:33 intensity so grey dark If reading the bytes 0xAA00FF as an RGB colour, as described in "Approaches for Representing Colors and Images", what colour would it mean? -Answer:RGB(170, 0, 255) If reading the bytes 0xAA00FF as a sequence of three one-byte decimal numbers, what decimal numbers would they be? -Answer: 170, 0, 255 From d32f791be599191fdf1b533e5e99bf8e6774d1c6 Mon Sep 17 00:00:00 2001 From: katarzynakaz Date: Wed, 4 Mar 2026 19:19:46 +0000 Subject: [PATCH 6/6] readme restored --- number-systems/README.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/number-systems/README.md b/number-systems/README.md index 5d8c78266..77a3bde94 100644 --- a/number-systems/README.md +++ b/number-systems/README.md @@ -5,41 +5,61 @@ 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: Convert the binary number 101101 to decimal: +Answer: Which is larger: 1000 or 0111? +Answer: Which is larger: 00100 or 01011? +Answer: What is 10101 + 01010? +Answer: What is 10001 + 10001? +Answer: What's the largest number you can store with 4 bits, if you want to be able to represent the number 0? +Answer: How many bits would you need in order to store the numbers between 0 and 255 inclusive? +Answer: How many bits would you need in order to store the numbers between 0 and 3 inclusive? +Answer: How many bits would you need in order to store the numbers between 0 and 1000 inclusive? +Answer: How can you test if a binary number is a power of two (e.g. 1, 2, 4, 8, 16, ...)? +Answer: Convert the decimal number 14 to hex. +Answer: Convert the decimal number 386 to hex. +Answer: Convert the hex number 386 to decimal. +Answer: Convert the hex number B to decimal. +Answer: If reading the byte 0x21 as a number, what decimal number would it mean? +Answer: If reading the byte 0x21 as an ASCII character, what character would it mean? +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: If reading the bytes 0xAA00FF as an RGB colour, as described in "Approaches for Representing Colors and Images", what colour would it mean? +Answer: If reading the bytes 0xAA00FF as a sequence of three one-byte decimal numbers, what decimal numbers would they be? +Answer: