Category Archives: computer science

Video Game Probability #1: How to Grow 5 Golden Crops in Stardew Valley

Welcome to the first installment of Video Game Probability! You can read the introduction and motivation for this series here along with a list of all posts. This post contains mild spoilers for probability distributions in Stardew Valley. Without further ado, I’m going to jump in!

Stardew Valley is a farming/lifestyle RPG where you grow crops, fish, find love, fight monsters, go on quests, and so much more. I have so much to say about this game and I’m trying so hard to hold in my enthusiasm – I hope you appreciate the sacrifices I make in the name of succinct writing. (But no really I love this game, it’s on Steam, it’s on Switch, it’s even on iOS and Android, so you have no excuse not to play it, please give it a try, it has something for everyone.)

One of your major tasks in Stardew Valley is to fix the Community Center. If you have no soul, you can go corporate and pay a ton of money, but most people go for the Bundle route because they’re not dead inside. A bundle is a set of items (crops, foraged goods, etc) that you donate to the spirits of the forest in exchange for rewards. Once you complete every bundle, you fix the Community Center!

Today, we’re going to talk about the Quality Crops bundle: you must gather 5 golden parsnips, melons, pumpkins, and corn to complete the bundle. The pesky thing about these crops is that parsnips are only grown in spring, melons are only grown in summer, pumpkins are only grown in fall, and corn can be grown in summer or fall. So if you reach the end of spring or summer and didn’t manage to collect the 5 crops for that season, you have to wait a whole year for another chance!

When you harvest a crop, it has a chance of being regular, silver, or gold quality. The game calculates your chances based on your farming level and what fertilizer, if any, was used. (Note: While “luck” is a mechanic in the game that I’d love to explore further, I don’t think your daily luck affects your harvests – correct me if I’m wrong!)

Here’s our big question for this post: How many crops should we plant with what fertilizer in order to guarantee a certain probability of getting at least 5 golden crops?

Continue reading

Video Game Probability: Introduction

A big theme of my computer-science-related content is that I have a hard time understanding concepts unless they’re connected to a real-world use case. I was required to take introduction to probability to complete my degree, and I really struggled because of the abstractness of terms like “geometric distribution” and “expected value.” I didn’t do enough work to understand how probability could connect back to real problems I’d want to solve, so I didn’t manage to internalize its value or develop an intuition for it.

(It took me weeks to understand that “expected value” really meant something like “weighted average” because I didn’t make the connection and no one pointed it out to me… those weeks were tough.)

Probability still doesn’t really come up at work a lot now (phew!), but I still wish I’d paid more attention because it keeps coming up in video games that I’m playing. And while I have enough vocabulary saved up to know what to look up to solve a problem, I haven’t practiced enough to be able to work out the math quickly. So I’m going to start sharing a couple of problems that interest me in hopes of helping out anyone who’s in my shoes.

I make no promises on how frequently I’ll add to this series, but I’m hoping to cover situations in Hearthstone (calculating lethal, chances of drawing a certain outcome) and Stardew Valley (growing certain crops, lightning). I’m open to requests for well-defined and motivated problems in your favorite video games too!

Here’s the index of posts in this series:

Data structures to name-drop when you want to sound smart in an interview

I was originally planning to tweet this by itself:

STARTUPS HATE HER: DATA STRUCTURES TO NAME-DROP WHEN YOU WANT TO SOUND SMART IN AN INTERVIEW

  1. bloom filter
  2. prefix trie
  3. ring buffer

But I realized I actually wanted to say some earnest, not-shitposty things about each of these data structures, so I figured I should take it to my neglected blog instead. If you just wanted the clickbait version, you can stop reading now.

Continue reading

My Coding Interview Style

