Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $results = { 0 => [], 1 => [], 2 => [], 3 => [], 4 => [], 5 => [] }
- def get_tens_column (numbers)
- n = 0
- for i in 0...numbers.length
- n += numbers[i]
- end
- return n / 10
- end
- def dec_to_array (n)
- array = []
- numbers = [1,2,4,8,6,2,4].reverse()
- for i in 0..7
- a = 2.pow(i)
- if (n & a == a)
- array.push(numbers[i])
- end
- end
- return array
- end
- # Populate the results
- for i in 0...128
- combo = dec_to_array(i)
- tens = get_tens_column(combo)
- $results[tens].push({ :array => combo, :decimal => i })
- end
- # Output Combinations
- File.open("./combos.txt", 'w') { |file|
- file.puts "128 total combinations"
- for i in 0...$results.keys.length
- result = $results[$results.keys[i]]
- file.puts "------------|| #{$results.keys[i]} (#{result.length} combos) ||------------"
- for j in 0...result.length
- file.puts "#{result[j][:array].to_s} = #{result[j][:decimal]}"
- end
- end
- file.puts "\n"
- for i in 0...$results.keys.length
- result = $results[$results.keys[i]]
- file.puts "------------|| #{$results.keys[i]} (#{result.length} combos) ||------------"
- for j in 0...result.length
- file.print "#{result[j][:decimal]}"
- if (j < result.length - 1)
- file.print(",")
- end
- end
- file.print("\n")
- end
- }
- # MAPPING RESULTS
- # using: https://www.charlie-coleman.com/experiments/kmap/
- # Does 10s column equal 0:
- # F = 2'4'6'2'4' + 4'8'2'4' + 2'8'6'2' + 2'4'8'4' + 8'6'4' + 4'8'6'
- # Does 10s column equal 1:
- # F = 2'862'4' + 2'4'62'4 + 24'86' + 486'2' + 2'486' + 4'864' + 86'24' + 2'86'2 + 2'86'4 + 248'4 + 28'62 + 48'24 + 48'6 + 8'64
- # Does 10s column equal 2:
- # F = 24824 + 2486 + 2864 + 4862 + 4864 + 8624
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement