Docs SEM 2
This commit is contained in:
commit
ed2b1d7fe8
Binary file not shown.
|
@ -0,0 +1,30 @@
|
|||
% Vraag 1
|
||||
|
||||
t=1:5;
|
||||
B = [t;t.^2;t.^3;t.^4;t.^5]
|
||||
det(B)
|
||||
|
||||
%C =B; C(4,:) = B(4,:) +7*B(3,:)
|
||||
%det(B) -det(C)
|
||||
|
||||
C = B(:,end:-1:1)
|
||||
det(B) - det(C)
|
||||
|
||||
% Vraag 2
|
||||
|
||||
t =(-1:0.1:1)';
|
||||
A = [ones(size(t)) t t.^2]
|
||||
b =(20:-1:0)'-t.^3
|
||||
|
||||
x1 = [10;-10.658;0]
|
||||
x2 = [-10;8.228;2]
|
||||
|
||||
(A*x1)'*(b- A*x1)
|
||||
(A*x2)'*(b- A*x2)
|
||||
% x1 is de kko
|
||||
|
||||
z1 = b - A*x1
|
||||
z2 = b - A*x2
|
||||
|
||||
z1'*z1
|
||||
z2'*z2
|
|
@ -0,0 +1,51 @@
|
|||
% 1
|
||||
|
||||
v = [2 -1 0 -1 3 -1 -2.5 1]'
|
||||
|
||||
u = v/sqrt(v'*v)
|
||||
|
||||
Q = eye(size(v*v')) - 2 * u*u'
|
||||
|
||||
Q'*Q -eye(length(u))
|
||||
Q'-inv(Q)
|
||||
inv(Q)-Q
|
||||
|
||||
|
||||
% 2
|
||||
a1 = [1 -2 1 0]'
|
||||
a2 = [1 2 -1 -2]'
|
||||
a3 = [-1 2 -1 1]'
|
||||
|
||||
A = [a1 a2 a3]
|
||||
rref(A)
|
||||
rank(A)
|
||||
% kolommen zijn l.o
|
||||
|
||||
b = [-2 -10 5 8]'
|
||||
|
||||
xhat = inv(A'*A)*A'*b % kleinste kwadraten opl
|
||||
|
||||
U = rref([A b])
|
||||
|
||||
% vraag 3
|
||||
x = [1;1;1]
|
||||
|
||||
% x[k] = A^k*x
|
||||
A = [0 0 3/4;1 0 -2;0 1 3/2]
|
||||
b= [1;3;2]
|
||||
c= [0 0 1]
|
||||
|
||||
T = 20;
|
||||
for k = 1:T,
|
||||
x = [x A*x(:,k)];
|
||||
end
|
||||
|
||||
plot(0:T, c*x)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
% 13 augustus examen matlabroot
|
||||
|
||||
|
||||
% Vraag 1
|
||||
|
||||
|
||||
N = 10
|
||||
k = (0:N-1)'
|
||||
|
||||
a = exp(i*2*pi*k/N)
|
||||
b = exp(i*4*pi*k/N)
|
||||
|
||||
c = zeros(N,1); c(2) = 1; c(3) = i;
|
||||
|
||||
Q = [a,b, conj(a), conj(b)]
|
||||
|
||||
D = Q'*Q % is een diagonaal matrix dus orthogonaal
|
||||
|
||||
na = sqrt(a'*a); % normeren
|
||||
nb = sqrt(b'*b);
|
||||
|
||||
V1 = [a/na conj(a)/na]
|
||||
V2 = [a/na conj(a)/na b/nb conj(b)/nb]
|
||||
|
||||
d1 = c - V1*V1'*c
|
||||
d2 = c - V2*V2'*c
|
||||
|
||||
sqrt(d1'*d2) % geeft 1.0954
|
||||
|
||||
% Vraag 2
|
||||
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
% Vraag 1
|
||||
|
||||
A = [0.1 -1 0;0 pi -0.2;0.7 -2 1/sqrt(2)]
|
||||
C = A
|
||||
norm(C(:,3))
|
||||
|
||||
for col=1:size(A,2)
|
||||
B = A;
|
||||
B(:,col)=norm(A(:,col)) * A(:, col)
|
||||
end
|
||||
|
||||
norm(B(:,3))
|
||||
|
||||
|
||||
% Vraag 2
|
||||
|
||||
a1 = [1 -2 1 0 3 -5]'
|
||||
a2 = [-1 0 3 1 2 4]'
|
||||
a3 = [3 -4 -1 2 -1 0]'
|
||||
a4 = [-10 10 10 -4 10 3]'
|
||||
|
||||
A = [a1 a2 a3 a4]
|
||||
rref(A)
|
||||
|
||||
% a4 is lin afh van de andere kolommen
|
||||
% gewichten: x = [1 2 -3]'
|
||||
x = [a1 a2 a3]\a4
|
||||
rank([a1 a2 a3])
|
||||
% a3 is niet te schrijven als een lineaire combinatie van zijn voorgangers want lin onafh
|
||||
|
||||
% 4
|
||||
|
||||
% qr geeft orthonormale kolommen
|
||||
|
||||
[Q, R] = qr([a1 a2 a3], 0)
|
||||
|
||||
|
||||
% Vraag 3
|
||||
A = [1 3;-1 -2;2 4;7 -3;-5 1]
|
||||
|
||||
P1 = A*inv(A'*A)*A'
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,52 @@
|
|||
t=(-1:0.1:1)';
|
||||
A=[ones(size(t)) t t.^2]
|
||||
b=(20:-1:0)'-t.^3
|
||||
|
||||
% Ax = b
|
||||
% als x1 een kleinste kwadratenopl is dan staat b-Ax1 loodrecht
|
||||
% op Ax1.
|
||||
|
||||
x1 = [10;-10.658;0]
|
||||
x2 = [-10;8.28;2]
|
||||
|
||||
|
||||
c = (b - A*x1 )'*(A*x1)
|
||||
d = (b - A*x2)'*(A*x2)
|
||||
|
||||
% c is ongeveer nul
|
||||
|
||||
%% vraag 2
|
||||
|
||||
A = [1 1/2 0
|
||||
1/2 2 -1/2
|
||||
0 -1/2 -3]
|
||||
|
||||
[V D] = eig(A)
|
||||
|
||||
[w, m] = max(diag(D))
|
||||
|
||||
argmax = V(:,m)
|
||||
|
||||
|
||||
%% vraag 3
|
||||
|
||||
t=-1:4
|
||||
B=[t;ones(size(t));cos(pi*t);cos(pi/2*t);t.^2]/10
|
||||
|
||||
C= zeros(size(B))
|
||||
|
||||
for k=1:size(B, 1) % k tot #rijen van B
|
||||
C(k,:) = 2 * B(k,:)/sqrt(B(k,:)*B(k,:)') % normeren van elke rij maal 2
|
||||
end
|
||||
|
||||
% Zonder for-loop
|
||||
|
||||
C = diag(1./sqrt(diag(B*B')))*B
|
||||
|
||||
|
||||
% Vraag 4
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
% Vraag 4
|
||||
clear all
|
||||
t=(-0.2:0.1:3)'
|
||||
B=[ones(size(t)) cos(pi*t) cos(pi/2*t).^2 sin(pi*t) sin(pi/2*t).^2]
|
||||
b=t.^2
|
||||
|
||||
|
||||
[U, S, V] = svd(B)
|
||||
|
||||
diag(S)
|
||||
r = 3
|
||||
|
||||
U1 = U(:,1:r) % orhonormale basis voor Col B
|
||||
U2 = U(:,r+1:end) % Nul B transpose; staat loodrecht op col B
|
||||
pCol = U1*U1'*b
|
||||
pNul = U2*U2'*b
|
||||
|
||||
% som v/d beide projecties moet nul zijn.
|
||||
|
||||
b- pCol - pNul
|
||||
|
Binary file not shown.
|
@ -0,0 +1,7 @@
|
|||
dict_vakken = {"Thermodynamica":"H01B4B",
|
||||
"Algemene en technische scheikunde":"H01A8A"}
|
||||
|
||||
dict_vakken["Methodiek van de informatica"] = "H01B6"
|
||||
|
||||
code_thermo = dict_vakken["Thermodynamica"]
|
||||
print(code_thermo)
|
|
@ -0,0 +1,10 @@
|
|||
num = int(input("Geef een getal: "))
|
||||
|
||||
num_dict = {
|
||||
1:"een",
|
||||
2:"twee",
|
||||
3:"drie"
|
||||
#...
|
||||
}
|
||||
|
||||
print(num_dict[num])
|
|
@ -0,0 +1,9 @@
|
|||
dict_klas = {"klas":
|
||||
{"student":
|
||||
{"name":"Mike"
|
||||
,"percentages":
|
||||
{"fysica":70,"geschiedenis":80}
|
||||
}}}
|
||||
|
||||
|
||||
print(dict_klas["klas"]["student"]["percentages"]["geschiedenis"])
|
|
@ -0,0 +1,14 @@
|
|||
import re
|
||||
|
||||
text = input(">")
|
||||
|
||||
def nospecial(text):
|
||||
|
||||
text = re.sub("[^a-zA-Z0-9 ]+", "", text)
|
||||
return text
|
||||
|
||||
|
||||
text = nospecial(text)
|
||||
text = text.split()
|
||||
zinnen_set = set(text)
|
||||
print(zinnen_set)
|
|
@ -0,0 +1,43 @@
|
|||
import string
|
||||
|
||||
"""
|
||||
In cryptografie is caesar cipher een encryptietechniek
|
||||
waarin elke letter in het alfabet vervangen wordt door
|
||||
een letter die een aantal posities verder in het alfabet
|
||||
staat. In dit geval implementeren we ROT-13, waarbij elke
|
||||
letter dertien plaatsen opschuift. Een a zou bijvoorbeeld
|
||||
een n worden. Schrijf hiervoor een encoder en decoder en
|
||||
vertaal/codeer hiermee de volgende twee berichten:
|
||||
Pnrfne pvcure? V zhpu cersre Pnrfne fnynq!
|
||||
Gebruik voor deze opgave een dictionary!
|
||||
"""
|
||||
|
||||
|
||||
def build_shift_dict(shift):
|
||||
alphabet = string.ascii_lowercase + string.ascii_uppercase
|
||||
|
||||
shifted_lower = string.ascii_lowercase[shift:] + string.ascii_lowercase[0:shift]
|
||||
shifted_upper = string.ascii_uppercase[shift:] + string.ascii_uppercase[0:shift]
|
||||
|
||||
shifted_alphabet = shifted_lower + shifted_upper
|
||||
|
||||
return {key: value for key, value in zip(alphabet, shifted_alphabet)}
|
||||
|
||||
|
||||
def apply_shift(shift, message):
|
||||
dictionary = build_shift_dict(shift)
|
||||
|
||||
for letter in message:
|
||||
for letter in dictionary.values():
|
||||
print(letter)
|
||||
|
||||
|
||||
|
||||
|
||||
message = "Pnrfne pvcure? V zhpu cersre Pnrfne fnynq!"
|
||||
shift = 13
|
||||
vertaling = apply_shift(shift, message)
|
||||
print(vertaling)
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
set1 = {10, 20, 30, 40, 50}
|
||||
set2 = {30, 40, 50, 60, 70}
|
||||
|
||||
intersect = set1.intersection(set2)
|
||||
print(intersect)
|
|
@ -0,0 +1,27 @@
|
|||
file = open("survey.txt", "r")
|
||||
list1 = ["Bel", "Eng", "Ger", "Fra", "Ita", "Spa","Cam"]# hiermee open je het bestand enkel om het te lezen
|
||||
my_set = set()
|
||||
count = 0
|
||||
for line in file.readlines(): # hiermee lees je het bestand lijn per lijn
|
||||
line = line.strip()
|
||||
line_split = line.split()
|
||||
for i in line_split:
|
||||
my_set.add(i)
|
||||
|
||||
for team in line_split:
|
||||
if team == "Bel" or "Ger":
|
||||
count += 1
|
||||
|
||||
print("aantal fans: ",count)
|
||||
|
||||
for woord in list1:
|
||||
if woord not in my_set:
|
||||
print(woord+" is niet gekozen.")
|
||||
|
||||
|
||||
|
||||
# hier kan je de lijn gebruiken in een functie
|
||||
file.close() # sluit de file
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,74 @@
|
|||
import string
|
||||
|
||||
def hoofdletters_kleineletters(string1, string2):
|
||||
kleineletters1 = []
|
||||
kleineletters2 = []
|
||||
hoofdletter1 = []
|
||||
hoofdletter2 = []
|
||||
|
||||
for i in string1:
|
||||
if i == i.lower():
|
||||
kleineletters1.append(i)
|
||||
for i in string2:
|
||||
if i == i.lower():
|
||||
kleineletters2.append(i)
|
||||
if i == i.upper():
|
||||
hoofdletter1.append(i)
|
||||
hoofdletter2.append(i)
|
||||
|
||||
print(set(kleineletters1).intersection(set(kleineletters2)))
|
||||
print(set(hoofdletter1).intersection(set(hoofdletter2)))
|
||||
|
||||
|
||||
|
||||
|
||||
def set_geenletters_instrings(string1,string2):
|
||||
kleineletters1 = []
|
||||
kleineletters2 = []
|
||||
hoofdletter1 = []
|
||||
hoofdletter2 = []
|
||||
|
||||
for i in string1:
|
||||
if i == i.lower():
|
||||
kleineletters1.append(i)
|
||||
for i in string2:
|
||||
if i == i.lower():
|
||||
kleineletters2.append(i)
|
||||
if i == i.upper():
|
||||
hoofdletter1.append(i)
|
||||
hoofdletter2.append(i)
|
||||
allekleineletters = string.ascii_lowercase
|
||||
allehoofdletters = string.ascii_uppercase
|
||||
|
||||
set(kleineletters1).difference(set(kleineletters2))
|
||||
print(set(allekleineletters).difference(set(kleineletters1)))
|
||||
|
||||
|
||||
|
||||
|
||||
def niet_letters(string1,string2):
|
||||
niet_letters1 = []
|
||||
niet_letters2 = []
|
||||
|
||||
for i in string1:
|
||||
if i.isalpha():
|
||||
pass
|
||||
else:
|
||||
niet_letters1.append(i)
|
||||
for i in string2:
|
||||
if i.isalpha():
|
||||
pass
|
||||
else:
|
||||
niet_letters2.append(i)
|
||||
|
||||
niet_letters = set(niet_letters1).intersection(set(niet_letters2))
|
||||
print(niet_letters)
|
||||
|
||||
|
||||
def main():
|
||||
#hoofdletters_kleineletters("Hallo","Nealogr")
|
||||
#set_geenletters_instrings("Hallo","Nealogr")
|
||||
|
||||
niet_letters("Dit is een string123", "lol13435//##")
|
||||
|
||||
main()
|
|
@ -0,0 +1,200 @@
|
|||
Ger Fra Eng
|
||||
Ger Fra Eng
|
||||
Ger Ita Eng
|
||||
Ger Fra Eng
|
||||
Ger Ita Eng
|
||||
Bel Ger Eng
|
||||
Bel Ger Spa
|
||||
Bel Ita Eng
|
||||
Ger Spa Ita
|
||||
Bel Ger Eng
|
||||
Spa Ita Fra
|
||||
Bel Ita Fra
|
||||
Ger Ita Fra
|
||||
Ger Spa Fra
|
||||
Bel Ita Fra
|
||||
Ita Fra Eng
|
||||
Bel Ita Spa
|
||||
Ger Ita Fra
|
||||
Bel Ger Eng
|
||||
Bel Ita Eng
|
||||
Bel Fra Eng
|
||||
Ger Spa Fra
|
||||
Bel Ger Spa
|
||||
Ger Ita Fra
|
||||
Spa Ita Eng
|
||||
Spa Ita Fra
|
||||
Bel Ita Eng
|
||||
Bel Ger Fra
|
||||
Bel Ger Ita
|
||||
Bel Ger Spa
|
||||
Ita Fra Eng
|
||||
Ger Spa Eng
|
||||
Bel Fra Eng
|
||||
Bel Ger Fra
|
||||
Bel Ger Ita
|
||||
Bel Ger Ita
|
||||
Bel Ger Eng
|
||||
Bel Fra Eng
|
||||
Ita Fra Eng
|
||||
Ita Spa Eng
|
||||
Bel Ita Fra
|
||||
Ita Spa Fra
|
||||
Bel Ger Ita
|
||||
Bel Ita Eng
|
||||
Bel Ger Eng
|
||||
Ita Fra Eng
|
||||
Bel Spa Eng
|
||||
Bel Ita Eng
|
||||
Bel Ger Fra
|
||||
Bel Ita Eng
|
||||
Ita Fra Eng
|
||||
Bel Ger Ita
|
||||
Ger Fra Eng
|
||||
Ita Fra Eng
|
||||
Ger Spa Fra
|
||||
Ger Ita Eng
|
||||
Bel Ita Eng
|
||||
Bel Spa Fra
|
||||
Bel Ger Eng
|
||||
Ita Fra Eng
|
||||
Ita Fra Eng
|
||||
Bel Fra Eng
|
||||
Ger Spa Fra
|
||||
Ger Ita Eng
|
||||
Ita Fra Eng
|
||||
Bel Ger Eng
|
||||
Bel Spa Fra
|
||||
Ger Ita Eng
|
||||
Ita Fra Eng
|
||||
Ger Spa Fra
|
||||
Bel Spa Ita
|
||||
Bel Ita Eng
|
||||
Bel Ita Spa
|
||||
Bel Ita Fra
|
||||
Bel Ger Eng
|
||||
Ger Spa Ita
|
||||
Ger Spa Eng
|
||||
Spa Fra Eng
|
||||
Ita Fra Eng
|
||||
Ger Ita Spa
|
||||
Bel Ger Eng
|
||||
Bel Ger Ita
|
||||
Ita Fra Eng
|
||||
Ger Spa Fra
|
||||
Ger Spa Eng
|
||||
Ita Fra Eng
|
||||
Bel Fra Eng
|
||||
Bel Ger Eng
|
||||
Ita Fra Eng
|
||||
Bel Ita Fra
|
||||
Bel Ger Fra
|
||||
Ger Spa Eng
|
||||
Ger Ita Eng
|
||||
Spa Fra Eng
|
||||
Ger Ita Eng
|
||||
Bel Ger Eng
|
||||
Bel Ger Ita
|
||||
Ger Fra Eng
|
||||
Ita Spa Eng
|
||||
Bel Spa Eng
|
||||
Spa Fra Eng
|
||||
Bel Ger Spa
|
||||
Bel Spa Ita
|
||||
Bel Ger Spa
|
||||
Ita Fra Eng
|
||||
Bel Ger Fra
|
||||
Bel Ger Ita
|
||||
Bel Ita Fra
|
||||
Ger Spa Ita
|
||||
Bel Ita Fra
|
||||
Bel Ger Fra
|
||||
Ger Ita Spa
|
||||
Bel Ita Eng
|
||||
Ger Spa Eng
|
||||
Bel Ita Fra
|
||||
Bel Fra Eng
|
||||
Bel Ger Spa
|
||||
Bel Ita Fra
|
||||
Ger Ita Fra
|
||||
Bel Spa Fra
|
||||
Ger Ita Eng
|
||||
Bel Ita Eng
|
||||
Bel Ger Fra
|
||||
Ger Ita Eng
|
||||
Ger Ita Spa
|
||||
Ger Fra Eng
|
||||
Ita Spa Fra
|
||||
Bel Fra Eng
|
||||
Ger Spa Ita
|
||||
Bel Ger Fra
|
||||
Ger Spa Ita
|
||||
Bel Ger Fra
|
||||
Ger Ita Spa
|
||||
Ger Fra Eng
|
||||
Ger Ita Spa
|
||||
Ger Ita Eng
|
||||
Ger Spa Ita
|
||||
Ita Spa Eng
|
||||
Ita Spa Eng
|
||||
Ger Ita Fra
|
||||
Bel Ita Spa
|
||||
Bel Ger Spa
|
||||
Ger Spa Eng
|
||||
Spa Ita Eng
|
||||
Spa Fra Eng
|
||||
Bel Ger Eng
|
||||
Bel Ita Fra
|
||||
Bel Ita Fra
|
||||
Ger Spa Eng
|
||||
Ita Fra Eng
|
||||
Spa Fra Eng
|
||||
Spa Fra Eng
|
||||
Ger Ita Eng
|
||||
Bel Ger Ita
|
||||
Ita Fra Eng
|
||||
Ita Spa Fra
|
||||
Bel Ger Fra
|
||||
Bel Ita Fra
|
||||
Bel Ita Eng
|
||||
Ger Ita Eng
|
||||
Spa Ita Eng
|
||||
Bel Ger Fra
|
||||
Spa Ita Eng
|
||||
Bel Spa Eng
|
||||
Bel Ger Eng
|
||||
Bel Ger Eng
|
||||
Ger Spa Eng
|
||||
Bel Ita Eng
|
||||
Ger Ita Fra
|
||||
Bel Ger Fra
|
||||
Ita Fra Eng
|
||||
Spa Fra Eng
|
||||
Spa Fra Eng
|
||||
Bel Ger Eng
|
||||
Bel Fra Eng
|
||||
Bel Spa Fra
|
||||
Bel Ger Eng
|
||||
Bel Ger Fra
|
||||
Bel Ita Spa
|
||||
Bel Ger Spa
|
||||
Ita Fra Eng
|
||||
Bel Ita Spa
|
||||
Bel Ita Fra
|
||||
Bel Ger Fra
|
||||
Ger Spa Fra
|
||||
Bel Fra Eng
|
||||
Ita Fra Eng
|
||||
Bel Fra Eng
|
||||
Ger Ita Fra
|
||||
Bel Ger Spa
|
||||
Bel Ger Fra
|
||||
Bel Spa Ita
|
||||
Bel Ita Fra
|
||||
Spa Fra Eng
|
||||
Bel Spa Eng
|
||||
Bel Ita Spa
|
||||
Ger Ita Fra
|
||||
Spa Fra Eng
|
||||
Ger Ita Eng
|
||||
Bel Ita Eng
|
|
@ -0,0 +1,84 @@
|
|||
import sys
|
||||
from subprocess import Popen, PIPE
|
||||
|
||||
######################################################################################################################
|
||||
# TODO: #
|
||||
# 1) PUT THIS FILE IN THE SAME FOLDER AS THE PYTHON FILE CONTAINING YOUR SOLUTION #
|
||||
# 2) CHANGE THE NAME 'MY_FILE_NAME.py' BELOW THIS BOX TO THE NAME OF YOUR PYTHON FILE #
|
||||
# 3) RUN THIS FILE #
|
||||
######################################################################################################################
|
||||
|
||||
YOUR_SOLUTION_FILE_NAME = "paswoordchecker_runevanoverloop_v2.py"
|
||||
|
||||
######################################################################################################################
|
||||
# DO NOT CHANGE ANYTHING BELOW THIS LINE #
|
||||
######################################################################################################################
|
||||
|
||||
|
||||
# Parse the given output string into a readable string
|
||||
|
||||
def parse_output(full_output_string):
|
||||
try:
|
||||
print(full_output_string)
|
||||
output = str(full_output_string).replace('\\n', ' ').replace(',', '').replace('\\r', ' ').replace('(', '')\
|
||||
.replace(')', '').replace('"', '').replace('\'', '')
|
||||
except:
|
||||
output = None
|
||||
return output
|
||||
|
||||
|
||||
# Run one test case with given input and output, return True when test succeeds, False when test fails
|
||||
def run_one_test_case(inp, expected_output):
|
||||
process = Popen([sys.executable, YOUR_SOLUTION_FILE_NAME], stdin=PIPE, stdout=PIPE, stderr=PIPE)
|
||||
(output, err) = process.communicate(inp)
|
||||
if len(str(err)) > 3:
|
||||
print(err)
|
||||
print("Je programma gooide een error. "
|
||||
"(Kijk eventueel ook na of de naam en locatie van je programma correct zijn.)")
|
||||
return False
|
||||
process.wait()
|
||||
output = output.decode('utf-8').replace("\n", "").replace("\r", "")
|
||||
# parsed_output = parse_output(output)
|
||||
parsed_output = output
|
||||
if parsed_output is None:
|
||||
print("Controleer het formaat van je output! Geef enkel de gevraagde numerieke waarden, en géén tekst!"
|
||||
" Kijk ook na dat je bij input() geen prompt meegeeft.")
|
||||
return False
|
||||
print("EXPECTED: ", expected_output.replace(" ", "*"))
|
||||
print ("OUTPUT: ", parsed_output.replace(" ", "*"))
|
||||
return parsed_output == expected_output
|
||||
|
||||
|
||||
# Retrieve a list containing all test_cases
|
||||
def get_test_cases():
|
||||
test_cases = []
|
||||
# In: 1234560 Uit: ZWAK! LENGTE HOOFDLETTER KLEINELETTER SPECIAALTEKEN
|
||||
test_cases.append((b"123456", "ZWAK! LENGTE HOOFDLETTER KLEINELETTER SPECIAALTEKEN "))
|
||||
# In: Admin123 Uit: ZWAK! LENGTE SPECIAALTEKEN
|
||||
test_cases.append((b"Admin123", "ZWAK! LENGTE SPECIAALTEKEN "))
|
||||
# In: paswoord2022 Uit: ZWAK! HOOFDLETTER SPECIAALTEKEN
|
||||
test_cases.append((b"paswoord2022", "ZWAK! HOOFDLETTER SPECIAALTEKEN "))
|
||||
# In: mi*IS*SUP3Rc88l Uit: STERK!
|
||||
test_cases.append((b"mi*IS*SUP3Rc88l", "STERK! "))
|
||||
# In: mi*IS*SUP3Rc88l Uit: ZWAK! SPATIE
|
||||
test_cases.append((b" mi*IS*SUP3Rc88l ", "ZWAK! SPATIE "))
|
||||
# In: Paswoord 2022 Uit: ZWAK! SPECIAALTEKEN
|
||||
test_cases.append((b"Paswoord 2022", "ZWAK! SPECIAALTEKEN "))
|
||||
return test_cases
|
||||
|
||||
|
||||
# Run all given test_cases
|
||||
def run_test_cases(all_tests):
|
||||
print("Alle tests worden uitgevoerd")
|
||||
print("Spaties zijn vervangen door *")
|
||||
for test_nb in range(len(all_tests)):
|
||||
(inp, exp_out) = all_tests[test_nb]
|
||||
test_result = run_one_test_case(inp, exp_out)
|
||||
if test_result:
|
||||
print('Test ' + str(test_nb + 1) + ': Succeeded')
|
||||
else:
|
||||
print('Test ' + str(test_nb + 1) + ': Failed')
|
||||
|
||||
|
||||
# Load all test cases and test them
|
||||
run_test_cases(get_test_cases())
|
|
@ -0,0 +1,25 @@
|
|||
# voorbeeld code
|
||||
|
||||
|
||||
def swap(values, i, j):
|
||||
# temp = values[i]
|
||||
# values[i] = values[j]
|
||||
# values[j] = temp
|
||||
values[i], values[j] = values[j], values[i]
|
||||
|
||||
def insertion_sort(values):
|
||||
i = 1
|
||||
# INVAR: is_sorted(values[:i])
|
||||
while i < len(values):
|
||||
j = i - 1
|
||||
# INVAR: is_sorted(values[:j+1]) and is_sorted(values[j+1:i+1])
|
||||
while j >= 0 and values[j] > values[j+1]:
|
||||
swap(values, j, j+1)
|
||||
j = j - 1
|
||||
i = i + 1
|
||||
return values # om te testen
|
||||
|
||||
assert insertion_sort([]) == []
|
||||
assert insertion_sort([1]) == [1]
|
||||
assert insertion_sort([2, 1]) == [1, 2]
|
||||
assert insertion_sort([7, 2, 1, 4, 5, 3, 6]) == [1, 2, 3, 4, 5, 6, 7]
|
|
@ -0,0 +1,49 @@
|
|||
paswoord = input()
|
||||
|
||||
CIJFER = "CIJFER "
|
||||
HOOFDLETTER = "HOOFDLETTER "
|
||||
SPECIAALTEKEN = "SPECIAALTEKEN "
|
||||
KLEINELETTER = "KLEINELETTER "
|
||||
bevat_spatie = "SPATIE "
|
||||
LENGTE = "LENGTE "
|
||||
spatie_in_woord = 0
|
||||
|
||||
|
||||
for letter in range(len(paswoord)):
|
||||
if paswoord[letter] == " ":
|
||||
spatie_in_woord += 1
|
||||
|
||||
if paswoord[letter].isdigit():
|
||||
CIJFER = ""
|
||||
|
||||
if paswoord[letter].isupper():
|
||||
|
||||
HOOFDLETTER = ""
|
||||
|
||||
if paswoord[letter].islower():
|
||||
|
||||
KLEINELETTER = ""
|
||||
|
||||
if not paswoord[letter].isalnum():
|
||||
if paswoord[letter] != " ":
|
||||
SPECIAALTEKEN = ""
|
||||
|
||||
|
||||
aantal_tekens = len(paswoord) - spatie_in_woord
|
||||
if aantal_tekens >= 12:
|
||||
LENGTE = ""
|
||||
|
||||
|
||||
if paswoord[0] == " " or paswoord[-1] == " ":
|
||||
pass
|
||||
|
||||
else:
|
||||
bevat_spatie = ""
|
||||
|
||||
string = LENGTE + HOOFDLETTER + KLEINELETTER + CIJFER + SPECIAALTEKEN + bevat_spatie
|
||||
|
||||
if string == "":
|
||||
print("STERK! ")
|
||||
|
||||
else:
|
||||
print("ZWAK! " + string)
|
|
@ -0,0 +1,27 @@
|
|||
def swap(values, i, j):
|
||||
# temp = values[i]
|
||||
# values[i] = values[j]
|
||||
# values[j] = temp
|
||||
values[i], values[j] = values[j], values[i]
|
||||
|
||||
def minimum_position(values, start):
|
||||
min_pos = start
|
||||
i = start + 1
|
||||
while i < len(values):
|
||||
if values[i] < values[min_pos]:
|
||||
min_pos = i
|
||||
i = i + 1
|
||||
return min_pos
|
||||
|
||||
def selection_sort(values):
|
||||
i = 0
|
||||
while i < len(values):
|
||||
min_pos = minimum_position(values, i)
|
||||
swap(values, i, min_pos)
|
||||
i = i + 1
|
||||
return values # handig om te testen
|
||||
|
||||
assert selection_sort([]) == []
|
||||
assert selection_sort([1]) == [1]
|
||||
assert selection_sort([2, 1]) == [1, 2]
|
||||
assert selection_sort([7, 2, 1, 4, 5, 3, 6]) == [1, 2, 3, 4, 5, 6, 7]
|
|
@ -0,0 +1,54 @@
|
|||
|
||||
|
||||
|
||||
def swap(values, i, j):
|
||||
# temp = values[i]
|
||||
# values[i] = values[j]
|
||||
# values[j] = temp
|
||||
values[i], values[j] = values[j], values[i]
|
||||
|
||||
def minimum_position(values, start, end_links_sort):
|
||||
min_pos = start
|
||||
i = start + 1
|
||||
while i <= end_links_sort:
|
||||
if values[i] < values[min_pos]:
|
||||
min_pos = i
|
||||
i = i + 1
|
||||
return min_pos
|
||||
|
||||
def maximum_position(values, end, end_rechts_sort):
|
||||
max_pos = end
|
||||
i = end - 1
|
||||
while i >= end_rechts_sort:
|
||||
if values[i] > values[max_pos]:
|
||||
max_pos = i
|
||||
i = i - 1
|
||||
return max_pos
|
||||
|
||||
|
||||
def selection_sort(values):
|
||||
print("hallo")
|
||||
gem = len(values)/2
|
||||
end_links_sort = round(gem) -1
|
||||
end_rechts_sort = round(gem)
|
||||
print(end_links_sort)
|
||||
print(end_rechts_sort)
|
||||
i = 0
|
||||
j = len(values) - 1
|
||||
while j >= end_rechts_sort or i <= end_links_sort:
|
||||
print("i: ",i)
|
||||
print("j: ",j)
|
||||
if i <= end_links_sort:
|
||||
min_pos = minimum_position(values, i, end_links_sort)
|
||||
if j >= end_rechts_sort:
|
||||
max_pos = maximum_position(values, j, end_rechts_sort)
|
||||
|
||||
swap(values, i, min_pos)
|
||||
swap(values, j, max_pos)
|
||||
print(values)
|
||||
i = i + 1
|
||||
j = j - 1
|
||||
|
||||
return values # handig om te testen
|
||||
|
||||
assert selection_sort([7, 2, 1, 4, 5, 3, 6]) == [1, 2, 3, 4, 5, 6, 7]
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,25 @@
|
|||
// ------------------------------------------------- globale variabelen definieren ------------------------------------------------
|
||||
|
||||
int pinNumber = 12;
|
||||
|
||||
// ---------------------------------------------------- setup() en loop () ---------------------------------------------------------
|
||||
|
||||
// de setup functie wordt maar een keer uitgevoerd helemaal in het begin!
|
||||
void setup(){
|
||||
// initialiseer alle pinnen van 11 tot en met 13 als output-pin met een for loop.
|
||||
for(int pin=11; pin<=13; pin=pin+1){
|
||||
pinMode(pin, OUTPUT);
|
||||
}
|
||||
}
|
||||
|
||||
// de loop routine wordt continu uitgevoerd en herhaald
|
||||
void loop(){
|
||||
for(int pinNumber=11; pinNumber<=13; pinNumber=pinNumber+1){
|
||||
|
||||
digitalWrite(pinNumber, HIGH); // Zet de output van de pin 'pinNumber' hoog. (HIGH komt overeen met 5V)
|
||||
delay(1000); // wacht gedurende 1000ms
|
||||
digitalWrite(pinNumber, LOW); // Zet de output van de pin 'pinNumber' laag. (LOW komt overeen met 0V)
|
||||
delay(1000); // wacht gedurende 1000ms
|
||||
}}
|
||||
|
||||
// ---------------------------------------------------- Eigen functies ---------------------------------------------------------
|
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"cpu": {
|
||||
"fqbn": "arduino:avr:mega:cpu=atmega2560",
|
||||
"name": "Arduino Mega or Mega 2560",
|
||||
"type": "serial"
|
||||
},
|
||||
"secrets": [],
|
||||
"included_libs": []
|
||||
}
|
Binary file not shown.
|
@ -0,0 +1,58 @@
|
|||
:Author: rune583
|
||||
:Email: {AuthorEmail}
|
||||
:Date: 23/02/2022
|
||||
:Revision: version#
|
||||
:License: Public Domain
|
||||
|
||||
= Project: {Project}
|
||||
|
||||
Describe your project
|
||||
|
||||
== Step 1: Installation
|
||||
Please describe the steps to install this project.
|
||||
|
||||
For example:
|
||||
|
||||
1. Open this file
|
||||
2. Edit as you like
|
||||
3. Release to the World!
|
||||
|
||||
== Step 2: Assemble the circuit
|
||||
|
||||
Assemble the circuit following the diagram layout.png attached to the sketch
|
||||
|
||||
== Step 3: Load the code
|
||||
|
||||
Upload the code contained in this sketch on to your board
|
||||
|
||||
=== Folder structure
|
||||
|
||||
....
|
||||
sketch123 => Arduino sketch folder
|
||||
├── sketch123.ino => main Arduino file
|
||||
├── schematics.png => (optional) an image of the required schematics
|
||||
├── layout.png => (optional) an image of the layout
|
||||
└── ReadMe.adoc => this file
|
||||
....
|
||||
|
||||
=== License
|
||||
This project is released under a {License} License.
|
||||
|
||||
=== Contributing
|
||||
To contribute to this project please contact rune583 https://id.arduino.cc/rune583
|
||||
|
||||
=== BOM
|
||||
Add the bill of the materials you need for this project.
|
||||
|
||||
|===
|
||||
| ID | Part name | Part number | Quantity
|
||||
| R1 | 10k Resistor | 1234-abcd | 10
|
||||
| L1 | Red LED | 2345-asdf | 5
|
||||
| A1 | Arduino Zero | ABX00066 | 1
|
||||
|===
|
||||
|
||||
|
||||
=== Help
|
||||
This document is written in the _AsciiDoc_ format, a markup language to describe documents.
|
||||
If you need help you can search the http://www.methods.co.nz/asciidoc[AsciiDoc homepage]
|
||||
or consult the http://powerman.name/doc/asciidoc[AsciiDoc cheatsheet]
|
|
@ -0,0 +1,63 @@
|
|||
/*
|
||||
|
||||
*/
|
||||
|
||||
int minimaleInput = 1;
|
||||
int maximaleInput = 3;
|
||||
|
||||
|
||||
void setup() {
|
||||
for(int pin=11; pin<=13; pin=pin+1){
|
||||
pinMode(pin, OUTPUT);
|
||||
Serial.begin(9600);
|
||||
delay(500);
|
||||
|
||||
Serial.println("Typ een getal in tussen 1 en 3 en een tweede getal voor de tijd");
|
||||
}
|
||||
}
|
||||
|
||||
void loop(){
|
||||
if (Serial.available()){
|
||||
|
||||
int receivedvalue = Serial.parseInt();
|
||||
int delay = Serial.parseInt();
|
||||
|
||||
boolean inputOK1 = validInput1(receivedvalue); // kijk of de input binnen de waardes ligt.
|
||||
boolean inputOK2 = validInput2(delay * 1000);
|
||||
|
||||
if (inputOK1 && inputOK2){
|
||||
led(receivedvalue, delay);
|
||||
}
|
||||
|
||||
|
||||
else {
|
||||
Serial.println("De ingegeven waarde is niet geldig.");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void led(int input, int time1) {
|
||||
int pinNumber = input + 10;
|
||||
digitalWrite(pinNumber,HIGH); // Zet de output van de pin 'pinNumber' hoog. (HIGH komt overeen met 5V)
|
||||
delay(delay); // wacht gedurende 1000ms
|
||||
digitalWrite(pinNumber, LOW); // Zet de output van de pin 'pinNumber' laag. (LOW komt overeen met 0V)
|
||||
delay(delay);
|
||||
|
||||
}
|
||||
|
||||
|
||||
boolean validInput1(float input){
|
||||
// && wordt gebruikt als logische 'AND'
|
||||
boolean ok = (input >= minimaleInput) && (input <= maximaleInput);
|
||||
|
||||
// geef de boolean ok als resultaat van de functie zodat er mee verder kan gerekend worden.
|
||||
return ok;
|
||||
// for(int pinNumber=11; pinNumber<=13; pinNumber=pinNumber+1){
|
||||
}
|
||||
|
||||
boolean validInput2(float input) {
|
||||
boolean ok = (input >= 0);
|
||||
return ok;
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"cpu": {
|
||||
"fqbn": "arduino:avr:mega:cpu=atmega2560",
|
||||
"name": "Arduino Mega or Mega 2560",
|
||||
"type": "serial"
|
||||
},
|
||||
"secrets": [],
|
||||
"included_libs": []
|
||||
}
|
Binary file not shown.
|
@ -0,0 +1,58 @@
|
|||
:Author: rune583
|
||||
:Email: {AuthorEmail}
|
||||
:Date: 23/02/2022
|
||||
:Revision: version#
|
||||
:License: Public Domain
|
||||
|
||||
= Project: {Project}
|
||||
|
||||
Describe your project
|
||||
|
||||
== Step 1: Installation
|
||||
Please describe the steps to install this project.
|
||||
|
||||
For example:
|
||||
|
||||
1. Open this file
|
||||
2. Edit as you like
|
||||
3. Release to the World!
|
||||
|
||||
== Step 2: Assemble the circuit
|
||||
|
||||
Assemble the circuit following the diagram layout.png attached to the sketch
|
||||
|
||||
== Step 3: Load the code
|
||||
|
||||
Upload the code contained in this sketch on to your board
|
||||
|
||||
=== Folder structure
|
||||
|
||||
....
|
||||
sketch123 => Arduino sketch folder
|
||||
├── sketch123.ino => main Arduino file
|
||||
├── schematics.png => (optional) an image of the required schematics
|
||||
├── layout.png => (optional) an image of the layout
|
||||
└── ReadMe.adoc => this file
|
||||
....
|
||||
|
||||
=== License
|
||||
This project is released under a {License} License.
|
||||
|
||||
=== Contributing
|
||||
To contribute to this project please contact rune583 https://id.arduino.cc/rune583
|
||||
|
||||
=== BOM
|
||||
Add the bill of the materials you need for this project.
|
||||
|
||||
|===
|
||||
| ID | Part name | Part number | Quantity
|
||||
| R1 | 10k Resistor | 1234-abcd | 10
|
||||
| L1 | Red LED | 2345-asdf | 5
|
||||
| A1 | Arduino Zero | ABX00066 | 1
|
||||
|===
|
||||
|
||||
|
||||
=== Help
|
||||
This document is written in the _AsciiDoc_ format, a markup language to describe documents.
|
||||
If you need help you can search the http://www.methods.co.nz/asciidoc[AsciiDoc homepage]
|
||||
or consult the http://powerman.name/doc/asciidoc[AsciiDoc cheatsheet]
|
|
@ -0,0 +1,26 @@
|
|||
/*
|
||||
|
||||
*/
|
||||
int pin = A0;
|
||||
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
delay(500);
|
||||
Serial.println("Typ \"v" + "om de spanning te meten.");
|
||||
// print text in de seriele monitor
|
||||
}
|
||||
|
||||
void loop() {
|
||||
if (Serial.available()) {
|
||||
char input = Serial.read();
|
||||
|
||||
float = value;
|
||||
if (char input == 'v') {
|
||||
value = analogRead(pin);
|
||||
Serial.print((value/(1024))*5);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"cpu": {
|
||||
"fqbn": "",
|
||||
"name": "",
|
||||
"type": ""
|
||||
},
|
||||
"secrets": [],
|
||||
"included_libs": []
|
||||
}
|
Binary file not shown.
|
@ -0,0 +1,58 @@
|
|||
:Author: rune583
|
||||
:Email: {AuthorEmail}
|
||||
:Date: 25/02/2022
|
||||
:Revision: version#
|
||||
:License: Public Domain
|
||||
|
||||
= Project: {Project}
|
||||
|
||||
Describe your project
|
||||
|
||||
== Step 1: Installation
|
||||
Please describe the steps to install this project.
|
||||
|
||||
For example:
|
||||
|
||||
1. Open this file
|
||||
2. Edit as you like
|
||||
3. Release to the World!
|
||||
|
||||
== Step 2: Assemble the circuit
|
||||
|
||||
Assemble the circuit following the diagram layout.png attached to the sketch
|
||||
|
||||
== Step 3: Load the code
|
||||
|
||||
Upload the code contained in this sketch on to your board
|
||||
|
||||
=== Folder structure
|
||||
|
||||
....
|
||||
sketch123 => Arduino sketch folder
|
||||
├── sketch123.ino => main Arduino file
|
||||
├── schematics.png => (optional) an image of the required schematics
|
||||
├── layout.png => (optional) an image of the layout
|
||||
└── ReadMe.adoc => this file
|
||||
....
|
||||
|
||||
=== License
|
||||
This project is released under a {License} License.
|
||||
|
||||
=== Contributing
|
||||
To contribute to this project please contact rune583 https://id.arduino.cc/rune583
|
||||
|
||||
=== BOM
|
||||
Add the bill of the materials you need for this project.
|
||||
|
||||
|===
|
||||
| ID | Part name | Part number | Quantity
|
||||
| R1 | 10k Resistor | 1234-abcd | 10
|
||||
| L1 | Red LED | 2345-asdf | 5
|
||||
| A1 | Arduino Zero | ABX00066 | 1
|
||||
|===
|
||||
|
||||
|
||||
=== Help
|
||||
This document is written in the _AsciiDoc_ format, a markup language to describe documents.
|
||||
If you need help you can search the http://www.methods.co.nz/asciidoc[AsciiDoc homepage]
|
||||
or consult the http://powerman.name/doc/asciidoc[AsciiDoc cheatsheet]
|
|
@ -0,0 +1,33 @@
|
|||
int pinNumber = 11;
|
||||
|
||||
int analogPin = A0;
|
||||
|
||||
int ACTIVATIE_WAARDE = 700;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
delay(500);
|
||||
// Serial.println("Typ \"v" + "om de spanning te meten.");
|
||||
// print text in de seriele monitor
|
||||
// Serial.println("");
|
||||
pinMode(pinNumber, OUTPUT);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
//char input = Serial.read();
|
||||
delay(100);
|
||||
float value;
|
||||
//if (char input == 'v') {
|
||||
value = analogRead(analogPin);
|
||||
if (value <= ACTIVATIE_WAARDE) {
|
||||
digitalWrite(pinNumber, HIGH);
|
||||
|
||||
}
|
||||
else {
|
||||
digitalWrite(pinNumber, LOW);
|
||||
}
|
||||
|
||||
Serial.print((value/(1024))*5);
|
||||
Serial.print(" ");
|
||||
delay(1000);
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"cpu": {
|
||||
"fqbn": "",
|
||||
"name": "",
|
||||
"type": ""
|
||||
},
|
||||
"secrets": [],
|
||||
"included_libs": []
|
||||
}
|
Loading…
Reference in New Issue