File: turnwheel.rb

package info (click to toggle)
genometools 1.6.1%2Bds-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 50,412 kB
  • sloc: ansic: 271,241; ruby: 30,339; python: 4,880; sh: 3,193; makefile: 1,194; perl: 219; pascal: 159; haskell: 37; sed: 5
file content (27 lines) | stat: -rw-r--r-- 545 bytes parent folder | download | duplicates (6)
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
def turnwheels(asizes)
  numofalphabets = asizes.length
  wheelspace = Array.new
  alphasizes = Array.new
  0.upto(numofalphabets-1) do |z|
    alphasizes[z] = asizes[z]
    wheelspace[z] = 0
  end
  z = numofalphabets-1
  loop do
    yield wheelspace
    stop = false
    while not stop
      wheelspace[z] = wheelspace[z]+1
      if wheelspace[z] == alphasizes[z]
        wheelspace[z] = 0
        if z == 0
          return
        end
        z = z - 1
      else
        z = numofalphabets-1
        stop = true
      end
    end
  end
end