Module4 - has been ended 1,2,3
Signed-off-by: Marcin Woźniak <y0rune@aol.com>
This commit is contained in:
parent
5f821e510f
commit
7fd51c072d
25
module.rb
25
module.rb
@ -587,6 +587,7 @@ end
|
||||
#################################################################################
|
||||
def xtime(a)
|
||||
binA = a.to_i(16).to_s(2)
|
||||
const = "1B".to_i(16).to_s(2)
|
||||
dl = binA.length
|
||||
while dl != 8
|
||||
binA = "0" + binA
|
||||
@ -594,10 +595,8 @@ def xtime(a)
|
||||
end
|
||||
if binA[0].to_i == 1
|
||||
binA[0] = ''
|
||||
binA = binA + "0"
|
||||
return (binA.to_i(2) ^ "1B".to_i(16).to_s(2).to_i(2)).to_s(16)
|
||||
return ((binA.to_i(2) << 1) ^ const.to_i(2)).to_s(16)
|
||||
elsif binA[0].to_i == 0
|
||||
binA[0] = ''
|
||||
return (binA.to_i(2) << 1 ).to_s(16)
|
||||
end
|
||||
end
|
||||
@ -607,7 +606,7 @@ end
|
||||
# Funkcja iloczyn(a,b) wykorzystujac liczby hex
|
||||
#################################################################################
|
||||
def iloczyn(a,b)
|
||||
solve = ""
|
||||
solve = "0"
|
||||
|
||||
binA = a.to_i(16).to_s(2)
|
||||
dl = binA.length
|
||||
@ -618,17 +617,17 @@ def iloczyn(a,b)
|
||||
|
||||
len = binA.length - 1
|
||||
binA.split('').each { |a|
|
||||
counter = len - 2
|
||||
tmp = xtime(b)
|
||||
puts counter
|
||||
while counter != 0
|
||||
tmp = xtime(tmp)
|
||||
counter = counter - 1
|
||||
if a == "1"
|
||||
tmp = b
|
||||
counter = len
|
||||
while counter != 0
|
||||
tmp = xtime(tmp)
|
||||
counter = counter - 1
|
||||
end
|
||||
solve = suma(tmp.to_i(16).to_s(16), solve)
|
||||
end
|
||||
puts tmp
|
||||
#puts solve
|
||||
solve = suma((a.to_i * tmp.to_i(16)).to_s(16), solve)
|
||||
len = len - 1
|
||||
}
|
||||
|
||||
return solve
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user