-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlrc-vrc.py
More file actions
166 lines (115 loc) · 2.74 KB
/
lrc-vrc.py
File metadata and controls
166 lines (115 loc) · 2.74 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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
#definining
class LRC:
def __init__(self, input1):
self.data= input1
def lrcodd(self):
check = 0
for i in range(len(self.data)):
if self.data[i] == '1':
check += 1
else:
continue
if check%2 == 0:
p = '1'
else:
p = '0'
return p
def lrceven(self):
check = 0
for i in range(len(self.data)):
if self.data[i] == '1':
check += 1
else:
continue
if check%2 == 0:
p = '0'
else:
p = '1'
return p
class VRC:
def __init__(self, input1):
self.data= input1
def vrcodd(self):
vrc_value= ""
for i in range(len(self.data[0])):
count = 0
for j in range(len(self.data)):
if self.data[j][i]== '1':
count += 1
else:
continue
if count%2 == 0:
p ='1'
else:
p = '0'
vrc_value = vrc_value+ p
return vrc_value
def vrceven(self):
vrc_value= ""
for i in range(len(self.data[0])):
count = 0
for j in range(len(self.data)):
if self.data[j][i]== '1':
count += 1
else:
continue
if count%2 == 0:
p ='0'
else:
p = '1'
vrc_value = vrc_value+ p
return vrc_value
#Test
a= int(input("Choose: 1 for LRC and 2 for VRC: "))
if a ==1:
b=int(input("Choose: 1 for odd parity and 2 for even: "))
if b == 1:
no_e = int(input("enter no of elements is your lrc, vrc data set: "))
data1 = ['']*no_e
for i in range(no_e):
c= str(input("insert your data for position " + str(i) + ": "))
data1[i]= c
print("LRC: -------------------")
print("odd: ")
for i in range(len(data1)):
l = LRC(data1[i])
print(data1[i] +" "+ l.lrcodd())
if b == 2:
no_e = int(input("enter no of elements is your lrc, vrc data set: "))
data1 = ['']*no_e
for i in range(no_e):
c= str(input("insert your data for position " + str(i) + ": "))
data1[i]= c
print("LRC: -------------------")
print("even: ")
for i in range(len(data1)):
l = LRC(data1[i])
print(data1[i] +" "+ l.lrceven())
if a== 2:
b=int(input("Choose: 1 for odd parity and 2 for even: "))
if b == 1:
no_e = int(input("enter no of elements is your lrc, vrc data set: "))
data1 = ['']*no_e
for i in range(no_e):
c= str(input("insert your data for position " + str(i) + ": "))
data1[i]= c
print(" VRC: -------------------")
v = VRC(data1)
print("odd: ")
for i in range(len(data1)):
print(data1[i])
print("--------")
print(v.vrcodd())
if b == 2:
no_e = int(input("enter no of elements is your lrc, vrc data set: "))
data1 = ['']*no_e
for i in range(no_e):
c= str(input("insert your data for position " + str(i) + ": "))
data1[i]= c
print("VRC: -------------------")
print("even: ")
v = VRC(data1)
for i in range(len(data1)):
print(data1[i])
print("--------")
print(v.vrceven())