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

The "Fissures 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 fissures problem from Advent of Code. The rules of the problem are as follows: The given lines are ((x1, y1) -> (x2, y2)), only consider horizontal and vertical lines; the end goal is to parse the string.


Transcript from the "Fissures Problem" Lesson

>> Everyone feeling pretty good? Do you feel like we're starting to get the language a little bit? Notice that we never really ran into ownership problems, right? The reason being is that ownership problems are easier to avoid sometimes and that last problem was pretty easy, right? We had a static string, we refer to that static string, something else owns it.

We're never going to own that string, whatever we don't care. We could have cloned it out and then owned the string. But why would you do that? Right? Why would you clone something when it exists? Always, so we refer to it, it gave us each line. Again we're just keep passing them along as you just always treat your variable as if only one person can have this thing because even if you have a reference.

If you hand it to someone else they have the reference just to always think of it that way is that one person gets to hold the thing, and that's, it just makes it really easy. So let's go on, let's do problem two. So again, advent of code, yes.

But let's do something with a bit more parsing. I feel like it would be a little bit more fun that last one is very trivial. So thank you again, Mr. Santa advent of code, check it out, great time. So problem two, of course, I dropped all the festivities and we're not gonna actually solve the problem cuz it's fairly verbose.

And you end up finding yourself, just programming a whole bunch about checking for undefines and all that. We're just gonna parse the string. I feel like that is a good thing to do. So you're given these lines, x1 x2, .2, x2, y2. I say that I think I said the right x1 y1 I think I threw a two in the beginning but either way, you get what I'm saying.

.1 points the .2. You should only consider vertical or horizontal lines. So what does that mean? That means either x1 equals y1, or I mean x1 equals x2 or y1 equals y2. And so here you go. Here's the example output. So we're gonna actually parse this output and then we're gonna use it.

So this is a little bit more effort. As you can see, we are gonna probably use split once multiple times. Does that sound about right? And then while we're doing rust I'm also gonna include some more trade operations. And we're gonna actually start using the language in a more idiomatic way canonical way restasis way I'm not really sure what the proper term is

Learn Straight from the Experts Who Shape the Modern Web

  • In-depth Courses
  • Industry Leading Experts
  • Learning Paths
  • Live Interactive Workshops
Get Unlimited Access Now