login
A292793
1/4 of the number of self-avoiding paths that are made of alternated vertical and horizontal n consecutive steps. (start point is different from end point.)
2
1, 2, 4, 8, 16, 29, 54, 98, 176, 318, 572, 1026, 1826, 3255, 5794, 10233, 18172, 32012, 56488, 99469, 175034, 307479, 540068, 947235, 1659907, 2908958, 5095019, 8917677, 15598100, 27281252, 47718310, 83298748, 145405769, 253641303, 442352671, 770769569, 1343166519, 2339093953
OFFSET
2,2
EXAMPLE
a(2) = 1;
E
|
*
|
S--*
a(3) = 2;
*--*--*--E E--*--*--*
| |
* *
| |
S--* S--*
a(4) = 4;
E E
| |
* *
| |
* *
| |
* *
| |
*--*--*--* *--*--*--* *--*--*--* *--*--*--*
| | | | | |
* * * * * *
| | | | | |
S--* S--* * * S--* S--*
| |
E E
PROG
(Ruby)
def A292793(n)
ary = [1]
b_ary = [[[0, 0], [1, 0], [1, 1], [1, 2]]]
s = 4
(3..n).each{|i|
s += i
f_ary, b_ary = b_ary, []
if i % 2 == 1
f_ary.each{|a|
b = a.clone
x, y = *b[-1]
b += (1..i).map{|j| [x + j, y]}
b_ary << b if b.uniq.size == s
c = a.clone
x, y = *c[-1]
c += (1..i).map{|j| [x - j, y]}
b_ary << c if c.uniq.size == s
}
else
f_ary.each{|a|
b = a.clone
x, y = *b[-1]
b += (1..i).map{|j| [x, y + j]}
b_ary << b if b.uniq.size == s
c = a.clone
x, y = *c[-1]
c += (1..i).map{|j| [x, y - j]}
b_ary << c if c.uniq.size == s
}
end
ary << b_ary.size
}
ary
end
p A292793(16)
CROSSREFS
Cf. A101856.
Sequence in context: A085583 A160786 A054154 * A332835 A018469 A098904
KEYWORD
nonn
AUTHOR
Seiichi Manyama, Sep 23 2017
EXTENSIONS
a(25)-a(39) from Bert Dobbelaere, Sep 14 2019
STATUS
approved