Monday, 2 June 2025

Google AI Studio and Related Disasters

I created a program in a Jupyter notebook that accepts a single number as input and then displays various properties of the number as a simple text output. I put the following prompt to Google's AI Studio:

The following code is what I created using SageMath. It is designed to accept a single number as input. Typically the number has five digits corresponding to my age in days (I'm currently 27819 days old). I'm using the program to find out interesting numerical facts about this number associated with my diurnal age. By trial and error I've had to limit the number of iterations for various tasks or else the program is too slow or crashes. For example, in finding the home prime for a number I've limited the iterations to just 10. What I want is to improve the output of this code to make it more readable and more informative in terms of additional graphs or charts? Feel free to modify the code to make it more efficient, informative or comprehensible. The code modifications can be in Python or SageMath, whatever is easier for you. I just need the program to run in a Jupyter notebook using an M1 Macbook Air and execute within say a minute or so. Any annotations, charts or tables that will enhance the output of the program will be appreciated. Any additional fun facts about the input number can be added to the program as you see fit. The key challenge is to enhance the output which is currently quite basic and limited to simple text. It's important that spacing between the different sections be consistent and that the various sections are clearly identified. I've added some commentary to each section but this can be expanded or modified if desired. 

What followed was something of a nightmare as the resulting code that was produced was full of bugs that AI Studio was never able to fix. Once I did get the code to run but many of the number properties that were displayed in my original code were no longer there. To be fair, it did produce a much improved output for the sections where it did work as can be seen in Figure 1. However, the attempts to get the code to run properly were frustrating and ultimately futile. 


Figure 1

There are numerous alternatives out there and I'll have to turn to them if I want to generate code that works. I tried ChatGPT and it revised the faulty AI Studio code but stopped at line 106 (there are about 875 lines of code) probably because I'd exceeded my free allowance of tokens. So dead end there.

Grok 3 failed to understand that the Jupyter notebook can be set to SageMath 10.3 not just Python 3 and gave the following comments:

The code you provided appears to be written for SageMath, but you're trying to run it in a Jupyter notebook, which typically uses a Python kernel with libraries like Matplotlib. This mismatch is likely causing some of the errors, as SageMath-specific functions and syntax (e.g., latex(), N(), Integer(), and certain mathematical operations) aren't directly compatible with a standard Python environment. Additionally, there are a few other issues that could lead to errors, such as undefined variables, plotting issues, and missing imports.

I'll modify the code to make it compatible with a standard Jupyter notebook environment using Python 3, while preserving its core functionality. I'll replace SageMath-specific functions with equivalent Python alternatives, ensure proper imports, and fix potential glitches.

After Grok 3 turned all the code to Python 3, it was still full of bugs and never managed to execute all the code. I'm getting the feeling that my original code, written in SageMath, is possibly at the core of the problem. When an AI tries to improve the code, using SageMath or Python, then all sorts of glitches arise because of the modifications to my original code. It would be better to build the whole code base from scratch using Python only and indicating exactly what I want. One thing I've realised is that LaTeX can be applied to the Jupyter notebook output to greatly improve readability.

It occurred to me that I lot of my code just reproduces what a site like Numbers Aplenty always publicly provides. I asked Gemini 2.5 Flash the following question:

Is it possible to create Python code that draws on the content of a site like Numbers Aplenty. For example, let's say I enter 27819 into my program. Can I get the program to then access https://www.numbersaplenty.com/27819 and extract some or all of the information from it. For example, one of the properties of the number that the site displays is "It is a junction number, because it is equal to n+sod(n) for n = 27792 and 27801". Can I get this information to show up as output in my code? If it is feasible then could you create the necessary code to do this or explain why this is not possible.

The response was encouraging:

Yes, it is absolutely possible to create Python code that draws on the content of a site like Numbers Aplenty and extracts specific information. This process is commonly known as web scraping. Numbers Aplenty doesn't seem to offer a public API (Application Programming Interface) for directly accessing its data in a structured format. This means we'll need to use web scraping techniques. 

It then went on to confidently provide code for doing this but of course it didn't work. Excuses were made and additional programs and drivers were recommended for download to remedy the problem. In short, no go. I should try other AI tools but frankly the whole process has exhausted me. I need a rest.

Saturday, 31 May 2025

Self Avoiding Walks

In my previous post titled Random Walks, I made mention of self-avoiding walks and for this post I asked Gemini 2.5 Pro to implement the following program:

Write a program in Python that will generate and display a random but self avoiding walk on a square grid of points. The size of the grid can be 100 x 100 points but this should be easily modifiable. The walk should start at the bottom left hand side and proceed to the top right hand side. Each step can be up or down from one point to the next or left or right from one point to the next but movement is contrained within the grid of points. The number of steps required to complete the walk should be prominently displayed at the top or bottom of the display.

It dutifully did this and here is the Canvas link. Here was Gemini's thinking about the desired program.

Okay, I'll provide you with a Python program that generates and displays a random self-avoiding walk on a square grid. This program uses a recursive backtracking algorithm to find a path from the bottom-left corner to the top-right corner. The grid size is easily modifiable.

Here's how the program works:

  1. Grid and Path Representation: The grid is implicitly defined by its size. The path is stored as a list of (x, y) coordinate tuples.
  2. Self-Avoiding Walk Generation:
    • It starts at (0,0) (bottom-left).
    • The target is (grid_size-1, grid_size-1) (top-right).
    • A recursive function attempts to find a path:
      • It marks the current cell as visited and adds it to the path.
      • If the current cell is the target, the path is found.
      • Otherwise, it randomly shuffles the possible directions (Up, Down, Left, Right).
      • For each valid direction (within bounds and not previously visited in the current path), it makes a recursive call.
      • If a recursive call returns success, the path is propagated up.
      • If all directions from the current cell lead to dead ends, it backtracks by removing the cell from the path and unmarking it as visited.
    • Due to the potential for deep recursion, especially on large grids (like 100x100), the program attempts to increase Python's recursion limit. Note that for very large grids, this process can still be computationally intensive and take some time.
  3. Display:
    • matplotlib is used to visualize the walk.
    • The path is plotted on the grid.
    • Start and end points are highlighted.
    • The number of steps taken is displayed in the plot title.

I will now generate the Python code for you.

Self-Avoiding Random Walk Generator

This Python script defines two main functions: generate_self_avoiding_walk to create the path and display_walk to visualize it using matplotlib.

To use this code:

  1. Save it as a Python file (e.g., saw_generator.py).
  2. Make sure you have matplotlib installed (pip install matplotlib).
  3. Run it from your terminal: python saw_generator.py.
  4. You can easily change the GRID_SIZE variable in the if __name__ == "__main__": block to generate walks on grids of different sizes. Keep in mind that larger grids (e.g., 100x100) will take significantly longer to compute and may require a high recursion limit, which the script attempts to set.

The generated plot will show the random walk, and the title will include the number of steps taken.

I should try to implement this program myself using SageMathCell. Running the program on SageMathCell using only for a 20m x 20 grid will often cause it to time out and even in my Jupyter notebook I often needed to terminate the process because it was taking too long. However, the program often generates a walk quite quickly and Figures 1 and 2 show typical outputs.


Figure 1: permalink


Figure 2: permalink

The difference between Figures 1 and 2 in this post compared to Figure 9 in my previous post is that the latter traverses every point in the grid and not just a random selection of them. Gemini will write a program to do this but as it explains:
Finding a Hamiltonian path is an NP-complete problem. This means that for larger grids, the time required to find such a path can grow extremely rapidly. The provided recursive backtracking algorithm will explore many possibilities. For a small grid (e.g., 3x3, 4x4, maybe 5x5), it might find a solution in a reasonable time.

Here is a Canvas link to the code. Figure 3 shows a typical output using a 4 x 4 grid.


Figure 3

Friday, 30 May 2025

Random Walks

On the 20th of December 2018, I uploaded a post titled Random Walks in which I looked at random walks within a grids of fixed size. For example, consider a 4 x 4 grid of points where the walk starts at (0, 0) and finishes at (4, 4). Movement can be vertical (up or down) or horizontal (left or right) but is confined to the grid. Diagonal movement in one step is not possible. See Figure 1.


Figure 1

I created a program (permalink) to simulate 1000 random walks and calculate the median of the number of steps required to travel from (0, 0) to (4, 4). It turned out to be about 60 steps. In this post, I looked at other 2-D grid sizes and also random walks in 3 dimensions with varying grid sizes (permalink). See Figure 2.


Figure 2

This present post was inspired by a Cliff Pickover tweet. See Figure 3.


Figure 3

I created a SageMath program (permalink) to simulate a 2-D random walk starting at the origin and concluding at the origin (if it is ever reached). Movement can be up or down one step and\or left or right one step, so diagonal movement is possible. See Figure 4.

Figure 4

I set a step limit of 100,000 and quite often the walk had not returned to the origin by then. See Figure 5.


Figure 5

At other times, it would return to the origin within the limit imposed. See Figure 6 and Figure 7.


Figure 6


Figure 7

Often the walk will end after a few dozen steps or less and these shorter walks are by far the most common. See Figure 8.


Figure 8

This was just an introductory look at 2-D random walks upon an infinite grid and there's much more to explore. As an example, Figure 9 shows another tweet from Cliff Pickover regarding SAW (Self Avoiding Walks).


Figure 9

Bertrand's Box Paradox

 I came across the following problem in my Inbox:

I have placed three coins inside a bag. The first coin has heads on both of its sides, the second coin has tails on both of its sides, and the third coin has heads on one side and tails on the other side.

I randomly take one coin from the bag. I open my hand and look at it. I notice that the side facing me is heads. What is the probability that the other side of the coin is also heads?

A. Less than 50%, B. More than 50% or C. Exactly 50%

I went for the exactly 50% option, which unfortunately proved to wrong. The correct answer was more than 50% and the following explanation was offered:

This puzzle is a variant of the Bertrand’s box paradox, and the exact answer is that there is a 2/3rds chance that the other side of the coin is also heads. However, many people answering this question intuitively say there is a 50% chance.

The best way to think of this problem is in terms of sides, not individual coins that have two sides. We are told that there are three heads sides in total. The heads side that you viewed could be any of the three heads sides in the bag. Two of the three heads sides in the bag have heads on the other side, therefore there is a 2/3rds chance that the other side of the coin you viewed is also heads.

I was thus prompted to find out more about Bertrand's Box Paradox and this is what Gemini had to say:

Bertrand's Box Paradox is a classic problem in probability theory that often trips people up because their intuition leads them to the wrong answer. It's a "veridical paradox," meaning the solution is indeed counter-intuitive but demonstrably correct.

Here's the setup:

Imagine you have three identical boxes:

  1. Box 1 (GG): Contains two gold coins.

  2. Box 2 (SS): Contains two silver coins.

  3. Box 3 (GS): Contains one gold coin and one silver coin.

You randomly choose one of the three boxes. Then, you randomly draw one coin from that chosen box.

The Paradoxical Question:

If the coin you drew is gold, what is the probability that the other coin remaining in that same box is also gold?

Why it's confusing (the intuitive, but wrong, answer):

Many people would intuitively say 1/2 (50%). Their reasoning often goes like this:

"Since I drew a gold coin, I know I didn't pick Box 2 (SS). So, it must be either Box 1 (GG) or Box 3 (GS). Since there are only two possibilities, and one of them (GG) means the other coin is gold, it's 1/2."

Why this reasoning is flawed:

The flaw lies in assuming that Box 1 (GG) and Box 3 (GS) are equally likely given that you drew a gold coin. This is not true.

The Correct Solution (and why it's 2/3):

Let's break down the possibilities more systematically. There are a total of 6 coins (2 gold, 2 silver, 1 gold, 1 silver). Each coin has an equal chance of being drawn initially.

Consider all the ways you could draw a gold coin:

  1. From Box 1 (GG): You could draw the first gold coin, and the other coin is gold. (Let's call this G1a)

  2. From Box 1 (GG): You could draw the second gold coin, and the other coin is gold. (Let's call this G1b)

  3. From Box 3 (GS): You could draw the gold coin, and the other coin is silver. (Let's call this G3)

These are the only three ways you could have drawn a gold coin. Each of these three "initial gold coin draws" is equally likely.

Now, let's look at what the other coin in the box would be for each of these three equally likely scenarios:

  1. If you drew G1a (from Box 1), the other coin is gold.

  2. If you drew G1b (from Box 1), the other coin is gold.

  3. If you drew G3 (from Box 3), the other coin is silver.

Out of the three equally likely ways to draw a gold coin, two of those ways result in the other coin also being gold.

Therefore, the probability that the other coin in the box is also gold is 2/3.

Analogy to help understand:

Imagine you have six coins laid out on a table:

  • G1 G2 (from Box 1)

  • S1 S2 (from Box 2)

  • G3 S3 (from Box 3)

You close your eyes and pick one coin. You open your hand and it's gold. Which gold coin did you pick? It could be G1, G2, or G3.

  • If you picked G1, the other coin in its pair (from Box 1) is G2 (gold).

  • If you picked G2, the other coin in its pair (from Box 1) is G1 (gold).

  • If you picked G3, the other coin in its pair (from Box 3) is S3 (silver).

Since G1, G2, and G3 were all equally likely to be picked as your first gold coin, and two out of those three scenarios lead to the other coin being gold, the probability is 2/3.

The key takeaway is that when you draw a gold coin, you gain information that changes the probabilities of which box you initially chose. The box with two gold coins is twice as likely to yield a gold coin on the first draw compared to the box with one gold and one silver coin.

Thursday, 29 May 2025

Xenodrome Pairs, Triplets Etc.

27815, the number associated with my diurnal age today, is one of those numbers for which an interesting property is hard to come by. However, I did notice that the number was a xenodrome in both base 10 and base 9 (42135). A little further investigation revealed that 27816 also shared this property. That got me thinking about how often pairs of such numbers occur. Now I've written about xendromes before in posts titled Xenodromes and Xenodrome Probabilities in which I've looked at numbers that remain xenodromes in various bases but so far I've not looked at groupings of numbers by pairs, triplets, quadruplets etc. with properties relating to xenodromes.

In my Bespoken for Sequences database, I've listed the following sequence of numbers:Smaller of a pair of consecutive numbersthat are xenodromes in base 10 and base 9Between 27815 and 40000, there are 282 numbers with this property (permalink):

27815, 27834, 27835, 27845, 27860, 27950, 27953, 27960, 28013, 28016, 28134, 28169, 28195, 28196, 28314, 28346, 28356, 28364, 28395, 28456, 28495, 28509, 28536, 28563, 28573, 28590, 28609, 28670, 28914, 28934, 28935, 28963, 29015, 29016, 29053, 29075, 29084, 29085, 29103, 29134, 29147, 30147, 30148, 30156, 30157, 30186, 30194, 30195, 30196, 30457, 30458, 30467, 30528, 30548, 30561, 30591, 30691, 30724, 30725, 30751, 30764, 30814, 30825, 30851, 30924, 30925, 31024, 31025, 31048, 31057, 31086, 31094, 31095, 31096, 31097, 31257, 31258, 31259, 31267, 31268, 31284, 31294, 31475, 31586, 31604, 31607, 31608, 31806, 31824, 31825, 31826, 31859, 31905, 31906, 31907, 32018, 32104, 32108, 32159, 32189, 32496, 32508, 32509, 32546, 32580, 32589, 32590, 32607, 32608, 32609, 32648, 32657, 32670, 32689, 32690, 32697, 32907, 32947, 32960, 32964, 34027, 34058, 34085, 34086, 34091, 34095, 34127, 34157, 34158, 34175, 34185, 34206, 34215, 34275, 34278, 34279, 34296, 34297, 34560, 34567, 34568, 34569, 34578, 34620, 34650, 34658, 34761, 34785, 34815, 34820, 34905, 34917, 34926, 35016, 35017, 35047, 35097, 35169, 35196, 35197, 35208, 35216, 35217, 35479, 35486, 35496, 35641, 35809, 35826, 35890, 35891, 35916, 35917, 35946, 35961, 35970, 35971, 35980, 35981, 36018, 36027, 36028, 36208, 36209, 36214, 36218, 36270, 36278, 36279, 36280, 36289, 36290, 37195, 37204, 37245, 37285, 37294, 37295, 37458, 37459, 37485, 37495, 37519, 37520, 37528, 37568, 37819, 37820, 37845, 37864, 37890, 37891, 37920, 37945, 37964, 37981, 38015, 38024, 38045, 38046, 38064, 38105, 38106, 38124, 38145, 38159, 38169, 38205, 38206, 38240, 38249, 38250, 38259, 38260, 38405, 38406, 38415, 38420, 38469, 38649, 38670, 38674, 38694, 38701, 38720, 38724, 38751, 38760, 38904, 38916, 39015, 39016, 39017, 39024, 39025, 39026, 39124, 39125, 39126, 39186, 39205, 39206, 39207, 39215, 39216, 39240, 39260, 39481, 39485, 39540, 39541, 39571, 39580, 39604, 39701, 39715, 39724, 39764, 39805, 39814, 39845, 39846

There are 69  triplets in the same range (permalink):Smallest of a triplet of consecutive numbersthat are xenodromes in base 10 and base 927834, 28195, 28934, 29015, 29084, 30147, 30156, 30194, 30195, 30457, 30724, 30924, 31024, 31094, 31095, 31096, 31257, 31258, 31267, 31607, 31824, 31825, 31905, 31906, 32508, 32589, 32607, 32608, 32689, 34085, 34157, 34278, 34296, 34567, 34568, 35016, 35196, 35216, 35890, 35916, 35970, 35980, 36027, 36208, 36278, 36279, 36289, 37294, 37458, 37519, 37819, 37890, 38045, 38105, 38205, 38249, 38259, 38405, 39015, 39016, 39024, 39025, 39124, 39125, 39205, 39206, 39215, 39540, 39845

An example is the xenodrome 27834 with 27835 and 27836 also xenodromes. The base 9 equivalents 42156, 42157 and 42158 are also xenodromes.

There are 13 quadruplets in the same range (permalink):Smallest of a quaduplet of consecutive numbersthat are xenodromes in base 10 and base 930194, 31094, 31095, 31257, 31824, 31905, 32607, 34567, 36278, 39015, 39024, 39124, 39205

An example is the xenodrome 30194 with 30195, 30196 and 30197 also xenodromes. The base 9 equivalents 45368, 45370, 45371 and 45372 are also xenodromes. 

There is only one quintuplet in the range and that is 31094. Here we see that 31094, 31095, 31096, 31097 and 31098 are all xenodromes as are their base 9 equivalents 46578, 46580, 46581, 46582 and 46583.

Sunday, 25 May 2025

More on A + B + C = D and A + B = C

In my previous post titled A + B + C = D, I generated a list of 44 "d" numbers with the property that:a+b+c=dwhere a, b, c and d share the same digits and a<b<c. The list of such numbers, up to 40000, is:

4617, 4851, 5103, 5184, 5913, 6021, 6129, 6192, 6219, 6291, 6921, 7182, 7281, 7416, 7614, 8145, 8154, 8253, 8325, 8451, 8514, 8523, 8541, 9135, 9216, 9234, 9324, 9612, 9621, 31860, 31905, 36171, 36711, 37116, 37161, 38061, 38106, 38151, 38214, 38511, 39051, 39105, 39411, 39501

In my post I noted the significant gap between sequence member 9621 and sequence member 31860. This was unfortunate as I'm currently 27811 days old and so all the numbers associated with my diurnal age, now and for some considerable time into the future, fall into this gap. The problem arises because I'm only displaying the sums, d, resulting from the addition of the three smaller numbers a, b and c.

What I needed to do was to extend the range of d numbers to 100,000 and then include all a, b, c and d numbers in a range let's say from 27810 to 40000. Doing this I get a far more useful list of numbers. Here is the expanded list (Google Doc link):

27810, 27864, 27891, 27936, 27954, 27963, 28017, 28026, 28035, 28062, 28071, 28116, 28125, 28161, 28170, 28179, 28197, 28206, 28215, 28260, 28269, 28359, 28413, 28458, 28467, 28476, 28512, 28521, 28539, 28548, 28593, 28611, 28647, 28674, 28692, 28701, 28710, 28719, 28746, 28764, 28791, 28845, 28854, 28863, 28917, 28935, 28953, 28962, 28971, 29016, 29034, 29043, 29061, 29106, 29160, 29178, 29187, 29268, 29304, 29340, 29358, 29367, 29385, 29394, 29439, 29448, 29475, 29493, 29538, 29583, 29601, 29610, 29628, 29637, 29673, 29682, 29718, 29754, 29763, 29781, 29817, 29835, 29853, 29871, 29961, 30015, 30150, 30159, 30168, 30195, 30285, 30294, 30429, 30492, 30519, 30582, 30591, 30627, 30681, 30726, 30825, 30852, 30924, 30942, 30951, 31059, 31068, 31149, 31158, 31176, 31185, 31464, 31491, 31509, 31590, 31599, 31608, 31635, 31644, 31653, 31680, 31689, 31698, 31761, 31788, 31806, 31815, 31842, 31860, 31869, 31878, 31896, 31905, 31959, 31968, 31986, 31995, 32049, 32076, 32085, 32148, 32418, 32481, 32490, 32499, 32580, 32607, 32679, 32697, 32760, 32769, 32796, 32814, 32841, 32850, 32859, 32886, 32895, 32904, 32958, 32967, 32976, 32985, 32994, 34029, 34119, 34128, 34164, 34182, 34218, 34281, 34299, 34461, 34614, 34641, 34812, 34821, 34911, 34992, 35019, 35082, 35091, 35109, 35118, 35190, 35217, 35271, 35631, 35712, 35721, 35802, 35820, 35829, 35892, 35910, 35982, 35991, 36018, 36108, 36117, 36135, 36144, 36153, 36171, 36198, 36261, 36279, 36288, 36297, 36315, 36351, 36414, 36513, 36531, 36621, 36711, 36729, 36792, 36810, 36819, 36918, 36927, 36972, 36981, 37116, 37125, 37161, 37179, 37197, 37215, 37251, 37269, 37296, 37521, 37611, 37629, 37719, 37917, 37962, 38016, 38061, 38106, 38115, 38142, 38151, 38160, 38169, 38187, 38196, 38214, 38241, 38286, 38295, 38412, 38511, 38529, 38592, 38610, 38619, 38682, 38691, 38817, 38826, 38871, 38916, 38925, 38952, 38961, 39015, 39024, 39042, 39051, 39105, 39150, 39159, 39177, 39186, 39195, 39204, 39258, 39285, 39402, 39411, 39420, 39492, 39501, 39510, 39528, 39582, 39591, 39618, 39627, 39672, 39681, 39717, 39726, 39762, 39816, 39825, 39852, 39861, 39942, 39951

Once a number is identified (whether it be an a, b, c or d number), then the other three members of the quadruplet can be called up. For example, 27864 is the b with a=27648,c=28764 and d=84276. such that:27648+27864+28764=84276For want of a better term we might call these sorts of numbers a,b,c,d numbers. I have the following entry for them in my Bespoken for Sequences document on Google Docs where code can be located as well by following this permalink but execution may time out in SageMathCell so Jupyter notebook may be required or any software capable of running Python code:

Bespoken for Sequences link

A similar thing can be done with A + B = C. Here is the list of numbers between 27809 and 40000 with the property described below in Bespoken for Sequences where code can be located as well as by following this permalink but execution may time out in SageMathCell and so Jupyter notebook may be required or any software capable of running Python code:

Bespoken for Sequences link

27846, 27936, 27945, 27954, 27963, 28035, 28503, 28530, 28539, 28746, 28935, 28953, 29016, 29106, 29160, 29286, 29367, 29376, 29385, 29457, 29502, 29574, 29601, 29637, 29664, 29691, 29736, 29754, 29763, 29853, 30267, 30276, 30285, 30465, 30627, 30654, 30762, 30825, 31698, 31905, 31950, 31968, 32697, 32706, 32760, 32769, 32796, 32850, 32895, 32967, 32976, 32985, 34128, 34182, 34218, 34281, 34497, 34569, 34578, 34587, 34659, 34749, 34758, 34785, 34812, 34821, 34857, 34875, 34947, 35082, 35289, 35703, 35730, 35784, 35874, 35901, 35910, 36198, 36297, 36918, 36972, 37296, 37449, 37503, 37584, 37854, 38124, 38142, 38214, 38241, 38412, 38421, 38529, 38574, 38754, 38925, 38952, 39105, 39150, 39285, 39852

For example, 27846 is a member of this sequence with a=27846,b=46782 and c=74628:27846+46782=74628The code and details of all such triplets can be found in the links provided.

Saturday, 24 May 2025

A + B + C = D

Building on my previous A + B = C post, I decided to get Gemini to modify the code to find all numbers such that:a+b+c=dwhere a, b, c and d share the same digits and a<b<c. The code is included at the end of this post. Up to 40000, the 44 numbers satisfying these criteria are:

4617, 4851, 5103, 5184, 5913, 6021, 6129, 6192, 6219, 6291, 6921, 7182, 7281, 7416, 7614, 8145, 8154, 8253, 8325, 8451, 8514, 8523, 8541, 9135, 9216, 9234, 9324, 9612, 9621, 31860, 31905, 36171, 36711, 37116, 37161, 38061, 38106, 38151, 38214, 38511, 39051, 39105, 39411, 39501

This sequence is not listed in the OEIS. Note the gap between 9621 and 31680. Here is a table showing the details for each of these numbers:

--------------------------------------------------
d          | a          | b          | c         
--------------------------------------------------
4617       | 1467       | 1476       | 1674      
4851       | 1458       | 1548       | 1845      
5103       | 1035       | 1053       | 3015      
5184       | 1485       | 1845       | 1854      
5913       | 1359       | 1395       | 3159      
6021       | 1260       | 2160       | 2601      
6129       | 1269       | 2169       | 2691      
6192       | 1269       | 1962       | 2961      
6219       | 1296       | 1962       | 2961      
6291       | 1926       | 2169       | 2196      
6921       | 1269       | 2691       | 2961      
7182       | 2178       | 2187       | 2817      
7281       | 1782       | 2718       | 2781      
7416       | 1476       | 1764       | 4176      
7614       | 1467       | 1476       | 4671      
8145       | 1485       | 1845       | 4815      
8154       | 1458       | 1548       | 5148      
8253       | 2385       | 2583       | 3285      
8325       | 2358       | 2385       | 3582      
8451       | 1458       | 1845       | 5148      
8514       | 1485       | 1548       | 5481      
8523       | 2358       | 2583       | 3582      
8541       | 1548       | 1845       | 5148      
9135       | 1593       | 3591       | 3951      
9216       | 1296       | 1629       | 6291      
9234       | 2349       | 2493       | 4392      
9324       | 2439       | 2493       | 4392      
9612       | 1629       | 1692       | 6291      
9621       | 1296       | 2196       | 6129      
31860      | 10386      | 10638      | 10836     
31905      | 10359      | 10593      | 10953     
36171      | 11367      | 11637      | 13167     
36711      | 11367      | 11673      | 13671     
37116      | 11637      | 11763      | 13716     
37161      | 11637      | 11763      | 13761     
38061      | 10368      | 10863      | 16830     
38106      | 10638      | 13608      | 13860     
38151      | 11385      | 11583      | 15183     
38214      | 12348      | 12384      | 13482     
38511      | 11358      | 11835      | 15318     
39051      | 10953      | 13059      | 15039     
39105      | 10953      | 13059      | 15093     
39411      | 11349      | 13149      | 14913     
39501      | 10539      | 13059      | 15903     
--------------------------------------------------
Total 'd' numbers found: 44

******************************************************

def find_permutation_sums_of_three_unique_up_to(limit):

    """

    Finds all numbers 'd' up to a given limit such that there exist three

    UNIQUE numbers 'a', 'b', and 'c' (where a < b < c) such that a + b + c = d,

    and a, b, c, d are all permutations of each other's digits.

    Displays the results in a tabular format and a comma-separated list of 'd' numbers.

    """

    found_d_numbers = []


    print(f"Searching for unique permutation sums (a + b + c = d, with a < b < c) up to {limit}...")

    print("-" * 50)

    print(f"{'d':<10} | {'a':<10} | {'b':<10} | {'c':<10}")

    print("-" * 50)


    for d in range(1, limit + 1):

        s_d = sorted(str(d))  # Canonical representation of d's digits


        # Smallest number that can be formed from d's digits

        min_val_from_digits = int("".join(s_d))


        # Optimization: If d is too small, it's impossible to form d from three positive permutations

        # The smallest sum of three *unique* positive permutations of d's digits would be at least

        # min_val + (min_val + 1) + (min_val + 2) if they are distinct and permutable.

        # A simpler lower bound for unique permutations is 3 * min_val_from_digits.

        if d < 3 * min_val_from_digits:

            continue

       

        # Another strong optimization: d must have at least 3 numbers that are permutations of its digits.

        # This is implicitly handled by the loops, but it's good to keep in mind.


        # Iterate for 'a'

        # 'a' can go up to d // 3 (roughly). Must be at least min_val_from_digits.

        for a in range(max(1, min_val_from_digits), d // 3 + 1):

            s_a = sorted(str(a))

            if s_a != s_d:

                continue


            remaining_sum_bc = d - a

            # Optimization: The remaining sum must be greater than 2 * a for b and c to be distinct and larger than a.

            # Also, remaining_sum_bc must be large enough for two distinct permutations.

            if remaining_sum_bc <= 2 * a or remaining_sum_bc < 2 * min_val_from_digits:

                continue


            # Iterate for 'b'

            # 'b' must be greater than 'a'.

            # 'b' can go up to remaining_sum_bc // 2 (roughly).

            for b in range(a + 1, remaining_sum_bc // 2 + 1): # Start 'b' from a + 1

                s_b = sorted(str(b))

                if s_b != s_d:

                    continue


                c = remaining_sum_bc - b

               

                # Check for uniqueness and order: c must be greater than b

                if c <= b: # c must be greater than b to satisfy a < b < c

                    continue


                s_c = sorted(str(c))


                # Final check: c is a permutation of d's digits

                if s_c == s_d:

                    found_d_numbers.append(d)

                    print(f"{d:<10} | {a:<10} | {b:<10} | {c:<10}")

                    # Found a valid (a,b,c) for this 'd', move to the next 'd'

                    break # Break from 'b' loop

            else:

                continue # If no 'b' was found for this 'a', continue to next 'a'

            break # Break from 'a' loop if a solution was found for 'b' (and implicitly 'c')

        else:

            continue # If no 'a' was found, continue to the next 'd'


    print("-" * 50)

    print(f"\nTotal 'd' numbers found: {len(found_d_numbers)}")


    if found_d_numbers:

        print("\nComma-separated list of 'd' numbers:")

        print(", ".join(map(str, sorted(list(set(found_d_numbers))))))

    else:

        print("\nNo 'd' numbers found within the specified limit.")


# Run the search up to 40000

find_permutation_sums_of_three_unique_up_to(40000)


Key Changes to Enforce a < b < c:

Loop for b starts from a + 1:
Original: for b in range(max(a, min_val_from_digits), ...)
New: for b in range(a + 1, ...)
This directly enforces b > a. Since a is already at least min_val_from_digits, b will also be.
 
 
Check for c > b:
Original if s_c == s_d and c >= b:
New: if c <= b: continue (Moved to an early check)
Then if s_c == s_d: (Final check, as c > b is already ensured)
After calculating c, we immediately check if c <= b: continue. This ensures that c is strictly greater than b. If c is not greater than b, this (a, b, c) triplet doesn't satisfy the a < b < c condition, so we move to the next b.
 
 
Refined Loop Bounds & Optimizations: 
 
b's upper bound: remaining_sum_bc // 2 + 1 is still appropriate, as b must be less than c (and b+c = remaining_sum_bc). 
 
Early exit for remaining_sum_bc: if remaining_sum_bc <= 2 * a or remaining_sum_bc < 2 * min_val_from_digits:
remaining_sum_bc <= 2 * a: If b + c is not greater than 2 * a, then it's impossible for b > a and c > b.
remaining_sum_bc < 2 * min_val_from_digits: Still valid, as b and c must be at least min_val_from_digits.

Impact of a < b < c:

Fewer Results: You will find significantly fewer d numbers that satisfy this stricter condition compared to the previous version where a, b, c could be equal or in any order. 
 
Faster Execution: The a < b < c constraint prunes the search space considerably. By skipping a=b, b=c, a=c, and permutations, the inner loops will run fewer iterations, making the search faster.

This version is more aligned with typical "unique permutation sum" problems