How Genetic Algorithms work using Hamlet as an Example

Hi!

I’ve officially run out of blog topics, so I’m going to expand upon Aarav’s (hi Aarav) blog about Genetic algorithms (we are on the same software engineering team, so I think this is alright!)

It’s also been awhile since his blog, and we’ve had to rework a lot of how our code works. 

Let’s start from the very beginning!

We have this really great spreadsheet that helps us to read data in. You can see it below:

We pretty much process all of this data into our code, and save it for later. 

After that’s done we need to make a bunch of really bad schedules (the initial generation, think Mendel’s original green and white pea plants), this is where we start with. Basically, we just have to put together 8 lists of room/teacher/class assignments (that makes one schedule, since each list represents a class period, multiplied by 8 makes a full day). Let’s say we have 100 of these to start out. 

Something we’ve improved from last time was the schedules we generate are actually possible schedules! That doesn’t sound super good, but our old code used to stick random teachers with random classes (think of Ms. Hitzeman teaching Software Engineering  – sorry Ms. Hitzeman :)). Now, we start all of our schedules off on the right foot. 

Any time we’re making a new schedule, we have a lot of “Teacher” objects: think various versions of Hamlet. We know each version of Hamlet has a super dramatic “To be or not to be” speech, weird dynamics between Hamlet and Gertrude, along with many other similarities. 

Like each version of Hamlet, where each is different but all have constant ideas/people/scenes, each “Teacher” object has a designated “Class” they teach, as well as a designated “Room” they teach that class in. Since we’d rather not store these values for every teacher for every period manually, we have two lists that hold these values. 

We have a class_list variable, think of it like Hamlet’s revenge checklist. He must talk to Horatio, out Claudius as a killer with the players, kill Polonius, and fence with Laertes. Similarly, each teacher object contains a list like this: [AP Lit, 2, Ap Lit, Lunch, 5, 6, 7, 8]. These hold class data for us. 

Next, we have to make changes to make better schedules. For example, while Ms. Hitzeman could teach 8 classes every single day, that probably isn’t good or healthy for her – so by randomly replacing teachers/classes/rooms between schedules, we can slightly alter how each schedule works (theoretically if we do this enough, combined with the next two steps, we’ll get a good schedule).

Now we have a bunch of mutated schedules, we need to get rid of the bad ones and add new ones! 

Think of making schedules like a AP Lit Hamlet Academic discussion: while we can have 20 people talk for the entire period, what they contribute to the conversation will probably decrease over time. So if we swap out the old people (delete a bad schedule) and sub in a fresh perspective (generating another schedule) then we can keep the very insightful Hamlet discussion going. 

After we do this, we’ve successfully progressed a single generation! If we go back to the AP lit discussion, let’s say that’s one period of discussion. (For the example to work let’s pretend people get carried over from period to period). 

I’m in second period, so let’s say we bring in the 3rd period kids. They’re all new and have great things to add to our conversation! So by progressing to another generation, where we repeat the previous 5-10 steps, we continue talking about how random Hamlet sometimes is and definitely how heroic Horatio is – all while a function is checking to see if we’ve reached a good schedule (think Ms. Hitzeman writing notes until someone finally arrives to the most insightful thing to discuss about Hamlet ever). 

We rinse and repeat for maybe 1000 generations (that would be a lot of AP discussions!), and once we’ve finally reached a good schedule, we save it and output it! 

Some other cool parts about our genetic algorithm: 

This is our super technologically advanced and modernly designed home page!!! Made by the illustrious Jonathan Qunell. Very cool I know. This site is just set up so the teacher who would want to generate schedules simply inputs the values into the spreadsheet I showed above, uploads it through upload data, then can create a schedule using that data, and finally can view any old schedules generated. 

Thanks for reading! I hope this provides some much-needed insight into Hamlet quantified programming.

-Max

Cruise! 

This spring break I went on a cruise with my family! I’m going to talk about my adventures. 

It was a 7-day cruise leaving from Galveston, TX. We were going to 3 ports, two in Mexico and one in Honduras. We had to get up at 3 AM to make the one-day drive! 

Luckily I had a ton of work that night, so I just worked through the night and slept in the car. 

I don’t know about you, but I’m really not a fan of road trips. The constant bumpy movements, music that’s either too loud or just loud enough to be annoying, and the heat from the sun creates a pretty bad travel environment, especially in a super limited space like the car backseat. 

My agenda items for the road trip: Survive without getting super headachey, read a couple of books, and recover my sleep. 

We arrived in Houston at 9:48 pm, 12 minutes before the restaurant where our dinner was waiting for us. We got a couple of pounds of seafood boil, which was super tasty after the extremely long road trip. Unfortunately, I have no pictures! 

