-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHoofdstuk2.rb
More file actions
98 lines (81 loc) · 1.29 KB
/
Hoofdstuk2.rb
File metadata and controls
98 lines (81 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
def deelbaardoor3 (tot)
i = 0
while i < tot
if i % 3 == 0
puts(i)
end
i = i + 1
end
end
def FizzBuzz(tot)
i = 0
while i < tot
if ((i % 3==0) and (i % 7==0))
puts ("FizzBuzz")
elsif i % 3 == 0
#puts (i)
puts("Fizz")
elsif i % 7 == 0
puts("Buzz")
else
puts(i)
end
i += 1
end
end
def zeef (n)
reeks = [*2..n]
priem = []
i = 0
while i < reeks.length
j = reeks[i]
priem.push(j)
while j < n
j += reeks[i]
reeks.delete(j)
end
i += 1
end
puts (priem)
end
def opsomming ()
for i in (0..1000)
puts(i)
end
end
$letters = [*"a".."z"]
def shift (letter, ap)
if isalpha(letter)
nieuwepos = ($letters.index(letter) + ap)
return $letters[nieuwepos % 26]
else
return letter
end
end
def isalpha(str)
!str.match(/[^A-Za-z]/)
end
def encrypt (woord, posities)
res = ""
res2 = ""
#woord.each_char do |c|
# res += shift(c, posities)
#end
for letter in woord.split("")
#puts(letter)
res2 += shift(letter, posities)
end
return res2
end
def readFile ()
contents = File.read('secret.txt')
puts(contents)
for i in (0..25)
puts(encrypt(contents.downcase(), -i))
end
end
readFile()
#opsomming()
#zeef(10000)
#FizzBuzz(100)
#deelbaardoor3(1000)