RSSAmplifier

Blog

Go deh!

Mainly Tech projects on Python and Electronic Design Automation.

paddy3118.blogspot.comRSS feed ↗16 posts

Latest posts

Sparse Ranges

Implementing sparse_range : From a Python Discuss Idea to a Sieve Stress Test I found an interesting thread over on the Python Discuss forum titled " Possibility to exclude ranges from range " . The initial discussion revolved around a common (?), developer need of : how to cleanly skip specific blocks of ints in a range of ints without writing clunky, nested if/continue logic, and without doing…

From all truths to (ir)relevancies

Following up on my previous post about truth tables, I now ask a subtler question: which inputs actually matter? Some variables, though present, leave no trace on the output. In this post, I uncover those quiet bits — the irrelevant inputs — and learn how to spot them with precision. Building on the previous The previous post showed that for a given number of inputs, there is a finite, but rapidly…

Go Deh celebrations!

This year it's: Fifty years since I first learned to program! Thirty years of programming Python! And In July, this blog topped one million views since its inception! I first learned to program by crashing an after-school class I saw the private school geeks disappearing to from Central library in Nottingham. One of the Trent Polytechnic lecturers I now see sometimes on Computerphile - he…

All Truth in Truthtables!

(Best viewed on a larger than phone screen) To crib from my RosettaCode tasks description and examples: A truth table is a display of the inputs to, and the output of a Boolean equation organised as a table where each row gives one combination of input values and the corresponding value of the equation. And as examples: Boolean expression: A ^ B A B : A ^ B 0 0 : 0 0 1 : 1 1 0 : 1 1 1 : 0 Boolean…

Incremental combinations without caching

Irie server room Someone had a problem where they received initial data d1, worked on all r combinations of the data initially received, but by the time they had finished that, they checked and found there was now extra data d2, and they need to, in total, process the r combinations of all data d1+d2. They don't want to process combinations twice, and the solutions given seemed to generate and…

Intsets by AI

I will be using sets a lot in a future algorithm and wanted to find out about the speed of operation of different set implementations. I will be dealing with different sets of strings from a total of around 200_000, (but the strings being added throughout the calculations). Python sets can do that directly, but I can create an integer index of all the strings and then do calculations on sets of…

Me, Chatgpt, copilot, gemini, and google search classify quadrilaterals

(Best viewed on a larger than phone screen) I decided to use AI more in coding, so found some free tools and incorporated them into my coding experience. My initial goal Someone on Linkedin posted their classification of types of quadrilaterals with a view to how they would implement each of them using OO principles. I commented on it, but was more interested in creating a program to state what…

There's the easy way...

Best seen on a larger than landscape phone Someone blogged about a particular problem: From: https://theweeklychallenge.org/blog/perl-weekly-challenge-294/#TASK1 Given an unsorted array of integers, `ints` Write a script to return the length of the longest consecutive elements sequence. Return -1 if none found. *The algorithm must run in O(n) time.* The solution they blogged used a sort which…

Recreating the CVM algorithm for estimating distinct elements gives problems

Someone at work posted a link to this Quanta Magazine article . It describes a novel, and seemingly straight-forward way to estimate the number of distinct elements in a datastream. Quanta describes the algorithm, and as an example gives "counting the number of distinct words in Hamlet". Following Quanta I looked at the description and decided to follow their text. They carefully described each…

Predicting results from small samples.

I've run simulations, tens of thousands of them at a time, over and over as we developed chips. In one project I noticed that I could predict the final result after only a small number of results were in which allowed me to halt the rest of the simulations, or make advance preparations for the final result. I looked it up at the time and, indeed, there is an equation where if you want the pass…

Searching OEIS tables

A few months ago I submitted a series to OEIS* that was accepted; yes, but OEIS does not seem to leave my series searchable! *OEIS is the Online Encyclopedia of Integer Series. I guess table is not in the name, but... (best viewed on larger than a portrait phone) Let me explain. The documentation for OEIS, explains that if you have a 2D triangle or table of values rather than a one dimensional…

Finding a sub-list within a list, in Python

Existing? As part of a larger project, I thought I might need to search for a sub-list within a given list, and because I am lazy i did a quick google and did not like the answers I found.I started with the thought that the best algorithm for me would be to start searching from the index of the first item in the sublist and so on, but none of the googled answers used list.index. I decided then to…

How not to check for a key in a dictionary.

I skim the Linkedin Python group and sometimes comment. A few days there was a poll asking for the way to check if a key is in a Python dictionary and as I write, more than half of the 900+ respondents have chosen dict.get rather than key in dict , which is the correct answer! When pushed, it seems they are relying on dict.get returning None if the key is not in the dict, but fail to see tha if…

Google Bard vs Microsoft Bing Chat: Vanity questions

I ask two questions about my activities online and compare the outputs from the two AI tools. Google Bard create a rosettacode.org task in the style of user paddy3118 Sure, here is a Rosetta Code task in the style of user paddy3118: Task: Write a program that generates the Godeh series. The Godeh series is an infinite sequence of integers that is defined by the following recursive formula:…

"Staring at assorted perms and Python", or "The Ranking and Unranking of Lexical Permutations"

I have been playing with encryptions and then series that involved permutations. Submitting my Godeh series to the OEIS made me look closer at the permutations that Python produces, and at maybe reducing those permutations to a single integer. (p.s. Post is best read on a larger than portrait phone screen) Here are the start of the permutations used in the Godeh series rows: (0,) (0, 1) (1, 0) (0,…

The Godeh Series, Python, and OEIS

(Best viewed on screens larger than a portrait phone) In my previous post I generalised a form of encryption to do this: Task Encrypt grouping chars by mod M, N times: Given an input string S; Some order of the K integers 0..K-1 called M, where K <= length_of(S); and an integer N > 0 First form groups: Form group G[0] by concatenating every K'th item of S starting from index 0 Form group G[1] by…