Posts

Showing posts from January, 2026

More Than One Way to Skin a Snake

Image
  The s ame above  title ( skin the cat-snake ) still applies here, but as a post script edit to this post, I'm going to give it an entirely different spin  than originally planned. Here it goes: My current Py project has evolved into needing a customized data structure . Never mind its specifics.  (Maybe I'll come back to those later.) As I started formulating the ideas / concepts for the customized data structure, I recalled having vaguely seen mention of a thing in Python called " DataClasses " . Had no idea what it actually was. It intrigued me. So I started chasing after it (started searching for clues ) . Turned out to be a popular topic. Many, many tutorials about it. So should I pick just one lecturer? (e.g. Tech with Tim/other (TwT, TwX), Indently , Bro Code , Mosh , Nana , ... or any of the other many free Py tutors ) and stick with that one explainer? No. It so happened that jumping around allowed me to pick up different nuances about the stuff they we...

Half Baked Thoughts on implementing non-flat probability outcomes

Image
This  might demonstrate how new ideas can emerge from accidental insights you have about code you've written for a different purpose. So below is a function I wrote called randLE(), which picks a random element from a list and outputs that one randomly selected slice based on a randomly selected index within a range. The output can be of type string, or integer of float. The input list should be of the desired one type: ( Left click on image to enlarge, backspace to return to original size image ) That got me thinking. What if I had an input list that looked like this: [0, 10, 1, 1, 9, 9, 2, 2, 2, 8, 8, 8, 3, 3, 3, 3, 7, 7, 7, 7, 4, 4, 4, 4, 4, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 5] In other words the occurrences of the list elements are weighted. There are: six 5's, five each of 4's and 6's, four each of 3's and 7's, three each of 2's and 8's, two each 1's and 9's and one each of 0's and 10's. That tilts the probability distribution...