Happy 0x7E7!

.webp

Happy new year! Is there anything interesting about the number 2023? I asked Open AI chat and was told no, it's just a number like any other. So I had to do the creative work myself. Here are some fun facts about 2023 (hex 7E7) of which the chatbot was unaware. I include some ideas for programming assignments, together with an analysis of the answers that the chatbot offered.

I asked Open AI chat: “What is interesting about the number 2023?”

The response: “There isn't anything particularly interesting about the number 2023 itself. It is just a number like any other. However, 2023 is the current year, so it might be interesting to think about what has happened or will happen in the year 2023. Do you have any specific questions about events or happenings in the year 2023 that I can help with?”

No Boring Numbers

Of course, there are no boring numbers, but 2023 seems rather a dull one. Still, there are some noteworthy tidbits.

The prime factorization of 2023 is 7×17×17.

2023 occurs in several integer sequences. The first one, the Flavius Josephus sieve, makes a fine programming assignment. Normally, I give a search-proof name when assigning such a problem. I might call this one Bulgarian elimination. But in this case, it seems safe to leave the name unchanged because Open AI chat yields the solution to a related but different problem. I tried some prompt engineering but kept getting different versions of the related problem instead of one that computes OEIS A000960. I think for most students it would be more trouble to try to understand the relationship between these two problems than to just program a solution.

When I asked the chatbot: “Thanks, can you rename the variables so that I won't fail the plagiarism check?”, it responded: “Certainly! Here is the modified version of the program that generates the Flavius Josephus sequence, with the variables renamed to avoid any potential issues with plagiarism.” It renamed n to num_people, k to skip, and index to idx.

But I digress. Returning to the original topic, 2023 is the Win 32 System Error Code ERROR_PROFILE_DOES_NOT_MATCH_DEVICE. This is a legacy API, so we'll likely have to wait until 2108 (ERROR_CONNECTED_OTHER_PASSWORD) for this to happen again.

Unicode

The Unicode character U+2023 is ‣ TRIANGULAR BULLET, but that feels like cheating since it's a fact about hexadecimal 2023, which is decimal 8227, and not of calendrical interest for another six thousand years.

The Unicode code point with decimal value 2023 (U+07E7) is ߧ, NKO LETTER NYA WOLOSO, in the N'Ko script for the Mandé languages of West Africa. How pleasant—it is vertically symmetrical, as A H I M O T U V W X Y are in the Latin script.

Now there is an interesting programming project: Find all Unicode characters that are vertically symmetrical. One could get the images for all characters from the Unicode consortium. Or one could render each character in a bitmap. Then check for whether the right half is the reflection of the left.

Or one can ask Open AI chat: “Write a Python program to find all Unicode characters that are vertically symmetrical. ”

I got this program:

import unicodedata

# Define a function that checks if a character is vertically symmetrical
def is_vertically_symmetrical(char):
  # Get the character's Unicode block
  block = unicodedata.block(char)

  # Check if the block is one of the blocks that contain
  # vertically symmetrical characters
  if block in ('Enclosed Alphanumerics', 'Geometric Shapes',
               'Miscellaneous Symbols', 'Miscellaneous Symbols and Arrows',
               'Dingbats', 'Supplemental Arrows-B'):
    return True
  else:
    return False

# Find all vertically symmetrical characters
symmetrical_chars = []
for i in range(0x10000):
  char = chr(i)
  if is_vertically_symmetrical(char):
    symmetrical_chars.append(char)

print(symmetrical_chars)

Of course, that doesn't solve the problem. I complained: “That's not what I mean. The character image should be vertically symmetric.” In response, I got a better proposal with this function:

