login
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

%I #28 Sep 14 2019 17:48:23

%S 1,2,4,8,16,29,54,98,176,318,572,1026,1826,3255,5794,10233,18172,

%T 32012,56488,99469,175034,307479,540068,947235,1659907,2908958,

%U 5095019,8917677,15598100,27281252,47718310,83298748,145405769,253641303,442352671,770769569,1343166519,2339093953

%N 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.)

%e a(2) = 1;

%e E

%e |

%e *

%e |

%e S--*

%e a(3) = 2;

%e *--*--*--E E--*--*--*

%e | |

%e * *

%e | |

%e S--* S--*

%e a(4) = 4;

%e E E

%e | |

%e * *

%e | |

%e * *

%e | |

%e * *

%e | |

%e *--*--*--* *--*--*--* *--*--*--* *--*--*--*

%e | | | | | |

%e * * * * * *

%e | | | | | |

%e S--* S--* * * S--* S--*

%e | |

%e E E

%o (Ruby)

%o def A292793(n)

%o ary = [1]

%o b_ary = [[[0, 0], [1, 0], [1, 1], [1, 2]]]

%o s = 4

%o (3..n).each{|i|

%o s += i

%o f_ary, b_ary = b_ary, []

%o if i % 2 == 1

%o f_ary.each{|a|

%o b = a.clone

%o x, y = *b[-1]

%o b += (1..i).map{|j| [x + j, y]}

%o b_ary << b if b.uniq.size == s

%o c = a.clone

%o x, y = *c[-1]

%o c += (1..i).map{|j| [x - j, y]}

%o b_ary << c if c.uniq.size == s

%o }

%o else

%o f_ary.each{|a|

%o b = a.clone

%o x, y = *b[-1]

%o b += (1..i).map{|j| [x, y + j]}

%o b_ary << b if b.uniq.size == s

%o c = a.clone

%o x, y = *c[-1]

%o c += (1..i).map{|j| [x, y - j]}

%o b_ary << c if c.uniq.size == s

%o }

%o end

%o ary << b_ary.size

%o }

%o ary

%o end

%o p A292793(16)

%Y Cf. A101856.

%K nonn

%O 2,2

%A _Seiichi Manyama_, Sep 23 2017

%E a(25)-a(39) from _Bert Dobbelaere_, Sep 14 2019