I can think of a few improvements.
Call all of your variable names something more meaningful. What is in
@array1
? Integers? consider calling it@ints
. Its good to call arrays a plural name. Same goes forj
andi
if possible.Use
(0..63).each do |i|
instead offor i in 0..63
. More ruby-likeUse spacing between operators, especially equals.
j = 0
notj=0
Small conditionals can go on one line:
j = 0 if j > 19
Why the magic numbers? Why are 18, 17, 16, and 13 special? Put them in an appropriately named array to start, and then use Array#reduce like so
special_indeces = [18, 17, 16, 13] ... and then in loop ... xor = special_indeces.reduce do |val, index| val ^ @array1[index].to_i end
- What is with
gets
at the end? What is the point of that?
Good luck, that code needs serious work.