## My (Not-So-Successful) Quest to Conquer the NYT Connections Game with Word2Vec

The New York Times’ Connections game: a fairly simple puzzle that has been rising in popularity. The objective? Find four groups for four within a larger sample of sixteen total words such that each subgroup has an overarching theme.

I thought this would be fairly easy to solve with some simple usage of word embedding and K-means clustering. After all, if it can figure out king – man + woman = queen, then surely it can figure out that these are all sandwich ingredients. There are enough models out there for topic modelling that it was easy to install a model in under 1 minute, and I just used a simple K-means.

However, I quickly ran into problems. The most major is the fact that K-means doesn’t always give four groups of four. Seeing as this was the case, I switched to a constrained K-means algorithm. Another thing I noticed is that the word embedding probably doesn’t account for the fact that repetition might be used (e.g. ‘tom tom’ rather than ‘tom’).

It’s curious to wonder what a better approach would be, as spending some 2 hours on this little question has proved to be not as fruitful, even for some relatively simple puzzles. Maybe a contextual embedding is needed, rather than just a GLOVE word2vec model.

I also thought a more curated, greedy algorithm might work rather than K-means. Take the two most similar words, and assume they must be a group. Average the two word vectors then find the next word from the now reduced list. I gave this a whack, but also didn’t turn out too well…

… maybe this is a more difficult puzzle than I originally thought.

Nevertheless, below is some sample code:

import gensim.downloader
from sklearn.metrics.pairwise import cosine_similarity
from k_means_constrained import KMeansConstrained

words = [
'plastic', 'foil', 'cellophane', 'lumber',
'organism', 'harpoon', 'trudge', 'limber',
'stomp', 'elastic', 'glove', 'bassinet',
]

# Generate similarity matrix
word_vectors = [
model[word] for word in words # We assume all words exist in corpus
]
sim_matrix = cosine_similarity(word_vectors)

clf = KMeansConstrained(n_clusters=4, size_min=4, size_max=4, random_state=0)
clf.fit_predict(sim_matrix)

print([x for _, x in sorted(zip(clf.labels_, words))])
print(sorted(clf.labels_))

## Tapping Out

I’m a fan of well-designed objects. One where its clear that an engineer spent some late nights thinking about the utility. They consciously insert themselves into the consumer who just want an intuitive experience paired alongside the promised functionality.

Things like the OXO measuring jug, where the lines are placed so that the baker doesn’t have to bend over. Or maybe just a door whose design clearly proclaims whether it should be pulled or pushed. A paperclip even passes this criteria.

The inverse is also true. Sometimes the pursuit for trends or profits causes a product to be utterly disgusting to use, causing pain (well, more so emotional damage). Even worse is when these products are procured by other businesses or the government, and just squirts soap or blows hot air when you want water….

In other words, I hate those stupid new faucets with soap dispenser/dryer that look alike. Shitty things like

or this…

or this…

especially this…

like who thought this was good… a three in one?

KISS.

## A Terrible Philosophy

You are standing next to a lever that controls a runaway trolley. The trolley is headed straight for five people who are tied to the track. You can pull the lever to divert the trolley onto a different track, but there is one person tied to that track. Do you pull the lever?

You decide to pull the lever. Unfortunately, due to lack of infrastructure upkeep, the lever malfunctions and snaps off and you witness the brutal massacre of five innocent workers. It’s a good thing they were unionized and their widows are now receiving proper indemnity benefits.

A runaway trolley is headed towards five people who are tied to the track. There is no lever that you can pull to divert the trolley, but there is a large person standing next to you. The only way to stop the trolley and save the five people is to push the large person off the bridge and onto the track.

You try to push the person off the track. But you, a scrawny philosophy student who subsists on a diet of ramen and Cheetos, lack the power to push the large person off. As retaliation, the large person shoves you instead, and your last thought before you are crushed is about Camus.

You are a surgeon performing an operation on a patient. Suddenly, five other patients rush into the operating room. They have all been involved in a car accident and are in critical condition. You can only operate on one patient, and you know that the other five patients will die if you don’t operate on them.