The next morning we drove 2 hours to Galveston and boarded our cruise. I expected the security process to be long and tedious, but it took about an hour and then we were on the ship! Since we dropped off our luggage we made our way to one of the three dining rooms available at the time and had some really good shrimp and beef tenderloin (picture below). 

After lunch, we went to check out the ship! Somehow instead of exploring the main exciting areas of the boat, like the buffet or the pools, we went to the very top and got locked out (since staff didn’t think people would go right to deck 19), and had to get let back in by a staff member. 

For the first few days of the cruise, when we were at sea, my days looked a lot like this:

I totally didn’t finish my voices novel in 2 days……

While I’m super carsick, boats are surprisingly not bad at all, 90% of the time it felt like we were on land. Which I guess is lucky for me – most of my family was hit pretty hard with seasickness. 

These days at sea I also told myself I would do the onboard activities – so between ping pong tournaments, culinary demonstrations, and origami classes, I got to meet a lot of shipmates. 

Do you know how most cruise ships have stores you can shop at? I never thought I’d spend my time in any of these – but low and behold I spent almost as much time in the jewelry store as I did the buffet. 

There’s a good reason, however! They were giving out these charms – most were related to our actual cruise (a ship wheel with our cruise line’s logo, the ports we visited). 

As a joke, I told my family that we should collect all 6-7 charms that were spaced out over the cruise… everyone picked up on it and it became our daily tradition for a week to go collect our charm things. 

Once we got to the ports the cruise was super fun! Not only did we have the same great cruise amenities, but there was also an entire port to explore (not to mention the ship was completely still – for some reason the restaurants would be super rocky even though the rest of the ship was good. 

POV my dad in Cozumel (or was it Costa Maya? One of the two).

Since my sister was taking this week off from school (even though she still had classes) we only visited each port for a couple of hours, especially since there really wasn’t that much to do besides buy super touristy stuff or lie on the beach. 

After the 3 sea days, we had three port days, each in a new destination. Our schedule every day would pretty much be waking up at 7, getting breakfast then start exploring the port at 8. At about 10 we’d either 1) Exhaust what each destination had or 2) Get really hot with the sun beating down. We’d return to the ship at about 11 and have a good 4 hours with all the cruise amenities to ourselves. That was super nice! 

Overall I really enjoyed my cruise! Was a great way to refresh after January, Feb, and March. I would definitely make it a spring break tradition – it’s like a normal vacation except you don’t have to worry about transportation, food, hotels, entertainment,   and a bunch of other great things. 

-Max 

 

From Film to Photos the Old Fashioned Way

This semester I’m taking Photography 1, initially for the Fine Arts credit, but a few weeks in the class has been super rewarding and fun! While at first, I cursed my choice to pick Traditional Photography over Digital, (as one is much more tedious than the other), I’ve found the experience of developing film into photographs super fascinating. (I’ve also been doing it for a month straight so I think I can provide a valid description!). 

The Process:

First, we need light-sensitive film, as well as a camera. I’ll have to talk about taking pictures with film some other time, that process also takes a bit of time to understand! 

Yet once we have our film, we can take it out of our camera in a little metal canister and place it into our changing bag (picture below). Since the film is light sensitive, we can’t just open our film canister in a bright room, because it’ll overexpose our images and we’ll end up with completely white pictures. Thus, the dark bag allows us to load our film for development. 

Ever try to walk around a hotel room at night with the lights off? That’s pretty much how it feels to use a changing bag. You have to 1) open up the film canister with a can opener, 2) pull out the film roll and trim it to size with scissors, 3) load it onto the white rolls (depicted above) 4) place all of that into the gray colored film developer tank, and 5) lock in the funnel and lid on the tank. And you have to do all of that without being able to look at what you’re doing. 

