From fef6d2cc76518eee75fc0d95e765bd2be8a660ee Mon Sep 17 00:00:00 2001 From: thing1 Date: Wed, 2 Apr 2025 10:26:21 +0000 Subject: did comp sci and some electronics --- comp/work/54/#hash.py# | 21 +++++++++++++++++++++ comp/work/54/#ques# | 4 ++++ comp/work/54/hash.py | 21 +++++++++++++++++++++ comp/work/54/ques | 3 +++ comp/work/54/rpn.py | 21 +++++++++++++++++++++ 5 files changed, 70 insertions(+) create mode 100644 comp/work/54/#hash.py# create mode 100644 comp/work/54/#ques# create mode 100644 comp/work/54/hash.py create mode 100644 comp/work/54/ques create mode 100644 comp/work/54/rpn.py (limited to 'comp/work/54') diff --git a/comp/work/54/#hash.py# b/comp/work/54/#hash.py# new file mode 100644 index 0000000..ad4859c --- /dev/null +++ b/comp/work/54/#hash.py# @@ -0,0 +1,21 @@ +def hash(string): + chunks = [] + for i in range(0, len(string), 3): + tmp = "" + for j in range(i, i + 3): + try: + tmp += string[j] + except: + break + chunks.append(tmp) + + chunks = map(int, chunks) + + print(sum(chunks) % 50) + + +inp = input("input a number: ") +if (len(inp) <= 10): + hash(inp) +else: + print("string is too long") diff --git a/comp/work/54/#ques# b/comp/work/54/#ques# new file mode 100644 index 0000000..4b586e3 --- /dev/null +++ b/comp/work/54/#ques# @@ -0,0 +1,4 @@ +1) address bus +2) Sending multiple bits of data down multiple wires, all at the same time, ensuring each bit is recieved at onces, it will be synced with a clock +3) Because it only required one wire (and a clock) to send data down it. This means the cables can be cheaper, smaller and simpler. It also means the deviecs can be simpler to make as they don't need to sync multiple line +y \ No newline at end of file diff --git a/comp/work/54/hash.py b/comp/work/54/hash.py new file mode 100644 index 0000000..6fae0ec --- /dev/null +++ b/comp/work/54/hash.py @@ -0,0 +1,21 @@ +def hash(string): + chunks = [] + for i in range(0, len(string), 3): + tmp = "" + for j in range(i, i + 3): + try: + tmp += string[j] + except: + break + chunks.append(tmp) + + chunks = map(int, chunks) + + print(sum(chunks) % 50) + + +inp = input("input a number: ") +if (len(inp) <= 10): + hash(inp) +else: + print("string is too long") diff --git a/comp/work/54/ques b/comp/work/54/ques new file mode 100644 index 0000000..ea3f92e --- /dev/null +++ b/comp/work/54/ques @@ -0,0 +1,3 @@ +1) address bus +2) Sending multiple bits of data down multiple wires, all at the same time, ensuring each bit is recieved at onces, it will be synced with a clock +3) Because it only required one wire (and a clock) to send data down it. This means the cables can be cheaper, smaller and simpler. It also means the deviecs can be simpler to make as they don't need to sync multiple lines. diff --git a/comp/work/54/rpn.py b/comp/work/54/rpn.py new file mode 100644 index 0000000..053a256 --- /dev/null +++ b/comp/work/54/rpn.py @@ -0,0 +1,21 @@ +def eval(expr): + s = [] + for i in expr.split(): + if i.isdigit(): + s.push(int(i)) + else: + a = s.pop() + b = s.pop() + match i: + case '+': + s.push(b + a) + case '-': + s.push(b - a) + case '*': + s.push(b * a) + case '/': + s.push(b / a) + + print(s.pop()) + +eval("1 2 +") -- cgit v1.2.3