-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSNAKPROC.txt
72 lines (58 loc) · 3.23 KB
/
SNAKPROC.txt
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
no_of_response = gets.to_i
no_of_response.times do
length=gets.to_i
string=gets.split("").map(&:to_s)
if string.length == length+1
if string.count('.') == length
puts 'Valid'
else
if string.count('H') == string.count('T')
if string.include?('H' || 'T' || '.') == true
p=1
w=0
while p!=0
h=string.index('H')
t=string.index('T')
if h<t
x=h+1
loop do
if x<t
if string[x] != 'H'
x +=1
else
p=0
puts 'Invalid'
w=1
break
end
else
break
end
end
if w==0
delete_list = ['H','T']
delete_list.each do |del|
string.delete_at(string.index(del))
end
if string.include?('H') == false
puts 'Valid'
p=0
end
end
else
puts 'Invalid'
p=0
break
end
end
else
puts 'Invalid'
end
else
puts 'Invalid'
end
end
else
puts 'Invalid'
end
end