This video (https://www.youtube.com/watch?v=H3h8WT9GjbM) explains it much better than I can!

Basically, it’s a lot of physical fumbling that you have to do without being able to see anything. 

It’s also super stressful to do! Since the developing process takes 30 or so minutes, and you have to do it all in one class period, you have to figure out the previous 5 steps in about 10 minutes. 

Once we have our film loaded into the gray tank, we can start developing! The process is quite a lengthy one, I’ll detail it below. 

  1. We need to rinse our film to prepare it for all of the chemicals and help to remove some of the silver crystals that make the film light-sensitive. We soak the film for 30 seconds in water, then pour it out. 
  2. We now need to develop our film! After taking a picture there is a latent image on the film that we need to expose. There are a bunch of chemicals that we don’t really cover, but basically, we take 10 ounces of magical mysterious Developer chemical and alternate between soaking the film in the chemical or agitating it by shaking the container. 
  3. Now we pour the chemicals out, rinse for 30 seconds again, and pour the “Fixer” chemical into the tank. Basically, our image is developed and visible, yet the image is still light-sensitive. Since we want to see the image in light, we have to “fix” the image, basically freeze it onto the film. 
  4. After much agitation, and then pouring the chemicals out, we have to stop the fixer chemicals from eating away at the film by washing it in water for 10 minutes. 
  5. Last step! Our film is wet, so we have to let it dry. Yet drying it right now would leave a bunch of watermarks on our film. So we have to submerge our newly developed film into a photography flo chemical that helps with the water drying. 

After you wait for a day, your film looks like this! (below)

This is pretty fun because this is the first time you can see what your photos look like after originally taking the pictures! Usually, my pictures look pretty blurry, but I’m always surprised.

Now we just have to cut the film into 5 picture strips (as the original film is a 25-picture strip). Then we place it into one of those clear plastic sleeves so we can safely store our negatives for future use. 

Next week, I’ll describe the process to take our newly developed film into creating an actual photograph (that’s 8.5 x 11 instead of a tiny rectangle of the film). 

Included below is my recent photography lab! We had to photograph an object, and I chose this origami cube puzzle because I thought it would look good with shadows. I’ll explain how we mounted the image to a black background later on. 


Thanks so much!

-Max

 

 

Poetry Difficulty Essay Blog

I’ve always wanted to do an in-depth read of an Edgar Allan Poe poem after watching videos like TedEd’s piece on Poe: https://youtu.be/8lgg-pVjOok, as well as Buzzfeed Unsolved’s video on analyzing his death: https://youtu.be/y4DTW4B3Sjs

I settled on his piece “The Haunted Palace” due to it’s more convoluted tone, alongside the fairly complex yet descriptive diction, as it would make a challenging read. When reading through, I found my best approach to understanding the poem was to go line by line, stanza by stanza, then finally piecing it all together, so I’ll structure my blog in a similar way! You can find the poem here: https://www.poetryfoundation.org/poems/52370/the-haunted-palace, and I’ll be showing the particular parts of the poem as I discuss them. 

The poem opens with this image of luscious green valleys stretching for miles, and immediately starts with words like “tenanted” “seraph” and “pinion”. Through admittedly a lot of dictionary searches, my interpretation of this first stanza is setting the scene for the rest of the work: on top of this picturesque, angel-owned landscape (due to tenanted meaning to own property or land like modern day tenants) there is a bright palace that even angels haven’t flew/been to (as seraphs refer to angels, and a pinion is a special feather used for flight). This puts us, the reader, into this almost dreamlike world with a palace that even angels don’t visit to disrupt the landscape. 

One especially tricky part about this passage is the line “In the monarch Thought’s dominion”, where we learn that this palace is controlled by a monarch. Yet the wording at first is unclear here: is “Thought” the monarch? Or is it the concept of “Thought” that allows this palace to exist, inside of one’s mind? Mulling it over, I found that the name of “Thought” would be pretty arbitrary out of all the possible names Poe could’ve chose, leading me to believe in the second interpretation, that this palace is not truly a location somewhere, but an idea in one’s mind. Technically, we could say that the monarch named “Thought” does control this palace, as the castle is at the whims of one’s imagination. As the poem progresses, we can piece together what this means for Poe’s intentions of the work. 

Continuing on, this next paragraph describes the “palace” itself, ironic since we just discerned that this palace is controlled by one’s imagination, so it is fluid in nature and not fixed to one particular look.  While a lot of descriptions, Poe continues with flight metaphors, where he states “Along the ramparts plumed and pallid” (Poe 15). While initially it sounds like the entire palace is decorated, pallid has a meaning closer to pale – where we can understand that Poe sees this palace as heavily decorated, yet pale and almost fake looking. Digging deeper, this palace isn’t the magnificent place we initially thought, the edges of this mental picture are less refined (like the pale ramparts), much like our own thoughts. 

This next stanza is definitely my favorite in the entire piece! While the line about luminous windows seems like a simple description of the palace architecture, I found the logic to not make sense. Mainly due to the fact that “wanders” wouldn’t see the palace inside from the outside (we know the “windows” separate the wanders and palace interior due to the descriptions of the monarch’s throne). 

Instead, using our earlier approach that this palace only exists in imagination, it makes more sense for these “windows” to not be windows at all, but rather 2 eyes. When we imagine, we close our eyes, and open “windows” into imaginary thoughts. 

While the imagination approach makes more sense than the literal representation, I did want to point out a confusing part of this stanza I had to work through: the word “Porphyrogene”. Apparently this word literally means “to be born in purple”, calling back to roman royalty wear colored purple due to the cost of purple silk at the time. Using the literal interpretation, Poe hints at how this palace isn’t as pristine as we initially think. 

This stanza contains one point I want to note further that helps us understand this poem, in the first line. We hear about all of this pearl and ruby that glows, either due to 1) manual shining/polishing or 2) some sort of ethereal glowing quality. While either interpretation leads to a plausible conclusion, I believe the latter conclusion makes more sense with what we’ve been discussing. 