# Define a function that checks if a character is vertically symmetrical
def is_vertically_symmetrical(char):
  # Create an image of the character
  img = Image.new('L', (200, 200), 255)
  draw = ImageDraw.Draw(img)
  font = ImageFont.truetype('arial.ttf', 150)
  draw.text((0, 0), char, font=font, fill=0)

  # Crop the image to the bounding box of the character
  bbox = img.getbbox()
  img = img.crop(bbox)

  # Check if the image is vertically symmetrical
  width, height = img.size
  if height % 2 == 1:
    return False
  else:
    left_half = img.crop((0, 0, width // 2, height // 2))
    right_half = img.crop((width // 2, 0, width, height // 2))
    left_half_data = left_half.tobytes()
    right_half_data = right_half.tobytes()
    return left_half_data == right_half_data

Pretty impressive. There are a few issues. It only takes the top half and doesn't reflect the right half. I messed around with a few more prompts to fix it, but in the end found it would be easier to code the rest myself. Still, a good starting point, since I didn't know how to do the rasterization in Python.

Hexadecimal and Binary

In hexadecimal, 2023 is 7E7, a palindrome. Now that's special. Well, maybe not that special. It will happen again in 16 and 33 years.

I asked Open AI chat: “Hex 7E7 is a palindrome. What is the next hex number that is also a palindrome?” Here is the answer:

The next hex number that is a palindrome after 7E7 is 818. Here is a list of all the hex palindromes between 7E7 and 10000:

    7E7
    818
    929
    A3A
    B4B
    C5C
    D6D
    E7E
    F9F

To generate this list, you can use the following code:

for i in range(7E7, 10000):
    hex_str = hex(i)[2:]  # get hex string without the "0x" prefix
    if hex_str == hex_str[::-1]:  # check if string is a palindrome
        print(hex_str)

This is fascinating. The answer is confidently presented but wrong. It is missing 7F7, 808, and so on. But if one runs the program (after adding a 0x prefix to 7E7), the program gives the correct answer!

Let's move on. In hexadecimal, 7E7 has a palindromic prime factorization 11×7×11. That's kind of special. There is a programming assignment in there: “Write a Java program that checks whether a given integer has a prime factorization that is palindromic in some number base.” Here is what I got from the chatbot:

import java.util.ArrayList;
import java.util.List;

public class PrimeFactorizationPalindrome {
    public static void main(String[] args) {
        int num = 123454321; // test number
        int base = 10; // base to check palindromicity in

        List<Integer> primeFactors = getPrimeFactors(num);
        String primeFactorizationInBase = getPrimeFactorizationInBase(primeFactors, base);

        if (isPalindrome(primeFactorizationInBase)) {
            System.out.println(num + "'s prime factorization is palindromic in base " + base);
        } else {
            System.out.println(num + "'s prime factorization is not palindromic in base " + base);
        }
    }

    // Returns a list of the prime factors of a given number
    public static List<Integer> getPrimeFactors(int num) {
        List<Integer> factors = new ArrayList<>();
        for (int i = 2; i <= num / i; i++) {
            while (num % i == 0) {
                factors.add(i);
                num /= i;
            }
        }
        if (num > 1) {
            factors.add(num);
        }
        return factors;
    }

    // Returns the given list of numbers as a string in the given base
    public static String getPrimeFactorizationInBase(List<Integer> numbers, int base) {
        StringBuilder sb = new StringBuilder();
        for (int num : numbers) {
            sb.append(Integer.toString(num, base));
        }
        return sb.toString();
    }

    // Returns true if the given string is a palindrome, false otherwise
    public static boolean isPalindrome(String str) {
        return str.equals(new StringBuilder(str).reverse().toString());
    }
}

There are a lot of things wrong with it. With a student, I would ask: “What would you get if you ran this program with the number hex 7E7?” The chatbot's response:

If you ran the program with the number 7E7 in hexadecimal (which is equal to 2019 in decimal), you would get the following output:

2019's prime factorization is palindromic in base 10

This is because the prime factorization of 2019 is 3 * 673, which is a palindrome when written in base 10.

I was impressed by the chutzpah. Such blatant falsehoods, so confidently stated.

.jpg

More 7E7 trivia. There is a modular hip joint and a vacuum tube with code 7E7. Perhaps a chance to discuss vacuum tube computers in class...

The Boeing 7E7 airplane was a project by Boeing to develop a new aircraft that was intended to be more fuel efficient and environmentally friendly than its previous models. The 7E7 was also known as the Dreamliner, and it was designed to be a long-range, mid-size wide-body jet airliner. The aircraft was made primarily of lightweight composite materials and featured a number of other advanced technologies, including improved engines and a redesigned cabin layout. The 7E7 was intended to compete with the Airbus A330 and A340, and it was initially offered in three different variants, including the 7E7-8, 7E7-3, and 7E7-9. The 7E7 project was eventually canceled by Boeing, and the company instead focused on the development of the 787 Dreamliner, which was based on many of the same technologies and design concepts as the original 7E7. At least that's what Open AI Chat told me. (I was struck how many internet search results pointed to business case study solutions about this airplane. It seems a frequently plagiarized assignment in business classes.)

Finally, the color #7E7, is a pleasing green. This paragraph has it as the background color. The color is sadly not named. Sixteen years ago, I could have pointed out that #7D7 is named pastel green.

In binary, 2023 is 11111100111, not a palindrome. But in 24 years, we will have a glorious binary palindrome 11111111111. I can't wait!

Conclusion

So, while 2023 is not the most scintillating number ever, it is not “just a number like any other”. I expect that by the beginning of 2024, the chatbots will have snarfed up the contents of this blog and others like it, and will be able to produce convincing essays about 2023. They are very good about rephrasing what others have already done. But perhaps not so good at creativity.

It was quite eye-opening to see what an AI assistant can do these days, and how it can produce both helpful and useless code with equal apparent confidence. If you teach computer science, I highly recommend that you type in some assignments into your chatbot of choice and get a preview of what you may well soon see in your submission system.

Comments powered by Talkyard.