Sha256: 3d594a23af81ca82f6c8fc0793669e6f0f3136a0e226660757105f8b7985a183

Contents?: true

Size: 780 Bytes

Versions: 6

Compression:

Stored size: 780 Bytes

Contents

# coding: utf-8

# A001006
MOTZKIN = [1,1,2,4,9,21,51,127,323,835,2188,5798,15511,
           41835,113634,310572,853467,2356779,6536382,
           18199284,50852019,142547559,400763223,1129760415,
           3192727797,9043402501,25669818476,73007772802,
           208023278209,593742784829].first(15)

describe Integer, "#motzkin" do
  MOTZKIN.each_with_index.each do |m, n|
    it "returns #{m} for Motzkin number #{n}" do
      n.motzkin.should == m
    end
  end
end

describe Integer, "#motzkin?" do
  MOTZKIN.sample(10).each do |n|
    it "returns true for Motzkin number #{n}" do
      n.should be_motzkin
    end
  end

  MOTZKIN.to_seq.invert.sample(10).each do |n|
    it "returns false for non-Motzkin number #{n}" do
      n.should_not be_motzkin
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
numb-0.186.0 spec/numb/motzkin_spec.rb
numb-0.185.0 spec/numb/motzkin_spec.rb
numb-0.184.0 spec/numb/motzkin_spec.rb
numb-0.181.0 spec/numb/motzkin_spec.rb
numb-0.170.0 spec/numb/motzkin_spec.rb
numb-0.152.0 spec/numb/motzkin_spec.rb