In summary, Poe’s use of describing thoughts through this imaginary palace challenges us to think with vivid imagery.

I put in the rest of the poem below, for your enjoyment. Thanks for reading!

 

-Max

 

How to Name Organic Molecules

First blog of 2023! 

Diverging from technology, I’d like to discuss a bit of chemistry today. Having taken Advanced Chem last semester (and not knowing what I can write 750 words about), I figured describing the very convoluted and backward way organic chemists name molecules would be a great thing to do. 

Before we start, there are a few prefixes that you need to know: 

Here, Meth- means 1, eth- means 2, prop- means 3, so and so forth. 

Let’s start with the most basic molecules, Alkanes. These are single bonded Carbon molecules. Not bad!

Here’s an example below:

C’s denote carbons. Now how do we name this molecule?

We simply count up the amount of carbons (here there are 5), find the corresponding prefix from our handy chart (in this case pent-), and simply add the suffix -ane since this is an Alkane molecule (single bonds connecting the carbons, seen above by the single dashes), this molecule is pentane. 

That wasn’t bad! But a majority of molecules have branches of either carbon chains (like what we see above), or different elements. 

Here is a slightly harder molecule: 

I’ll explain the Iodine (I) and bromine (Br) seen here. There are a few molecules that are often attached to these carbon molecules, which we denote with the prefix Iodo- for iodine, bromo- for bromine, fluoro- for fluorine, etc. Since this molecule is more than just a simple chain, we need to order our branches. 

We start ordering from the end with the closest branch. Since with this molecule, either end has a Iodo- molecule or a bromo-molecule 1 carbon in, this is a tie and results in us using the very backwards approach organic chemists take to order these molecules: going by the alphabet

Which letter comes first, I (like iodo-) or B (like bromo)? Bromo, so we start ordering our molecule from that end. So from right to left, we name each carbon with a number, starting with 1, then 2, then 3, then 4, up to 6. 

Lastly, we have a carbon branch. Referring to our table, this is a single carbon, so it should start with the prefix Meth-. Since it’s a branch, we end it with -yl, so we call this branch methyl. 

Now taking all those parts together, we have our right to left ordered carbon, bromo, iodo, and methyl branches, now it’s time to name! Here’s a picture below, with the carbons ordered and the branches circled. 

Again, going by the alphabet, we name the branches before the base molecule, so bromo, iodo, then methyl. 

Bromine is attached to the second carbon, so we name this branch as 2-bromo. Iodine is attached to the 5th carbon, so we name it as 5-iodo. (Note here, while the methyl is the next molecule we should name, organic chemists chose to do it alphabetically so we have to name the iodine branch first!). Lastly, we have the methyl branch, attached to the 3rd carbon, so we call it 3-methyl. 

Finally, since we have 6 carbons, consulting our handy chart this works out to be hex- as a prefix, so hexane as the base chain of 6 molecules. 

Put it all together, and this molecule is 2-bromo 5-iodo 3-methyl hexane. 

Nice! We can name linear molecules, but what about circular ones? 

Here’s a more complex molecule. Note how the red donut of 5 carbons are connected to each other in a circular fashion. Since they are this way, we add the prefix cyclo- to the ending bit of the molecule. Since this central (red) ring of carbons contains 5 of them, referring to our table this molecule should have pent- in it. Furthermore, we can see the “bonds” or lines around the 4 o’clock region of the molecule are double instead of single, this denotes a double bond, which would mean this molecule is an alkene, slightly different from the Alkanes we named earlier. This means the molecule above would end with the conventions cyclopentene

Onto ordering the carbons! We found with the previous molecule that we need to order the carbon order so that the branches are in the right places. Since this is a alkene, we must start at a double bond (more organic chemistry backwardness). Yet do we name our carbons clockwise or counterclockwise? 

It turns out here that we should follow the red number order, since each way you start naming you name a branch on the 3rd carbon. Since the E in Ethyl comes before the F in fluoro, we name with the red numbers. 

All in all, this makes the molecule 3-ethyl 5-flouro 4-iodo cyclopentene. 

Here’s Mrs. Brucker’s youtube channel for further information: https://www.youtube.com/watch?v=GJVvOixr–c&list=PLQAytuMyLyMVTdfLoCTSCEsGr6Qb46OMs. She is infinitely better than me at teaching this material!

-Max

 

The Final Blog

Wow. It’s been quite a few 6 months. From all the 2 am college essays to studying calculus during lunch and other periods, it’s been definitely the most transformative period of my life to date. 

I think personally I’ve definitely learned that stress can push me to work a lot harder than I thought was possible. Again, having to write college essays at 2 am due to unfortunate procrastination was never ideal, but something I’ve definitely learned from. With the largely retrospective nature of college essays, I find myself being more reflective and analytical than I ever was, something that has helped me appreciate the smaller, less spectacular things in life. 

