summaryrefslogtreecommitdiff
path: root/comp
diff options
context:
space:
mode:
authorthing1 <thing1@seacrossedlovers.xyz>2025-04-02 10:26:21 +0000
committerthing1 <thing1@seacrossedlovers.xyz>2025-04-02 10:26:21 +0000
commitfef6d2cc76518eee75fc0d95e765bd2be8a660ee (patch)
treed9886424f7d18d86ad1f4c73613b7e23b64b0434 /comp
parent5b73c7157aad4d65eee7af41fd4b4ded1a434b96 (diff)
did comp sci and some electronics
Diffstat (limited to 'comp')
-rw-r--r--comp/work/53/sheet68
-rw-r--r--comp/work/54/#hash.py#21
-rw-r--r--comp/work/54/#ques#4
-rw-r--r--comp/work/54/hash.py21
-rw-r--r--comp/work/54/ques3
-rw-r--r--comp/work/54/rpn.py21
6 files changed, 138 insertions, 0 deletions
diff --git a/comp/work/53/sheet b/comp/work/53/sheet
new file mode 100644
index 0000000..45058ac
--- /dev/null
+++ b/comp/work/53/sheet
@@ -0,0 +1,68 @@
+12.1)
+head | 1
+tail | [2, 3, 4]
+
+12.2)
+[2, 4, 6, 8]
+
+12.3)
+I fisrt put the list into the function map, because the list was not empty, I used the second definition.
+I applied f to the head of the list, then I applied map onto the tail of the list.
+Because the tail was not empty I repeated this again.
+I repeated this until I got an empty list
+Then the most recent call to map returns, and gets conncatinated to the second to last function calling f on x.
+This repeates as the call stack collapses, leaving behind the list, with all values having f applied to x
+
+8.1)
+WHO KNOWS
+
+8.2)
+36
+
+8.3) to apply a function onto a list in a specific order.
+
+6.1)
+10
+
+6.2)
+map square a | [1, 9, 25]
+filter (<10) b | [1, 5]
+fold (+) 0 c | 18
+
+6.3)
+A function that takes another function as an argument or a returns function as a result
+
+15.1)
+3
+
+15.2)
+fw [4, 3] | 12
+fx sales | [20, 50, 32]
+fz sales | 102
+
+15.3)
+This is the total of sales, the amount sold in a day perhaps
+
+7.1)
+NO CLUE
+
+7.2)
+4
+
+7.3)
+plus4 = add 4
+result = plus4 6
+'
+11.1)
+head | "Blackpool"
+tail | ["Paris", "New Brighton", "Toronto"]
+
+11.2)
+A function that takes another function as an argument or a returns function as a result
+
+11.3)
+(((1 * 2) * 3) * 2)
+((2 * 3) * 2)
+(6 * 2)
+(12)
+12
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 +")