Today, I told someone that when it comes to interviews, I am a robot with a checklist. I thought it would be useful to write it down for others! Here’s what I do:

  1. Listen to the problem. Ask questions and give example inputs/outputs to make sure I understand the rules. Try to think of edge cases if possible – consider the empty input case, single (1) case, and maximum case.
  2. Think of a solution. If nothing comes to mind, I ask myself if any of these tools are relevant to this problem: hashing and hash maps, sorting, classic data structures, classic algorithms / techniques, and bit logic. Classic data structures include: arrays, hashes, sets, trees, linked lists, stacks, and queues. Classic algorithms include brute forcing, breadth- and depth-first search (remember to explain when you would use one over the other), memoization / dynamic programming, recursive backtracking, and exhaustive recursion. Bit logic rarely comes up, but it’s worth mentioning in case your interviewer is an asshole.
  3. Explain my plan. Once I have thought of a solution, I explain it to the interviewer verbally or with pseudocode. I usually clarify that my intent is to make sure we’re on the same page and that I’m making sure my solution works. After I explain it, I ask if the interviewer would like me to code it up or if there’s anything I should clarify or fix. This is a cheat code because sometimes an interviewer will say that I explained it in enough detail that we can move on without coding it! Or they might ask, how would you make this solution faster?, in which case I didn’t spend too much time coding something and can go straight to the optimizations.
  4. Code. Once I’m coding, I refer back to my pseudocode pretty often because I lose track of my thoughts easily. I like having a plan to read from so that my nerves don’t stop me. I try to write the pseudocode in a way that there’s enough detail that the code isn’t a challenge. As an interviewer, I appreciate seeing the candidate’s plan because it makes it easier for me to follow what they’re doing if they’re silent.
  5. Test and debug. If I’m on a laptop, I run the code with some test cases. If I’m on a whiteboard, I ask the interviewer if they mind if I step through my code with an example or two. I mark up the board with what I expect each variable’s value to be as I go through and make sure things work as I imagine.
  6. Runtime and optimizations. Once I’m satisfied with my solution, I talk about Big-O runtime and potential optimizations, assuming the interviewer cares. Optimizations usually include some algorithm bullshit with sorting or hashing or some gotcha, or maybe adding threading.

Each of these steps take a lot of practice to become good at. Not only do you have to be good at coding, you have to be good at communicating, collaborating with your interviewer, paying attention to details, and talking about improvements. With this list, you can practice each step and get comfortable with it. Eventually, you’ll be able to systematically answer interview questions without hesitation!

Look What You Made Me Do, Chrome

How to use Chrome Developer Tools to get tickets to Taylor Swift’s next concert

For her upcoming concert, Taylor Swift partnered with Ticketmaster to ensure that only legitimate fans can buy tickets. I’d like to say that I’m a true fan who will do the honest work to get a ticket… but I am also a woman with a computer and I like a challenge.

I ended up having a lot of fun exploring Chrome Developer Tools and I wanted to share what I learned. Here’s what we’ll cover in this post:

  • How to send code through the Console tab
  • How to use the Network tab to find relevant activity
  • XHR breakpoints
  • Putting this all together to create fake user activity

Continue reading

Giving the Same Talk Twice

Last month, I gave my first conference talk ever, titled “UX Design and Education for Effective Monitoring Tools,” at TechSummit Berlin. I felt terrible about it. All I could say about it was that it was over and I didn’t make any glaring mistakes, but something felt hollow about the whole thing. I realized that it was because I couldn’t say honestly to myself that I had expressed what I really wanted to say when I wrote the abstract. The good news is that I gave a talk at Monitorama with the same title and abstract, and I feel like I made a bit more progress towards saying what I needed to say. I wanted to write down some of my thoughts on what changed between the two talks.

Continue reading

Your Culture Has Consequences

Allies, put your career where your mouth is.

There is no fire under any tech company’s ass to change their ways. Over the past few years, we’ve seen every major tech company release a statement about their abysmal numbers, their token efforts to improve, and how much they value diversity and inclusion at their companies. It’s been a feel-good hug fest where everyone gets an A for effort.

Yet from the same companies, we see all this talk of not lowering the bartolerating of abusive behavior from their employees, and unwillingness to hire from the existing pipeline. How could this behavior be so pervasive when tech companies claim to be so concerned about diversity and inclusion?

Continue reading

The Impact of Diversity on Everything

I’m a Vietnamese American woman in technology. That is not synonymous with being an Asian American in technology. Here’s the shortest summary of my background I can give: My parents escaped Vietnam on a boat and moved to the United States in 1990 with barely any understanding of the English language. We grew up poor and I pulled myself through high school and university with little guidance from others. I worked after school until 10–11pm several nights a week throughout high school for my family. My high school nearly lost accreditation while I was there, which would have made my diploma useless. There’s so much more to my upbringing than that, but I’ll save it for another time.

Continue reading

Last Minute Interview Tips for First-Time Interviewers

In an ideal world, you would be perfectly prepared for technical interviews before having to go through them and you would know exactly what to say. For most people (myself included), however, that first interview is a complete mystery — you have no idea what to say or do or expect. I wanted to compile my personal list of preparation reminders so that I have a semi-permanent reference for people who ask me for advice!

Continue reading

Your Power is in Another Castle

The trivialization of women’s interests throughout history and what we can learn for the future

In the 1920s, flight attending was a predominately male profession. Passengers were fearful of this new mode of transportation; having an all white, male staff reassured them of the safety of commercial airlines. These men were perceived as capable, competent members of the crew, right alongside the pilot in importance. It was only after World War II, when women took over the job as men left for war, that flight attendants lost their respect, instead becoming sexualized and trivialized.

Continue reading