Let’s start with multivariable calculus, a double-edged sword of being academically rigorous (in a good way) yet also mentally and physically taxing. From spending pretty much every morning in math help asking questions, I definitely have learned strategies to use when I’m struggling in college. 

Here is my really delightful multivariable study guide on just the formulas we have to know! And this is just half of it….

Posting on the blog site it looks a bit blurry… I guess you’ll have to take my word for it that there’s a lot here!

Then college applications, the other Beloved-like haunting of my senior year. Working at 2 am, taking power naps for an hour to keep working (and hoping that I don’t fall asleep), all helped me grow. 

Personally, I’ve learned not only how to study, but how to cope with friends, something that I never really did in the past with bad tests/ college rejections. I’ve also seen how consistent friendships are much better than friendships that are more on and off. Hanging out with a few people for the entire semester, through the highs and lows of the year I’ve learned so much not only in academics but also about them. 

You always hear people say how you should start college applications early, yet no one actually does and ends up telling the rising seniors to do that, and repeat. I find either strategy has its merit, while yes, working early and having time to refine and build off of your claims systematically and being able to conference with others is good, I believe (while not procrastinating) working closer to deadlines is not the worst thing. Most people do the latter, which sure, a week or two here or there will definitely be bad, but your writing isn’t diluted with the criticisms of 10 other people, it’s true to you. 

So my advice is, even if you have many applications due in a very short period of time, as you probably will, don’t sweat it, but make sure to pull some pretty late hours to study. 

As for school wise, I would say generally keep up the rigor of your previous year’s classes. Me, I was lucky that a lot of the harder classes I wanted to take conflicted with each other, and I had to find substitute classes that were a bit easier. With the study hall that comes when you take online PE, working during lunch, and generally finding time, I was able to get a lot of my homework done, so getting home I could start on college work pretty quickly. 

As I’ve mentioned before, I definitely feel as though college applications and AP lit have made me a more retrospective and reflective person, something I value for growth. I also learned to appreciate the jobs of writers, as sometimes writing even a paragraph can take an hour.  

What lessons would I take away with me to college…. That’s a good question. Finding a group of friends to study with and have fun with is important, probably having to stay up until very late hours at the library studying, etc. 

This semester is by far my hardest yet… and I’ve learned so much from it. Hopefully next semester I’ll be able to learn the values of a more chill senior year. 

That’s been me for this short yet intense chapter of life. 

-Max

How Algorithms Show That Some Jobs are Unnecessary

Reading Algorithms to Live By: The Computer Science of Human Decisions by Brian Christian, it’s easy to get immersed in the many different applications, explanations, and more that Christian provides. One such topic I’d like to talk about more is the idea of caching, and how it shows that when organizing any collection of objects, oftentimes no system at all is more efficient than a certain sorting pattern.

You’ve probably heard of caching, I believe in years past the district installed a “Clear Cache” extension that totally did nothing, but it was a cool little trash bin that said it cleared your cache! Caching is the idea that computers store pieces of information or processes that need to be frequently used. Imagine, instead of a brightness button, if you wanted to change your computer screen you had to physically go to a terminal prompt and input your commands there, like below.

That would be super unnecessary and inconvenient! Caching helps to make computers run faster, having key processes saved to improve efficiency. 

The trickiest part of this idea is, with only a limited amount of memory that your computer can hold in this “cache”, what should we keep and what should we get rid of to maximize efficiency? 