After asking the RN to find insurance cards in their wallets and realizing that the five new patients are most likely on high deductible plans, you decide to simply operate on the original patient. After all, he has that new BCBS plan that will finally help you make a dent in that ridiculous $100,000 student loan. So much for the Hippocratic oath. You are a self-driving car engineer. You are working on a new algorithm that will prevent self-driving cars from hitting people. However, you know that the algorithm is not perfect, and there is a small chance that it will cause the car to swerve into oncoming traffic and kill the people in the car. Do you release the algorithm? Your boss is Elon Musk. Of course you do/did and was/will be the cause of a major pile up on I-75 one of these days. ## Shared Experiences The clue read 3 letters, 39 Across: Tamagotchis are digital ones celerius: wait you don't know this noah? noahsfart: uhhhh no I don't celerius: did you not have one like in early 2000s? everyone had one noahsfart: dude, I just never did. guess I faintly remember classmates having one??? noahsfart: idk I was just playing too much maplestory lol Noah started doing the crossword on Discord with his friends during lock down as a way to feel connected. However, he didn’t expect a game, out of all things, to cause a moment of self-reflection. “Why didn’t I know what Tamagotchis are? Oh god, what are other toys that I didn’t play with? … did I have a bad childhood? Oh my god, think of all the cultural phenomenon that I never will know! My friends already think I’m weird because I never watched Teen Titans…” He didn’t have a terrible childhood. After all, it’s just a matter of circumstances that he couldn’t control that he never got to take care of a digital pet. The fleeting panic passed by the second the group moved to the next clue: 4 letters, 44 Down: Cubs slugger snickerpunch: isn't slugger a baseball term? is must be AROD noahsfart: it's not AROD, it's definitely SOSA. AROD never played for the cubs. celerius: how do you know this baseball stuff??? noahsfart: ... how do you know about Tamaguccis noahsfart: I mean i did play little league for 5 years. snickerpunch: lmao guccis ## np.vectorize quirk I was being lazy, and had to code up a piecewise function. Rather than use the proper array tools, I used np.vectorize instead but somehow got weird results: import numpy as npdef f(x): if x < .5: return 1 else: return .4points = np.linspace(0, 1, 5)points_flipped = np.flip(points)vec_f = np.vectorize(f)print(vec_f(points))print(vec_f(points_flipped)) returns [1 1 0 0 0] [0.4 0.4 0.4 1. 1. ]  Tuorns out np.vectorize has the property that The output type is determined by evaluating the first element of the input, unless it is specified Took me a minute to figure this out. RTFM. ## Pony Book Pony bookspony stories or pony fiction form a genre in ## Impressions Trist sunk into the sagging loveseat immediately after throwing her keys onto the credenza. The air in the apartment was too warm, but she didn’t have the vim to stand back up to adjust the thermostat. It had been a long day, with several of her clients being especially difficult. One wanted Trist to call his almost-estranged son and to convince him to visit him in the nursing home, threatening to leave him out of the large will. Another, unfortunately, was just never easy no matter the day. It would be another hour or so before Luc, Trist’s husband, got home. Luc typically finishes his scheduled tennis coaching sessions around this time. “Scheduled” seems to be a suggested word. He was far too gregarious to just leave the kids at six sharp, and would stay after to talk and afford guidance in their personal lives. Luc and Trist agreed that kids for them were out of the equation, but Luc couldn’t help but pretend to be a dad for those on the courts. Luc tore his ACL in the middle of qualifiers for a middling tournament, whilst figuratively also tearing any chance at tennis stardom. Since then, it had been difficult finding steady work in a field rife with athletes who flustered in the big leagues. Teaching kids at the high school made ends meet then. For dinner, Trist had a table set with a large heaping pile of curried lentils with herbs, some sausages, and a bowlful of roasted root vegetables. All served on plain glassware as their precious china from the wedding sits unused. Festivities where elegant plates were appropriate just never arose in the year since their wedding. The gibber jabber went as usual; Trist and Luc always loved their banter when together. A little light teasing here or there; a lot of complaining about their days recently. Usually, the nights ended with some light escapism. For Luc, it was scrolling through feeds while Trist enjoyed streaming dramatic series. Parallel play as the psychologist called it: the company itself was the entire point. That night though, they never stopped talking. ” … it’s just those people are so terrible. I know this makes me a terrible person, but I really want him to just… go away if you catch my drift.” “Actually, you know what Trist? it’s been too long, we should go on a vacation. Maybe that’ll help? I know I need one too.” “We’ve been through this. We don’t have the money for that yet. I don’t have the vacation days… your kids’ parents are gonna be mad if you have to cancel practice. So many things to plan. Maybe someday” “Yeah I know….” In that little exchange, the seed was planted. Several weeks later, Trist saw an advertisement in the nursing home promising the elderly the ability to travel like they were young again. No more of the shuffle onto coach buses, and being herded around the sights like animals. It promised adventuring with the vigor of youth. The product Zephyr was a state-of-the-art implant alongside pills which loaded “experiences” to the implants. Essentially, it engaged the remaining senses that VR goggles ignored by interfacing directly with the brain to stream in what it feels like to surf the waves of Bondi beach, or zip line across a Costa Rica jungle. Fanfare for such a revolutionary product was massive. It was also far cheaper than any physical journeys, and the implant was noninvasive. There was a catch though: after an experience, one must still pony up the monthly fee. It turns out the plasticity of the human brain means that it actively will seek and diffuse away those memories. After a few days, it would be as if the experiences never happened. Trist showed Luc the website that night. “Remember how we talked about taking a trip awhile ago? This is so much cheaper!” “Yeah, but we’re not actually doing it. Does it really count?” “It says it can pretend that days has passed and …” “… And there’s a subscription cost. What exactly are we subscribing to anyways?” “Oh that’s for making your brain remember the whole thing.” “Pfft, so not even really remembering it.” “Come on, it’s not even a hundred dollars, let’s just try it.” A week after getting the implants, Luc and Trist opened the mail to discover the package has arrived. The two initially couldn’t decide on what they wanted to do, but ultimately chose the couples package to Belize. The box contained just two pills, one for each of them, and the remaining space where filled with brochures advertising this-or-that “trip.” The actual experience was magical. The getaway was a “reservation” at a cabana on the beach for three days with all excursions included. There with other people on the shore, but they were AI generated and got out of the way when prompted. The weather was, in every sense of the word, optimal. Water, crystal blue. And best of all, the two were somehow able to interact while in this simulation. It was legitimately a fun adventure for Trist and Luc. And oddly enough, the pictures they took while “in” Belize showed up on their doorsteps soon after. Truly unBelizeable as the trite T-shirts would say. This became a tradition for them: every half year, they would pick out another adventure. It provided just enough glimmer in the rat race for them to push on. Some time later, the cycle of capitalism hit a nadir. Trist’s nursing home laid her off, and Luc’s coaching gigs dried up. They struggled to stay afloat, even with the unemployment checks. Those also eventually shriveled up prompting the two to start cutting expenses. By the fourth month, the Zephyr monthly cost came onto the chopping block. They knew that all those experiences would be erased, but figured it’s easy enough once things were better to do it again. After all, don’t many people wish they could re-experience a transformative movie or music for the first time? Six months after the lay offs, the maintenance pills stopped coming. Unbeknownst to Luc and Trist, their implants also malfunctioned. One day, they woke up in bed, and stared blankly at each other’s eyes, waiting for the rush of memories to kick in. It never did. The memories wiped extended beyond their little vacations. Somehow, their entire relationship was among the trail of destruction left behind. The two kept on starring into each eyes inquisitively as if the act of looking could remove the hoarfrost that clearly was between the two strangers now. As Trist and Luc individually got up and looked around their room, they realized how fragile love was. Just bits of neurons firing at the sight of a certain person triggering other portions of the brain to respond; a little hormone here or there too. Yet, from the photos of the two happily together in unknown lands, it was clear that it had meant everything to the two. ## Terrific Trio Pressure is trying to pass for four when you just turned seven, at the “Miss Toddler Panama city” pageant. You’re crammed into the same five-inch heels you wore the year before, blood pooling in your toes. But you know if you don’t win, mom can’t fix the hole in the gator fence, so you’ll be up all night, s*ab gators. Pressure is performing on a party boat that catches on fire, your throat burning from the smoke. You still sing so beautifully that it calms the passengers, so that you and the crew can escape. Pressure is singing the Yemeni national anthem while a handsome but ruthless general pushes a scimitar into your neck, Kristin Chenoweth’s corpse at your feet. That’s pressure. – Jenna Maroney Pressure is trying to finish the New Yorker magazine before the next issue arrives. STRFKR concert was dope. I guess I’m a poet now: ## The Flying Mattress There was a mattress store near my apartment in Providence which never had people in it. Since it lies between where I lived and a popular local taquería, the storefront was actually quite familiar to me. There would always be a sign reminiscent of Word’s Pop Art announcing a sale, and several mattresses lied in the darkness through the dusty panes of glass. Not once did I notice the lights turned on. All this convinced me that this was in fact a front for the notorious mafia in Providence. After all, Providence was renounced for their intimate ties with organized crime, College Hill was not the cheapest real estate, and, most importantly, there were no, nil, nada, zip customers. For four years of my time in PVD, it just sat there. Seemingly abandoned. I don’t know if I preferred it to be a barren storefront, or just one with no character. But eventually an electric bike company peddling (get it?) their wares took over the lease. But perhaps, I misunderstand the economics of a quality mattress. Maybe selling one a week was enough to go even, with its high prices justified by the substantial mass of a mattress. After all, a mattress should be hefty in weight, able to withstand the tossing and turning of the, sadly, probably overweight sleeper for years on end. The mattress might even increase in weight as the various dandruff, hair and dust mites bury themselves into the seams and folds of the mattress. This means that a mattress flying through the air would be surprising… … which is exactly what happened today when a mattress nearly landed on the hood of my car tonight while commuting back home. Moral of the story: don’t buy mattresses which can fly when blown by gusts of air, but if you do, please dispose of it properly. ## Calvin’s Interesting Question Given a set of positive integers$\{q_i\}_{i=1}^n$, describe the set$s_t \in S$of positive integers such that there exists only one linear combination of$\sum_{i=1}^n a_i q_i = s_t\$.

In the comic above, it’s pretty obvious with the amount of money given, that Calvin was hoping to get four “D”s. In fact, all integers from 1 to 9 can only be expressed in one permutation.

A satisfying answer to all sets of integers might be less trivial.