-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtesto.rb
More file actions
59 lines (46 loc) · 747 Bytes
/
testo.rb
File metadata and controls
59 lines (46 loc) · 747 Bytes
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
#puts "hello"
#p "hi"
arri = []
def test
x = 0
while x < 10
p x
x += 1
end
end
#p test
a = 0
#p 0.methods
b = "dog"
letters = b.split("")
#p letters
def letter_count(str)
counts = Hash.new(0)
str.each_char do |char|
counts[char] += 1 unless char == " "
end
counts
end
p letter_count("doggo")
def bubble_sort(arr)
sorted = false
until sorted
sorted = true
(arr.count - 1).times do |i|
if arr[i] > arr[i + 1]
arr[i], arr[i + 1] = arr[i + 1], arr[i]
sorted = false
end
end
end
arr
end
a = "221"
b = a.to_i
p b
x = 0
while x < 3
puts "yes" if a[x].to_i.even?
puts "no" if a[x].to_i.odd?
x += 1
end