It turns out, while there are many complex solutions, like caching reactively where your storage depends entirely on what’s being used at the present moment in time, the overall most efficient strategy is a last-in-first-used strategy. Especially with a computer, information most recently accessed has the highest chance to be called again. (For more caching examples, check out: https://docs.aws.amazon.com/whitepapers/latest/database-caching-strategies-using-redis/caching-patterns.html!)

How can we visualize this? Imagine doing your math homework, let’s say your processes of completing this task are writing with a pencil, fixing mistakes with your eraser, solving problems with your calculator, and correcting mistakes with a red pen. Let’s visualize each of these objects as different processes on your computer. 

Let’s say you’re working with your pencil, solving a problem. Then making a mistake, you quickly erase it. What will you pick up next? Most likely your pencil to continue the problem. Lets say, after solving that problem, the next one requires a calculator. After picking up the calculator and solving the problem, you write down your answer with your pencil. Realizing you forgot to add a value, you quickly adjust your calculations and fix your work. 

Here, we can see that you kept picking up the school supplies that you used last – this idea of the most recently used tool being the one most likely to be used again.   

So how does this apply to our lives? 

Imagine you are a librarian, sorting books. I love this picture below with the annotations and circling marks – it perfectly gets at my claim. How should you sort books? Should the big Shakespeare book go together with the Romeo and Juliet books, even though one is a biography and the other is a work of fiction? 

This problem is what librarians face in their day-to-day operations: how should they sort these books to be efficient for readers to search for? 

Yet applying Caching concepts, and the idea of last used as the most likely accessed process, it makes the most sense for librarians to never reshelve a book. Since we know people will want to use the most recently used process, in this case, a certain book, why should librarians ever sort these books back into the shelves where it’s harder for patrons to find? Not only does this take time out of their day, but it also wouldn’t be efficient for readers. 

Which is super strange! It seems obvious that we should sort items, and order the chaos. But here, the most efficient strategy for librarians is to have a “recently checked out” book display in the lobby of the library, and only reshelve the books that have been on this display for a certain amount of time, let’s say a week. 

This realization leads us to question if reshelving books is even needed, and if not why so many spend their time doing something inefficient for both the librarian and reader. 

These ideas are super interesting to explore: it shows how some jobs in our society, or even entire processes in our society, could be unnecessary and even inefficient for society. 

Overall, I hope this blog helped show how we can use algorithms to not only better our lives, but learn a thing or two from the computers that power our society. 

How advanced is AI, really?

You might have seen the recent news about Open AI or more specifically DALL-E— an AI system that can generate an entire picture from a simple text command. Usually generated images look slightly unnatural – as predicted since this AI can’t physically see. Yet sometimes the images yield surprising results, below are some of my favorites. 

Inputting “Salmon in a river” generates salmon fillets in a river swimming like live fish, which is super strange! You could ask anyone on the planet to describe salmon in a river – and no one would think of raw fillets in the water. We can start to see how data pollution can affect generated images. Here, there have been so many pictures of raw/cooked salmon over the actual fish, so DALL-E can’t discern the difference between the two and chooses the more popular one. 

 

Here’s another interesting one: inputting “Chess match on a pizza”, not only do you get the physical pieces and somehow a chess board instead of cheese, but I’m especially impressed by the first image. DALL-E chose to include 2 people playing on this pizza chess board – which again shows how much input data affects this AI’s understanding of the game chess as a 1 on 1 board game rather than just pieces on a checkered board. 

One last cool example of DALL-E is when inputting “Future of City of Kigali”  DALL-E generates the image below:

For context, Kigali is the capital city of Rwanda, a country in central Africa. As things currently stand, they’re ranked roughly in the bottom 20% of all Nation’s Gross Domestic Products, a statistic used to show the

 economic growth and output of a nation. Yet DALL-E is pretty confident that this developing nation will one day become a futuristic city with an emphasis on greenery. 

All of these images show how far AI has come, especially in visualizing our world. Thinking about it, DALL-E has boiled down our complex 3d world into 1’s and 0’s that computers use, which seems a bit out there. 

As an avid reader of the New York Times, I was recently captivated by this article, “A.I. Wrote These Thanksgiving Recipes. Would You Make Them?” by Priya Krishna. Krishna used another AI, Open AI’s GPT-3, a program that takes input and can give a plethora of not only recipe ideas but full measurements and instructions. Some of the inputs for GPT-3 were basic background questions like describing your heritage, to which Krishna typed: 

“I am originally from Texas, and I grew up in an Indian American household. I love spicy flavors, Italian and Thai food, and desserts that are not too sweet. Some ingredients I frequently cook with are chaat masala, miso, soy sauce, herbs and tomato paste.”

Not only did this AI create full start-to-finish recipes, but also created fusions based on thanksgiving dishes and Krishna’s culture. One recipe was Pumpkin Spice Chaat, a variation of a traditional Indian dish. Not only did GPT-3 have a spark of inspiration to fuse two cultures together, but wrote introductory notes (usually tips and tricks written by the experienced chef to aid the home cook, or backgrounds on why they cooked the dish) in the voice and perspective of Krishna. Here is the full top-to-bottom recipe: 

Pumpkin Spice Chaat

Written by the A.I. system GPT-3.

I grew up in an Indian American household, and I love spicy flavors. I often do not enjoy traditional Thanksgiving food because it is too bland. I like recipes that have different kinds of flavors and textures, that balance savory with sweet and spicy and tangy. This recipe for pumpkin spice chaat is perfect for my tastes! It is made with pumpkin purée, chaat masala, ginger, cloves, nutmeg, black pepper, honey, lime juice, cilantro, mango, red onion and chickpeas. It is a delicious and easy snack or side dish that is perfect for Thanksgiving.

Sidenote from Max: This introduction sounds so authentic, the voice and reasoning behind this fusion dish is so clear!!! (End sidenote)

Ingredients:

1 can pumpkin purée

1 tablespoon chaat masala

1 teaspoon ground ginger

¼ teaspoon ground cloves

½ teaspoon ground cinnamon

½ teaspoon ground black pepper

1 tablespoon olive oil

1 tablespoon lime juice

2 tablespoons chopped cilantro

¼ cup chopped roasted peanuts

½ cup yogurt

Instructions:

  1. In a bowl, mix together the pumpkin purée, chaat masala, ginger, cloves, cinnamon and black pepper.
  2. Heat the oil in a pan over medium heat. Add the pumpkin mixture and cook for 5 minutes.
  3. Add the lime juice and cilantro and cook for another minute.
  4. Serve with the peanuts, yogurt and lime wedges.

(End Recipe)

Before I describe how the dish went when Krishna actually made it, let’s revisit DALL-E for a second. Krishna decided to go a step further, inputting “Pumpkin Spice Chaat” into the image generation platform. Below, one of the images is what DALL-E generated, and one of the images is what Krishna made as per GPT-3’s instructions in her kitchen. Which is the fake one?  

It turns out, the left one was generated by DALL-E. Shocking! The vivid colors, pumpkin pieces on the Chaat, dots of yogurt, not to mention the LITERAL PIECE OF PUMPKIN in the background, make the image look authentic. This trick of putting the raw ingredients in the background is something that every food blogger does – as I’m sure you’ve seen at one point or another.

Overall, Krishna rated the flavors of the Chaat as a “grassy-flavored mush”. While sure, the flavor aspects of these recipes are lacking, I’m thoroughly impressed by the depth of both recipe creation and image generation of these dishes. Maybe one day our recipes passed down from generation to generation will be indistinguishable from those generated in minutes by AI. 

 

How Algorithms Help with College Apps (In an Alternate Universe)

Imagine, in an alternate universe known as Algorithmopolis, college applications work a little differently. Instead of applying to colleges that you want to get admitted to, colleges send admission letters to students they would want on campus. 

Which is great and all, no supplemental essays to write! Yet, in this parallel universe, let’s say these admission letters are very committal. Once you open your acceptance email, you have to either fully commit or fully reject that school on the spot, never receiving another chance to attend the school upon such rejection. 

You know you received 100 acceptance letters, but you have no idea which schools sent acceptances. How do you commit to the best school?

In the world of Computer Science, this is known as an optimal stopping problem. When is the optimal, or best, time to stop reading acceptances and commit to a school?

 

The classical example in the computer science field is quite similar, in a pool of 100 applicants to be your assistant, at what point should you stop interviewing and commit to the best applicant, given the fact that you must reject or accept an applicant on the spot?

 

This problem sounds downright impossible at first – you’ll either commit too early to a worse school or reject the best schools in search of something better, or have to settle for a worse school in the end. There are 100 letters you have to sift through, the best acceptance has an equal chance to be the first as it does to be the last (and everything in between). 

It turns out the answer is surprisingly simple, in fact, it’s a number: 37%. To describe further, you should spend a little over ⅓ of your time, or in our case acceptance letters, seeing what’s out there and noting down the best school you saw in this period. After this searching phase, anything in the remaining 63% that was better than the best school you’ve seen you should commit to. 

Let’s quantify: In our 100 letters, the best solution is to open the first 37, with the intent of rejecting them all. Again, there is no definitively best acceptance letter, you wouldn’t know if your #1 school sent you a letter, you can only compare two schools for the better one.

After looking at these 37 letters, let’s assume the “best” school you saw and had to reject was the University of Illinois at Urbana Champaign, not bad! The average person living in Algorithmopolis would be stressed, they just had to decide to reject or accept an offer to study at UIUC! But you know the Computer Science deities and mathematical odds are ever in your favor. 😉

With this in mind, you swallow your fears and trek on. After all, the odds of receiving a better acceptance letter are high. After 10 letters, nothing. 20- same thing. In the 30s, there are a couple, but nothing worth committing to. Nearing the 50 mark, opening and rejecting every school in your path, you stumble across a letter, not your #1 school but definitely a top 5. 

Not bad! The normal person would’ve probably committed to UIUC, but you had patience and a bit of luck. (Not to say UIUC is bad! Let’s just say it was your 6th favorite school). 

Now, since you’ve been accepted to a very good school, let me explain why the 37% approach is so effective. 

Using probability, let’s work from 1 acceptance letter to the 100 that your scholarly self received. With 1 letter, congrats! Since you (probably) want to go to college, accept the first and only letter! Celebrate with some cake. 

With 2 letters, you know the best offer for acceptance has a 50/50 chance of being the first letter you read. Why we exemplify the first letter is important, it shows what we miss out on with each subsequent letter we receive. 

Going to 3 letters, the chance of that first letter being the best one yet is ⅓, 4 being ¼, and so forth to 100. 

Let’s focus on receiving 3 letters before things get too messy. We can either accept the first letter, it is technically the best one we’ve seen yet. Or, hold out until the last letter, being forced to accept it. Both result in many cases where we have to reject the best offer. Our answers lie in the second letter. Applying our 37% rule (roughly), setting a baseline with the first letter and rejecting the offer, and then choosing to accept anything better that follows is surprisingly effective. 

The math is interesting here: this strategy of looking for ⅓ of the time, and committing to any school after, raises your odds of choosing the best acceptance letter to 50%. Look at that! You just turned this 3 acceptance letter problem into a 2 letter problem. (With 2 letters you’ll choose the best letter half of the time).

How do your odds rise to 50%, rather than the 33% of just randomly choosing a letter? With the schools, we can visualize them in the order of reading as 3-2-1, with 1 being the best offer. There are 6 possible scenarios here, and applying our rule of 37%, you’ll commit to the best school half of the time (3-2-1, 2-1-3, and 3-1-2), commit too fast to a worse school ⅙ of the time (1-2-3), and be forced to choose the third school ⅓ of the time (1-2-3, 1-3-2). 

Look at that! With a little bit of logic, computer science, and wit, you’ve gotten into the best college, given the terrible college application process in Algorithmopolis. Now to worry about moving in….

 

Inspired by “Algorithms to Live By” (Brian Christian) and Ted-Ex riddle videos.

Reflections on Traveling Alone (+ a description of my summer trip to San Francisco)

This summer, I was fortunate enough to have the opportunity to not only get a free flight to San Francisco to attend one of my favorite types of events: a Hackathon. 

Being somewhat interested in computer programming freshman year, I attended a coding event, or a Hackathon, run by Naperville North’s Computer Science club. This event was eye-opening: coming from a nonsocial middle school background, hanging out with like-minded students, and doing something I enjoyed (coding and problem solving), not to mention the endless pop and snacks we were provided, I quickly loved this kind of social event. 

Fast forward to the pandemic, from competing in watered-down virtual hackathons to attending webinars, these Hackathons were very much incomparable to their in-person counterparts. 

To end that somber note! There is a national organization, Hack Club, that helps to organize these coding events and sponsors high schoolers to run Hackathons. This year’s summer, they organized “Assemble” – a riff off of Marvel’s Avengers’ catchphrase. Their goal was to “assemble” all high schoolers to their San Francisco HQ, and they even offered travel stipends!

Since I was free about two weeks before school would start, I eagerly signed up and hoped I would get a stipend. Much to my excitement, I was able to get the stipend! I remember that summer afternoon when I raced to my computer to find a $500 flight that was reasonable (this was our stipend).

I was really excited to have the opportunity to get flown out to San Francisco for the sole purpose of coding! This would be pretty much my first vacation ever since the pandemic started, and more especially my first time flying/traveling alone. 

I will admit, I spent much more time than I should’ve trying to make sure I wouldn’t get lost at O’hare Airport (and the San Francisco Airport). Looking at maps, and reading Slack (a communication platform) for Assemble, I was increasingly more excited to go. 

Whew! With all of that exposé, I’ll touch a bit about me actually traveling!

Waking up at 4 AM on a Friday morning, my dad and I rushed to the airport so I could catch my flight. Arriving at the airport, I knew the lines for security would be lengthy, and my experience was no different. With the shortage of TSA and airport employees, I anxiously waited in line, hoping I wouldn’t miss my flight. 

Getting through security – I was thrust into the chaotic and busy environment of a waking airport. Quick sidebar – in Chinese, there is a word for a really lively and happening place – 热闹(rè nào). What I find so great about this phrase is that, in English, rè means hot and nào means noisy – which almost perfectly describes the late summer chaotic terminal I had just stepped into). 

I have, of course, taken flights out of O’hare before. Like relearning a forgotten skill, I found myself walking somewhat familiar routes and slowly finding my gate. Shockingly (or really not so shockingly) it wasn’t that hard to follow signs around an airport I was familiar with. As I sat down and waited for my boarding group, I knew the hardest part was about to come – navigating SFO (San Francisco Airport). Not only was it an unfamiliar environment – but I had read on Slack that I had to take a tram inside of the airport, and I had to navigate through an unfamiliar place. (In fact, the organizers made a video on walking through the San Francisco airport, and it was 8 minutes long and cut in some parts). 

The flight itself was pretty uneventful – waking up at 4 AM meant that I would be spending my entire plane trip sleeping. 

I would like to take this opportunity to talk about this kid – let’s call him Window Seat Kid. Considering my boarding group was last, this meant the plane was pretty much full when I got onto the plane. 

My seat was the window seat, which happened to be occupied by Window Seat Kid as I found my seat. 1) I was too tired to argue too much and 2) the Window Seat kid refused to move. So I’m glad I pretty much slept for 4 hours straight! It made my newfound middle seat a bit better.

 

Landing in SFO, the unfamiliar environment was, to put it lightly, confusing. Terminal sizes twice as big as O’hare, travelers and employees alike yelling to each other, and leaving the dimly lit plane cabin into the bright California sun,  I was definitely thrown off. 

Then I had to find the train. 

(A preview for next week)