Polyglot Programming: TypeScript, Go, & Rust

# Count Trees Problem

## ThePrimeagen

terminal

### Check out a free preview of the full Polyglot Programming: TypeScript, Go, & Rust course

The "Count Trees Problem" Lesson is part of the full, Polyglot Programming: TypeScript, Go, & Rust course featured in this preview video. Here's what you'd learn in this lesson:

ThePrimeagen provides an overview of the count trees problem from Advent of Code and the problem's initial input. The goal of the problem is to count the total number of trees that would be hit while traveling, three right and one down, until the bottom is reached.

Preview
Close

### Transcript from the "Count Trees Problem" Lesson

[00:00:00]
>> All right, awesome, so let's move on to Problem 3, I really did wanna get through a lot of this. So are you guys, is Rust interesting? Is Go interesting? How do you feel about Go? We haven't talked much about Go. Go is really simple, right? Everything you think you should be able to do it just does it, right?

[00:00:16]
That's why I said Joe is gonna refer to as the working man's language because anyone can just get up there and just start typing Go and be largely successful with almost no knowledge. You may not be as idiomatic as possible, but it will still run fairly fast. You will likely run into zero foot guns, and you may write a little too much boilerplate, that's about it, so it's a pretty nice language.

[00:00:37]
All right, so let's move on. Last question, I just wanted to do one more, but this one's from 2020, cuz I think this one's a pretty fun one, it gets us a little bit more into something unique. So again, Mr. Santa, thank you, here's a link to it.

[00:00:50]
So you're given this as you're following input, and you want to be able to take this and you are gonna ride a toboggan, a sled down this and see how many trees you will hit if you go one down, three over. One down, three over, one down three over, and it wraps over and over and over again.

[00:01:10]
So it just goes on infinitely this way. So I mean, these problems tend to be really hard if you don't have a good strategy going into it, but this one I think, will be fairly easy. So here's our initial input. So if you're on the website, you can grab that right down copy, cuz you know we're going to use it shortly.

[00:01:25]
And a pound sign is a tree. A dot A piece of snow. So here's our example input, you don't need to get the size, we should just be able to parse this. And we need to travel three right, one down and count how many trees we hit starting at 00.

[00:01:41]
So, and you can make the assumption that this direction is positive y, and this direction is positive x,

### Learn Straight from the Experts Who Shape the Modern Web

• In-depth Courses