<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.bbchallenge.org/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=NicolaeLupescu</id>
	<title>BusyBeaverWiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.bbchallenge.org/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=NicolaeLupescu"/>
	<link rel="alternate" type="text/html" href="https://wiki.bbchallenge.org/wiki/Special:Contributions/NicolaeLupescu"/>
	<updated>2026-04-30T20:32:16Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.43.5</generator>
	<entry>
		<id>https://wiki.bbchallenge.org/w/index.php?title=Antihydra&amp;diff=5126</id>
		<title>Antihydra</title>
		<link rel="alternate" type="text/html" href="https://wiki.bbchallenge.org/w/index.php?title=Antihydra&amp;diff=5126"/>
		<updated>2025-11-21T14:01:32Z</updated>

		<summary type="html">&lt;p&gt;NicolaeLupescu: Added the formula of shifting from Antihydra to Hydra.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{machine|1RB1RA_0LC1LE_1LD1LC_1LA0LB_1LF1RE_---0RA}}{{unsolved|Does Antihydra run forever?}}&lt;br /&gt;
{{TM|1RB1RA_0LC1LE_1LD1LC_1LA0LB_1LF1RE_---0RA|undecided}}, called &#039;&#039;&#039;Antihydra&#039;&#039;&#039;, is a [[BB(6)]] [[Cryptid]]. Its pseudo-random behaviour was first reported [https://discord.com/channels/960643023006490684/1026577255754903572/1256223215206924318 on Discord] by mxdys on 28 June 2024, and Racheline discovered the high-level rules soon after. It was named after the 2-state, 5-symbol [[Turing machine]] called [[Hydra]] for sharing many similarities to it.&amp;lt;ref&amp;gt;[https://discord.com/channels/960643023006490684/960643023530762341/1257053002859286701 Discord conversation where the machine was named]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Antihydra is known to not generate Sturmian words&amp;lt;ref&amp;gt;DUBICKAS A. ON INTEGER SEQUENCES GENERATED BY LINEAR MAPS. &#039;&#039;Glasgow Mathematical Journal&#039;&#039;. 2009;51(2):243-252. doi:[https://doi.org/10.1017/S0017089508004655 10.1017/S0017089508004655]&amp;lt;/ref&amp;gt; (Corollary 4).&lt;br /&gt;
&amp;lt;table style=&amp;quot;margin: auto; text-align: center;&amp;quot;&amp;gt;&amp;lt;tr&amp;gt;&amp;lt;td style=&amp;quot;width: 200px;&amp;quot;&amp;gt;[[File:Antihydra-depiction.png|200px]]&amp;lt;br&amp;gt;Artistic depiction of Antihydra by Jadeix&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin-left: auto; margin-right: auto;&amp;quot;&lt;br /&gt;
! !!0!!1&lt;br /&gt;
|-&lt;br /&gt;
!A&lt;br /&gt;
|1RB&lt;br /&gt;
|1RA&lt;br /&gt;
|-&lt;br /&gt;
!B&lt;br /&gt;
|0LC&lt;br /&gt;
|1LE&lt;br /&gt;
|-&lt;br /&gt;
!C&lt;br /&gt;
|1LD&lt;br /&gt;
|1LC&lt;br /&gt;
|-&lt;br /&gt;
!D&lt;br /&gt;
|1LA&lt;br /&gt;
|0LB&lt;br /&gt;
|-&lt;br /&gt;
!E&lt;br /&gt;
|1LF&lt;br /&gt;
|1RE&lt;br /&gt;
|-&lt;br /&gt;
!F&lt;br /&gt;
| ---&lt;br /&gt;
|0RA&lt;br /&gt;
|}&lt;br /&gt;
The transition table of Antihydra.&lt;br /&gt;
&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[[File:Antihydra_state_diagram.png|200x200px]]&lt;br /&gt;
State diagram of Antihydra&lt;br /&gt;
&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;lt;/td&amp;gt;&amp;lt;td style=&amp;quot;width: 220px;&amp;quot;&amp;gt;[[File:Antihydra award.jpg|220px]]&amp;lt;br&amp;gt;A community trophy - to be awarded to the first person or group who solves the Antihydra problem&lt;br /&gt;
&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[[File:Nico-BB-vs-Antihydra.jpg|thumb|A brave busy beaver confronts the dreaded Antihydra. Copyright [https://www.nicoroper.com/ Nico Roper].]]&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&amp;lt;/table&amp;gt;&lt;br /&gt;
== Analysis ==&lt;br /&gt;
Let &amp;lt;math&amp;gt;A(a,b):=0^\infty\;1^a\;0\;1^b\;\textrm{E}\textrm{&amp;gt;}\;0^\infty&amp;lt;/math&amp;gt;. Then,&amp;lt;ref name=&amp;quot;bl&amp;quot;&amp;gt;S. Ligocki, &amp;quot;[https://www.sligocki.com/2024/07/06/bb-6-2-is-hard.html BB(6) is Hard (Antihydra)]&amp;quot; (2024). Accessed 22 July 2024.&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;\begin{array}{|lll|}\hline&lt;br /&gt;
A(a,2b)&amp;amp; \xrightarrow{2a+3b^2+12b+11}&amp;amp; A(a+2,3b+2),\\&lt;br /&gt;
A(0,2b+1)&amp;amp;\xrightarrow{3b^2+9b-1}&amp;amp; 0^\infty\;\textrm{&amp;lt;}\textrm{F}\;110\;1^{3b}\;0^\infty,\\&lt;br /&gt;
A(a+1,2b+1)&amp;amp;\xrightarrow{3b^2+12b+5}&amp;amp; A(a,3b+3).\\\hline&lt;br /&gt;
\end{array}&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot;&amp;gt;&#039;&#039;&#039;Proof&#039;&#039;&#039;&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
Consider the partial configuration &amp;lt;math&amp;gt;P(m,n):=0\;1^m\;\textrm{E}\textrm{&amp;gt;}\;0\;1^n\;0^\infty&amp;lt;/math&amp;gt;. The configuration after two steps is &amp;lt;math&amp;gt;0\;1^{m-1}\;0\;\textrm{A}\textrm{&amp;gt;}\;1^{n+1}\;0^\infty&amp;lt;/math&amp;gt;. We note the following shift rule:&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;\begin{array}{|c|}\hline\textrm{A}\textrm{&amp;gt;}\;1^s\xrightarrow{s}1^s\;\textrm{A}\textrm{&amp;gt;}\\\hline\end{array}&amp;lt;/math&amp;gt;&lt;br /&gt;
As a result, we get &amp;lt;math&amp;gt;0\;1^{m-1}\;0\;1^{n+1}\;\textrm{A}\textrm{&amp;gt;}\;0^\infty&amp;lt;/math&amp;gt; after &amp;lt;math&amp;gt;n+1&amp;lt;/math&amp;gt; steps. Advancing two steps produces &amp;lt;math&amp;gt;0\;1^{m-1}\;0\;1^{n+2}\;\textrm{&amp;lt;}\textrm{C}\;0^\infty&amp;lt;/math&amp;gt;. A second shift rule is useful here:&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;\begin{array}{|c|}\hline1^s\;\textrm{&amp;lt;}\textrm{C}\xrightarrow{s}\textrm{&amp;lt;}\textrm{C}\;1^s\\\hline\end{array}&amp;lt;/math&amp;gt;&lt;br /&gt;
This allows us to reach &amp;lt;math&amp;gt;0\;1^{m-1}\;0\;\textrm{&amp;lt;}\textrm{C}\;1^{n+2}\;0^\infty&amp;lt;/math&amp;gt; in &amp;lt;math&amp;gt;n+2&amp;lt;/math&amp;gt; steps. Moving five more steps gets us to &amp;lt;math&amp;gt;0\;1^{m-2}\;\textrm{E}\textrm{&amp;gt;}\;0\;1^{n+3}\;0^\infty&amp;lt;/math&amp;gt;, which is the same configuration as &amp;lt;math&amp;gt;P(m-2,n+3)&amp;lt;/math&amp;gt;. Accounting for the head movement creates the condition that &amp;lt;math&amp;gt;m\ge 4&amp;lt;/math&amp;gt;. In summary:&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;\begin{array}{|c|}\hline P(m,n)\xrightarrow{2n+12}P(m-2,n+3)\text{ if }m\ge 4.\\\hline\end{array}&amp;lt;/math&amp;gt;&lt;br /&gt;
With &amp;lt;math&amp;gt;A(a,b)&amp;lt;/math&amp;gt; we have &amp;lt;math&amp;gt;P(b,0)&amp;lt;/math&amp;gt;. As a result, we can apply this rule &amp;lt;math display=&amp;quot;inline&amp;quot;&amp;gt;\big\lfloor\frac{1}{2}b\big\rfloor-1&amp;lt;/math&amp;gt; times (assuming &amp;lt;math&amp;gt;b\ge 4&amp;lt;/math&amp;gt;), which creates two possible scenarios:&lt;br /&gt;
#If &amp;lt;math&amp;gt;b\equiv0\ (\operatorname{mod}2)&amp;lt;/math&amp;gt;, then in &amp;lt;math&amp;gt;\sum_{i=0}^{(b/2)-2}(2\times 3i+12)=\textstyle\frac{3}{4}b^2+\frac{3}{2}b-6&amp;lt;/math&amp;gt; steps we arrive at &amp;lt;math display=&amp;quot;inline&amp;quot;&amp;gt;P\Big(2,\frac{3}{2}b-3\Big)&amp;lt;/math&amp;gt;. The matching complete configuration is &amp;lt;math&amp;gt;0^\infty\;1^a\;011\;\textrm{E}\textrm{&amp;gt;}\;0\;1^{(3b)/2-3}\;0^\infty&amp;lt;/math&amp;gt;. After &amp;lt;math&amp;gt;3b+4&amp;lt;/math&amp;gt; steps this is &amp;lt;math&amp;gt;0^\infty\;1^a\;\textrm{&amp;lt;}\textrm{C}\;00\;1^{(3b)/2}\;0^\infty&amp;lt;/math&amp;gt;, which then leads to &amp;lt;math&amp;gt;0^\infty\;\textrm{&amp;lt;}\textrm{C}\;1^a\;00\;1^{(3b)/2}\;0^\infty&amp;lt;/math&amp;gt; in &amp;lt;math&amp;gt;a&amp;lt;/math&amp;gt; steps. After five more steps, we reach &amp;lt;math&amp;gt;0^\infty\;1\;\textrm{E}\textrm{&amp;gt;}\;1^{a+2}\;00\;1^{(3b)/2}\;0^\infty&amp;lt;/math&amp;gt;, from which another shift rule must be applied:&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;\begin{array}{|c|}\hline\textrm{E}\textrm{&amp;gt;}\;1^s\xrightarrow{s}1^s\;\textrm{E}\textrm{&amp;gt;}\\\hline\end{array}&amp;lt;/math&amp;gt;Doing so allows us to get the configuration &amp;lt;math&amp;gt;0^\infty\;1^{a+3}\;\textrm{E}\textrm{&amp;gt;}\;00\;1^{(3b)/2}\;0^\infty&amp;lt;/math&amp;gt; in &amp;lt;math&amp;gt;a+2&amp;lt;/math&amp;gt; steps. In six steps we have &amp;lt;math&amp;gt;0^\infty\;1^{a+2}\;011\;\textrm{E}\textrm{&amp;gt;}\;1^{(3b)/2}\;0^\infty&amp;lt;/math&amp;gt;, so we use the shift rule again, ending at &amp;lt;math&amp;gt;0^\infty\;1^{a+2}\;0\;1^{(3b)/2+2}\;\textrm{E}\textrm{&amp;gt;}\;0^\infty&amp;lt;/math&amp;gt;, equal to &amp;lt;math display=&amp;quot;inline&amp;quot;&amp;gt;A\Big(a+2,\frac{3}{2}b+2\Big)&amp;lt;/math&amp;gt;, &amp;lt;math display=&amp;quot;inline&amp;quot;&amp;gt;\frac{3}{2}b&amp;lt;/math&amp;gt; steps later. This gives a total of &amp;lt;math display=&amp;quot;inline&amp;quot;&amp;gt;2a+\frac{3}{4}b^2+6b+11&amp;lt;/math&amp;gt; steps.&lt;br /&gt;
#If &amp;lt;math&amp;gt;b\equiv1\ (\operatorname{mod}2)&amp;lt;/math&amp;gt;, then in &amp;lt;math display=&amp;quot;inline&amp;quot;&amp;gt;\frac{3}{4}b^2-\frac{27}{4}&amp;lt;/math&amp;gt; steps we arrive at &amp;lt;math display=&amp;quot;inline&amp;quot;&amp;gt;P\Big(3,\frac{3b-9}{2}\Big)&amp;lt;/math&amp;gt;. The matching complete configuration is &amp;lt;math&amp;gt;0^\infty\;1^a\;0111\;\textrm{E}\textrm{&amp;gt;}\;0\;1^{(3b-9)/2}\;0^\infty&amp;lt;/math&amp;gt;. After &amp;lt;math&amp;gt;3b+2&amp;lt;/math&amp;gt; steps this becomes &amp;lt;math&amp;gt;0^\infty\;1^a\;\textrm{&amp;lt;}\textrm{F}\;110\;1^{(3b-3)/2}\;0^\infty&amp;lt;/math&amp;gt;. If &amp;lt;math&amp;gt;a=0&amp;lt;/math&amp;gt; then we have reached the undefined &amp;lt;code&amp;gt;F0&amp;lt;/code&amp;gt; transition with a total of &amp;lt;math display=&amp;quot;inline&amp;quot;&amp;gt;\frac{3}{4}b^2+3b-\frac{19}{4}&amp;lt;/math&amp;gt; steps. Otherwise, continuing for six steps gives us &amp;lt;math&amp;gt;0^\infty\;1^{a-1}\;0111\;\textrm{E}\textrm{&amp;gt;}\;1^{(3b-3)/2}\;0^\infty&amp;lt;/math&amp;gt;. We conclude with the configuration &amp;lt;math&amp;gt;0^\infty\;1^{a-1}\;0\;1^{(3b+3)/2}\;\textrm{E}\textrm{&amp;gt;}\;0^\infty&amp;lt;/math&amp;gt;, equal to &amp;lt;math display=&amp;quot;inline&amp;quot;&amp;gt;A\Big(a-1,\frac{3b+3}{2}\Big)&amp;lt;/math&amp;gt;, in &amp;lt;math display=&amp;quot;inline&amp;quot;&amp;gt;\frac{3b-3}{2}&amp;lt;/math&amp;gt; steps. This gives a total of &amp;lt;math display=&amp;quot;inline&amp;quot;&amp;gt;\frac{3}{4}b^2+\frac{9}{2}b-\frac{1}{4}&amp;lt;/math&amp;gt; steps.&lt;br /&gt;
The information above can be summarized as&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;A(a,b)\rightarrow\begin{cases}A\Big(a+2,\frac{3}{2}b+2\Big)&amp;amp;\text{if }b\ge 2,b\equiv0\pmod{2};\\0^\infty\;\textrm{&amp;lt;}\textrm{F}\;110\;1^{(3b-3)/2}\;0^\infty&amp;amp;\text{if }b\ge3,b\equiv1\pmod{2},\text{ and }a=0;\\A\Big(a-1,\frac{3b+3}{2}\Big)&amp;amp;\text{if }b\ge3,b\equiv1\pmod{2},\text{ and }a&amp;gt;0.\end{cases}&amp;lt;/math&amp;gt;&lt;br /&gt;
Substituting &amp;lt;math&amp;gt;b\leftarrow 2b&amp;lt;/math&amp;gt; for the first case and &amp;lt;math&amp;gt;b\leftarrow 2b+1&amp;lt;/math&amp;gt; for the other two yields the final result.&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
In effect, the halting problem for Antihydra is about whether repeatedly applying the function &amp;lt;math display=&amp;quot;inline&amp;quot;&amp;gt;f(n)=\Big\lfloor\frac{3n}{2}\Big\rfloor+2&amp;lt;/math&amp;gt; will at some point produce more odd values of &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt; than twice the number of even values. This pattern can be easily reduced to the [[Hydra function]] &amp;lt;math display=&amp;quot;inline&amp;quot;&amp;gt;H(n)=\Big\lfloor\frac{3n}{2}\Big\rfloor&amp;lt;/math&amp;gt;, strengthening Antihydra&#039;s similarities to Hydra, since the function is equivalent to &amp;lt;math&amp;gt;f(n) + 4 = \lfloor \frac{3(n+4)}{2} \rfloor&amp;lt;/math&amp;gt;. Notice this shifting should also be performed to the starting value, as shown in the [[Antihydra#Code|code]] below.&lt;br /&gt;
&lt;br /&gt;
== Trajectory ==&lt;br /&gt;
[[File:Antihydra Walk.png|thumb|Path of parity of repeated applications of Hydra map for Antihydra.]]&lt;br /&gt;
Starting from a blank tape, Antihydra reaches &amp;lt;math&amp;gt;A(0, 4)&amp;lt;/math&amp;gt; in 11 steps and then the rules are repeatedly applied. So far, Antihydra has been simulated to &amp;lt;math&amp;gt;2^{38}&amp;lt;/math&amp;gt; rule steps,&amp;lt;ref&amp;gt;https://discord.com/channels/960643023006490684/1026577255754903572/1271528180246773883&amp;lt;/ref&amp;gt; at which point &amp;lt;math&amp;gt;a&amp;lt;/math&amp;gt; exceeds &amp;lt;math&amp;gt;2^{37}&amp;lt;/math&amp;gt;. Here are the first few:&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;\begin{array}{|c|}\hline A(0,4)\xrightarrow{47}A(2,8)\xrightarrow{111}A(4,14)\xrightarrow{250}A(6,23)\xrightarrow{500}A(5,36)\xrightarrow{1209}A(7,56)\xrightarrow{2713}A(9,86)\rightarrow\cdots\\\hline\end{array}&amp;lt;/math&amp;gt;&lt;br /&gt;
The trajectory of &amp;lt;math&amp;gt;a&amp;lt;/math&amp;gt; values resembles a random walk in which the walker can only move in step sizes +2 or -1 with equal probability, starting at position 0. If &amp;lt;math&amp;gt;P(n)&amp;lt;/math&amp;gt; is the probability that the walker will reach position -1 from position &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt;, then it can be seen that &amp;lt;math display=&amp;quot;inline&amp;quot;&amp;gt;P(n)=\frac{1}{2}P(n-1)+\frac{1}{2}P(n+2)&amp;lt;/math&amp;gt;. Solutions to this recurrence relation come in the form &amp;lt;math display=&amp;quot;inline&amp;quot;&amp;gt; P(n)=c_0{\left(\frac{\sqrt{5}-1}{2}\right)}^n+c_1+c_2{\left(-\frac{1+\sqrt{5}}{2}\right)}^n&amp;lt;/math&amp;gt;, which after applying the appropriate boundary conditions reduces to &amp;lt;math display=&amp;quot;inline&amp;quot;&amp;gt;P(n)={\left(\frac{\sqrt{5}-1}{2}\right)}^{n+1}&amp;lt;/math&amp;gt;. This means that if the walker were to get to the position of the current &amp;lt;math&amp;gt;a&amp;lt;/math&amp;gt; value, then the probability of it ever reaching position -1 is less than &amp;lt;math display=&amp;quot;inline&amp;quot;&amp;gt;{\left( \frac{\sqrt{5}-1}{2} \right)}^{2^{37}}\approx 2.884\times 10^{-28723042565}&amp;lt;/math&amp;gt;. This combined with the fact that the expected position of the walker after &amp;lt;math&amp;gt;k&amp;lt;/math&amp;gt; steps is &amp;lt;math display=&amp;quot;inline&amp;quot;&amp;gt;\frac{1}{2}k&amp;lt;/math&amp;gt; strongly suggests Antihydra [[probviously]] runs indefinitely.&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
The following Python program implements the abstracted behavior of the Antihydra. Proving whether it halts or not would also solve the Antihydra problem:&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
# Current value of the iterated Hydra function starting with initial value 8 (the values do not overflow)&lt;br /&gt;
h = 8 # 4 shifted by 4.&lt;br /&gt;
# (Collatz-like) condition counter that keeps track of how many odd and even numbers have been encountered&lt;br /&gt;
c = 0&lt;br /&gt;
# If c equals -1 there have been (strictly) more than twice as many odd as even numbers and the program halts&lt;br /&gt;
while c != -1:&lt;br /&gt;
    # If h is even, add 2 to c so even numbers count twice&lt;br /&gt;
    if h % 2 == 0:&lt;br /&gt;
        c += 2&lt;br /&gt;
    else:&lt;br /&gt;
        c -= 1&lt;br /&gt;
    # Add the current hydra value divided by two (integer division, rounding down) to itself (Hydra function, instead of Antihydra)&lt;br /&gt;
    # Note that integer division by 2 is equivalent to one bit shift to the right (h &amp;gt;&amp;gt; 1)&lt;br /&gt;
    h += h//2&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The variable values of this iteration have been put into the On-Line Encyclopedia of Integer Sequences (OEIS):&lt;br /&gt;
&lt;br /&gt;
* Hydra function values with Antihydra&#039;s starting value 8: https://oeis.org/A386792&lt;br /&gt;
* Antihydra&#039;s condition values: https://oeis.org/A385902&lt;br /&gt;
&lt;br /&gt;
Fast [[Hydra]]/Antihydra simulation code by Greg Kuperberg (who said it could be made faster using FLINT):&amp;lt;syntaxhighlight lang=&amp;quot;python2&amp;quot; line=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
# Python script to demonstrate almost linear time hydra simulation&lt;br /&gt;
# using fast multiplication. &lt;br /&gt;
# by Greg Kuperberg&lt;br /&gt;
&lt;br /&gt;
import time&lt;br /&gt;
from gmpy2 import mpz,bit_mask&lt;br /&gt;
&lt;br /&gt;
# Straight computation of t steps of hydra&lt;br /&gt;
def simple(n,t):&lt;br /&gt;
    for s in range(t): n += n&amp;gt;&amp;gt;1&lt;br /&gt;
    return n&lt;br /&gt;
&lt;br /&gt;
# Accelerated computation of 2**e steps of hydra&lt;br /&gt;
def hydra(n,e):&lt;br /&gt;
    if e &amp;lt; 9: return simple(n,1&amp;lt;&amp;lt;e)&lt;br /&gt;
    t = 1&amp;lt;&amp;lt;(e-1)&lt;br /&gt;
    (p3t,m) = (mpz(3)**t,bit_mask(t))&lt;br /&gt;
    n = p3t*(n&amp;gt;&amp;gt;t) + hydra(n&amp;amp;m,e-1)&lt;br /&gt;
    return p3t*(n&amp;gt;&amp;gt;t) + hydra(n&amp;amp;m,e-1)&lt;br /&gt;
&lt;br /&gt;
def elapsed():&lt;br /&gt;
    (last,elapsed.mark) = (elapsed.mark,time.process_time())&lt;br /&gt;
    return elapsed.mark-last&lt;br /&gt;
elapsed.mark = 0&lt;br /&gt;
&lt;br /&gt;
(n,e) = (mpz(3),25)&lt;br /&gt;
&lt;br /&gt;
elapsed()&lt;br /&gt;
print(&#039;hydra:  steps=%d hash=%016x time=%.6fs&#039;&lt;br /&gt;
    % (1&amp;lt;&amp;lt;e,hash(hydra(n,e)),elapsed()))&lt;br /&gt;
&lt;br /&gt;
# Quadratic time algorithm for comparison&lt;br /&gt;
# print(&#039;simple: steps=%d hash=%016x time=%.6fs&#039;&lt;br /&gt;
#     % (1&amp;lt;&amp;lt;e,hash(simple(n,1&amp;lt;&amp;lt;e)),elapsed()))&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
[[Category:BB(6)]][[Category:Cryptids]]&lt;/div&gt;</summary>
		<author><name>NicolaeLupescu</name></author>
	</entry>
</feed>