CppCast - Competitive Coding
Episode Date: February 23, 2018Rob and Jason are joined by Conor Hoekstra to discuss Competive Coding websites and competitions. Conor Hoekstra works at Moody's Analytics as a C++ Software Developer helping maintain and dev...elop an insurance software program called AXIS. Wanting to develop better algorithm and data structure knowledge he started using online sites like HackerRank and LeetCode to do so. He now has a YouTube channel where he reviews the contests from the last week of Competitive Coding sites like HackerRank, LeetCode, topcoder and Codeforces) and also covers solutions to the trickier problems. News Announcing Tensor Comprehensions Google summer of code for GCC Pacific++ 2018 location and dates confirmed 59+ videos now up from Meeting C++ 2017 CppNow Registration Open Conor Hoekstra @code_report Links Code_Report YouTube Channel HackerRank LeetCode TopCoder CodeForces Sponsors think-cell software Embo++ Hosts @robwirving @lefticus
Transcript
Discussion (0)
Episode 139 of CppCast with guest Conor Hoekstra, recorded February 22, 2018.
CppCast is sponsored by ThinkCell Software.
They're looking for developers that would want to work on extremely challenging C++ development tasks.
In their Berlin-based office, they work with no deadlines, no overtime, and no meetings.
If this is for you, go to thinkcell.com slash cppcast and apply today.
CppCast is also sponsored by Embo++.
The upcoming conference will be held in Bochum, Germany
from March 9th to 11th.
Meet other embedded systems developers
working on microcontrollers, alternative kernels,
and highly customizable zero-cost library designs.
Get your ticket today at embo.io. In this episode, we talk about Google's Summer of Code and some conference news.
Then we talk to Conor Hoekstra.
Conor tells us about the world of competitive coding and more. Welcome to episode 139 of CBPCast, the only podcast for C++ developers by C++ developers.
I'm your host, Rob Irving, and your mom and co-host, Jason Turner.
Jason, how are you doing today?
Doing good. I am super tired. I plan to stay awake for the whole episode, though. We'll see what happens.
Yes, what have you been up to today, this week?
I've been doing training this week at a local company. And I will say, I've been thinking about this today.
The C++ community in Denver is really shockingly small.
So the company that I am doing training at is i had just interviewed someone or
they told me the that they needed to go do an interview and i'm like oh well who is it this
community is actually pretty small and they're like oh there's no way you know the person's name
and i'm like i don't go ahead lay it on me so he tells me the name i'm like yeah i totally worked
with him eight years ago at a different company like and and there's a fair number of C++ jobs
that are open here right now.
So it's all kind of surprising to me and interesting.
But yes, I actually did know the person
they were interviewing today.
And I got to wave at him as he walked past the training room.
Yeah.
Small world.
Yeah.
Okay.
Well, at the top of our episode,
I threw in a piece of feedback.
This week, we got an email from Stefan in Norway
saying, hi, I love the show.
I was a bit disappointed, though, in the way
you guys glossed over the SpaceX
Falcon Heavy launch being American
and all. I believe some of the
developers from SpaceX had an AMA
on Reddit at some point and spoke about using
mainly C++. It would be interesting maybe
to listen to one of them on the show.
I did
try to find that Reddit
AMA, and it looks like it was
actually like five years ago.
So I'm not sure
if it would be worth trying to contact any of those
Reddit users if those
accounts are active or whatever.
But it would be great to have someone from
SpaceX on the show to
talk about some of the recent news and what they're working on over there from a C++ perspective.
Maybe they're listeners and one of them will reach out to us.
Yeah, if anyone is there at SpaceX listening to the show or if anyone knows someone from SpaceX and can put us in touch, then please reach out.
It would be great to have them on.
Yeah, and I don't really feel like we glossed over it,
but I don't remember how much time we spent on it though.
It was impressive to watch.
I don't think we glossed over it,
but it wasn't,
it was truly impressive to watch live.
Yeah.
Well,
yeah,
there's still a car,
you know,
on its orbit heading towards Mars at the moment it's ridiculous i
really love some of those memes with spaceman going around the globe it was fantastic oh i
don't think i've seen any of the spaceman memes but that sounds like it could be fun could be
okay well we'd love to hear your thoughts about the show as well you can always reach out to us
on facebook twitter or email us at feedback at cpcast.com. And don't forget to leave us a review on iTunes.
Joining us today is Connor Hoekstra.
Connor works at Moody's Analytics as a C++ software developer, helping maintain and develop an insurance software program called Axis.
Wanting to develop better algorithm and data structure knowledge, he started using online sites like HackerRank and LeetCode to do so. He now has a YouTube channel where he reviews the contest from the last week of competitive
coding sites like HackerRank, LeetCode, TopCoder, and CodeForces, and also covers solutions
to the trickier problems.
Connor, welcome to the show.
Thanks for having me.
So this insurance system that you're working on, is this something that is sold to insurance
companies or is it something that is sold to insurance companies?
It's something that's used internally. I don't know. I mean, I'm not familiar with Moody's
analytics. So it's, it's sold to insurance companies, but we actively maintain it. So
we're, I think once or twice a month, we release like updated versions of the program and people
can download that and convert their data sets.
We're always adding new features and fixing small issues with it. The insurance companies use it to value their existing policies and price their new products.
I have a little bit of experience in the insurance world, and saying that you release an update
every couple of months
that sounds astoundingly fast for that world actually every couple of weeks every couple
of weeks sorry yeah we have something called a continuous release cycle and they capture
i think daily and at least two or three times a month they make a release. Yeah, our quality assurance team that's responsible for that is always very busy.
I imagine.
So do your users actually update every time there's a release
or do they set themselves on their own schedule?
It depends.
So we have the support matrix that we have goes back, I think, two years.
So we usually have one or two maintained versions, which are
like our numbered versions. So we have like 2017.99901 that we will continuously fix the
bugs for, but we won't add new features to. And then every month, a couple new release versions
will come out. So I think we're on 2018.27.01 or something like that. And so it depends on the
client. There are a lot of insurance And so it depends on the client.
There are a lot of insurance companies that they stick with the maintained versions.
And then once every two or three years, they have to get like approval from corporate.
And then they'll upgrade and then they'll get a whole bunch of new features at once.
And then there's other insurance companies that they live more on, like they live off of the newer updates because they need all the new functionality that's coming that's getting put
into the system okay now i'm curious and perhaps we could save some of this for the interview but
i'm still just going to go ahead and jump into it sure in our last interview we discussed
maintaining abi compatibility across versions api versus abi Now this sounds like is a product, not a library that they're using.
Correct. Yeah, we, the clients, they download like an executable.
So from your perspective, even though you're making these releases all the time, you never
have to worry about like, you can change your API and ABI like every five minutes,
and your clients never going to care. i think that's mostly the case yeah
i guess changing the data sets is kind of the more larger concerns make sure you have
compatibility between versions yeah so that's it's actually one of the biggest um like features i
guess of this industry is we have two main competitors and they have what are called
open systems so they release more libraries that then the user can go in and mess around with the code and they
can implement their own custom functionality. But at Moody's Analytics, their software,
it's a closed system. So they don't like to say black box, they like to say glass box. So we
provide like a lot of reconciliation reports, but the user can't actually go in and change the way that we've implemented the calculations.
We offer things called formula tables
where users can write their own custom scripts
to sort of execute their own proprietary calculations.
But at the end of the day,
like the source code is ours and they can't touch it.
Whereas our competitors, you can touch their source code.
But due to that and things that have happened in the industry,
we're doing really
well because of that. Because upgrading is like, it's a breeze. Their data, like anything that
they use from going all the way back to 2012, they can just upgrade. Whereas open source,
when you go and change the source code and then the vendor releases an update, it's a mess to
go and upgrade that. So it's worked out really well for us.
I'm assuming I'm not asking a question
that would be proprietary information,
but you can stop me if I am.
But how are these scripts written
that your users can actually write?
I think we were using a third-party library.
I'm not sure if it's vb.net,
but it's something like that.
And so we're using,
I think it's a third-party library
and compiler for that.
That's actually not part of the work that I work on.
That's the systems guys that do that.
I work more on the calculation engine of the software program.
Okay, cool.
Okay, well, Connor, we've got a couple of news articles to discuss.
Feel free to comment on any of these, and then we'll start talking more about the competitive coding that you have an interest in, okay?
Okay, definitely.
Okay, so this first one is from Facebook AI Research announcing Tensor Comprehensions,
which is a C++ library and mathematical language that they are releasing.
And it seems like the goal of this is to help researchers
so that they don't need to be writing their own C++ code,
but they can write in this mathematical language
very similar to what they're used to being able to write in.
And it gets converted into C++ code using this library.
At least that's my understanding of it.
Does that sound right to the two of you?
I have no idea.
It's a long article.
It's a bit over my head, to be honest with you.
I understand here that it contains a polyhedral just-in-time compiler
based on an integer set library,
which I don't know what that means i can honestly
say it sounded very impressive it does sound impressive i have no experience with artificial
intelligence do you connor connor no uh i haven't done any cuda programming uh it's on my list of
things to do but i'm sure there's some people out there that are very, very happy that this has been released.
Right.
Yeah, they're offering order
of magnitude productivity gains.
And I know, you know, mathematical
researchers, I think we've had other
guests on the show that have talked about how they
you know, C++
is pretty foreign to them, so
this should really help them do their work,
which is great.
Alright, great. So a topic really help them do their work, which is great. All right, great.
So a topic none of us do anything about.
Okay, well, you want to introduce the next one, Jason, about Google Summer of Code?
Yeah, I mean, why not?
So if you're not familiar with the Google Summer of Code, every year for a long time now,
and just looking at this history, at least the last 12 years,
they sponsor projects around the world where they pay students to work on some open source project,
basically. So GCC has just announced that they have been accepted for Google Summer of Code,
and they're looking for applications. And I think that seems like a good opportunity for
our listeners that are interested in compilers and our students yeah absolutely and and the one thing worth mentioning is um they come out with a list
of possible uh project ideas and that when you if you decide to submit yourself to to join the
google summer of code and get funding for this then you would be paired with a mentor. And those mentors have
already submitted possible project ideas. So you don't need to come up with something on your own,
you can kind of look and see if this is something you'd be interested in contributing to. And maybe
you can get paired with a mentor. Right? Yeah. And it looks like they've got some suggestions
for improving their sanitizer library. And adding a fuzzer, which Clang already has,
dash F sanitizer equals fuzzer.
So Clang has fuzzing built into the sanitizer engine.
Parallel compilation of executables, excuse me, of C++ files.
Looks pretty cool. Options.
Absolutely.
Okay, next,
Pacific++ has
announced that they're going to be
doing their next conference
October 18th and 19th in
Sydney this year.
Last year was in New Zealand,
right, Jason?
Yes, it was in Christchurch, New Zealand.
Okay, so they're keeping it in the general area of the Pacific,
but they're moving from New Zealand to Sydney, Australia.
So I guess they're targeting maybe a larger audience, right?
Yeah, yeah.
I mean, Sydney's a considerably larger city than Christchurch.
And to those who are in the area, if I understand correctly,
like the Air New Zealand flights
between Sydney and New Zealand
are pretty darn cheap,
so it should be pretty accessible
to people that are in New Zealand still also.
Yeah.
And in addition to just announcing the dates,
they're saying they're looking for volunteers
to select and evaluate talks
that are being presented
to the conference. So if you have any interest in that
you can email them at info
at pacificplusplus.com
Are you going to go this year Rob?
Probably not.
It's a far trip.
It is a long trip, yes.
How about you Connor? Have you
made it to any of the C++ conferences yet?
No.
I've watched a ton of the CppCon videos online,
but I've never been to a conference.
Maybe my company will send me one year.
Well, so C++ Now, I don't believe,
has officially launched registration yet,
although it is probably worth checking
because I know they were going to do it soon. Yes, if you go to cppnow.org, registration is open.
So that's May 6th through the 11th. And if you volunteer, then you can get in free. And also
cppcon, if you volunteer, you can get free access. You just have to be willing to help,
but you have to pay your trip if you're a volunteer, you can get free access. You just have to be willing to help, but you have
to pay your trip if you're a volunteer, unless you are a student for those cases.
Right. And then last thing to mention, Meeting C++ has still been putting out videos. Looks
like they're up to about 59, oh no, 61 videos now. And one of the latest ones to go up is Sean Parent's lightning talks on polymorphic
tasks templates. I think he's actually
sent out a tweet saying that there was technically a bug in that
code invoking undefined behavior and then has a follow up article on that particular
one. I think that's right. One of his lightning
talks said that okay i have
to look for that article yeah okay well connor uh i i saw your youtube channel uh being posted on
reddit rcpp a couple days ago and i realized that we had never talked about competitive coding on
the show at least not that I remember.
So I kind of wanted to learn a little bit more about it.
Why don't you start off by telling us how you got interested in competitive coding, though?
Yeah, so my first exposure to competitive programming was actually in my third last semester of university. And at one point, I was a double major in computer science, but then I got offered a job. So I dropped the double major and just graduated. So but I had taken a number of
computer science courses. And I just saw a poster on the wall that said, qualifier for this ACM ICPC coding contest. And so I went to it, I didn't really know what I was
doing. And I think I solved two out of the five problems, but I didn't know how to submit them.
So I asked the person, you know, that was in charge, like, how do I submit and the guy sort
of looked at me being like, what you solve these problems and haven't submitted them.
And so then there, luckily, there was a a second qualifier and I went to that one.
At that time, I had done a little practice in between and knew how to submit my problems.
And then I ended up getting on to one of my university's teams.
So I think they had like the A team, the B team and the C team.
And so I ended up going to one regional contest. And that was sort of it.
And then for a number of years, I was focusing on my actuarial exams. And but working as a software
developer. And since then, I guess a year ago, I sort of get started getting back into it. And
it's just a great way to develop your yeah your data
structure and algorithms knowledge um we don't use stl at my company um or at least we're not
exposed to like the actual raw data structures um so i sort of have like a up until a year ago i
didn't have much experience using it um and so now yeah i i I compete in a lot of the contests, and it's a great way to practice
using STL. And, and yeah, that's, that's how I got into it. So I'm curious, you said at one time,
you were a double major with computer science, but I don't believe you actually said what
your actual major was. Oh, so yeah, my initial major was actuarial science. Okay. So actuarial science, for those that don't know, it's sort of the study of insurance statistics.
So I was told in high school or asked, do you know what an actuary is?
I said no.
And they said, oh, you might like it.
You're good at math.
And you get paid well to do basically math all day long.
And so that sort of started me on that track towards that. But then a part of that degree is taking a couple introductory computer science
courses. So I hadn't really even heard of computer science in high school because I went to a small
high school. And then I got down to Vancouver. I studied at Simon Fraser and I took a couple
courses there and really, really enjoyed it, but decided to still stay with actuarial science. And then I discovered a job called actuarial
software developer, and it was sort of the best of both worlds. So that's what led me into the
software world. That's a, I've, yeah, I have heard that actuarial work can be a well-paying field.
Is it also a licensed field? Yeah. so it's similar to accounting in the sense
in the sense that you have to write uh an exam um but accountants only have to write i think one or
two exams and we have eight um and and they're they're pretty rough you have to study roughly
about four to four to five hundred hours per exam um and then the pass
rates are the pass rates are about 40 so oh wow more than half the people after studying for
four to five hundred hours are going to fail um you said four to five hundred hours per exam
and there's eight exams and eight exams yeah I'll qualify that by saying the first five
are considered easier. So you might not need that much for that. But typically, they say it's about
100 hours, sorry, 100 hours per hour of the exam. So the first five exams are about three hours each.
So they usually say two to 300 hours for those. But the last three, the fellowship exams, those
ones are five hours, or i guess two five hour exams
and then one two hour exam and those ones yeah you have to study four to five hundred hours those
ones are rough so like you know adding this up it's it sounds like it's roughly a year of full-time
work just to pass the exams uh it sounds like you're in the like 1500 to 2000 hour range or something yeah the the last three
exams they don't offer they only offer twice a year so if you fail well typically you're studying
for about four months anyways and it takes two months to grade them so uh i do know people that
have gotten their fsa in like three to four years but but typically it takes like seven, eight years.
I'm totally fascinated by this.
It actually honestly sounds harder than the passing the bar,
which my brother-in-law did recently.
I don't know.
It depends what your forte is.
A lot of actuaries are better at numbers
than they are at memorizing and reading stuff.
So I'm sure there are some people that could
pass the bar that would have trouble with the actual exam, but vice versa as well.
Well, that's, uh, that's, so is the, are the exams like mostly just math then?
Uh, yeah, the first five, they cover topics, uh, like probability, financial mathematics,
uh, life contingencies, and then the fellowship exams.
It depends on the track you take.
Those ones are less mathematical.
But yeah, it's still very math heavy.
And then you, I assume, have to keep doing continuing education kinds of things and maintaining a license kind of thing with it?
Yeah, once you have your FSA,
they have something called the CPD, the Continuing Professional Development Program,
and you have to do X number of hours of readings
or attending info sessions and stuff like that.
That sounds considerably more difficult than what I've done.
I don't know about you, Rob,
but I was required to take one statistics class
to get my degree in computer science. I'm not even sure if I Rob, but I was required to take one statistics class to get my degree in computer science.
I'm not even sure if I took that because I was computer engineering.
Yeah, well, mine was actually statistics and probability for computer engineering.
I think that's technically what it was.
I think I may have taken one statistics class.
It was not my favorite.
Yeah.
No.
Well, bringing it back to the competitive coding.
So I know we mentioned four different sites on your bio, and I watched some of your YouTube videos, and those are the ones you seem to follow the most.
I'm just kind of curious, you know, what differentiates those sites?
I mean, or are they all pretty similar? Yeah. So I guess before I jump into sort of what the differences are, I haven't really actually even explained what competitive coding is. So I'm not sure all the listeners have heard of it. So
essentially, I think according to Wikipedia, they call it a mind sport. I wouldn't really call it that. It sounds a bit odd, but it's basically these websites. They host these contests that typically last an hour to two hours. know, three to five problems that are solvable using algorithms and data structures.
So usually you're given a little sort of in-browser editor, and you can use the language of your
choice to sort of, you know, they'll either present you with a function declaration, and
then they just ask you to return a number or a vector or something like that.
Or different sites will actually make you read the input in yourself,
which is a little bit more work.
And then the goal is to be able to solve the problems correctly, obviously,
and then also as fast as possible.
And then based on the site, there's slight differences on how scores work,
which I guess I can jump into.
So the four websites that I cover,
HackerRank, LeetCode, TopCoder, and CodeForces.
So I made a video really detailing the differences between those sites.
So I won't go over all of them because I think I cover 14 different features.
But at a high level, the differences between those four sites is
you can sort of group them into two categories.
So the HackerRank and Leet lead code sites are more geared towards everyone um they're a lot easier
for beginners to get into um and then and they're a lot easier to use in general whereas top coder
and code forces are what a lot of um people that are actually doing in-person um competitive
programming contests they they use to train.
So that's another thing to mention.
I didn't know.
So I guess I discovered the ACM ICPC contest, which stands for the Intercollegiate Programming Contest.
It's hosted by IBM every year, and it's for college and university students.
So I discovered that late in my degree.
I wish I had known about it earlier. But like for anyone that's listening to this, that's a university student
and that's interested in coding, I would highly recommend looking into it. And there's also
another. And so and so that the difference between that contest is that one is you work in a team.
So it's almost like it's almost like coding dodgeball and that and that you work with two other people and you only have one computer.
So you'll get all seven problems or ten problems and you'll jot them down.
And each person sort of has an expertise in the different type of problem category.
And so one person will start coding immediately and the other two people will start writing down the solutions to the other ones.
And so you swap back and forth. Um, and then there's another in-person coding contest, uh, called the, uh, international, uh, informatics or Olympiad
in informatics, uh, the IOI. And that's for high school students. I, once again, didn't know about
that. If there's any height, I'm not sure how much of your audience is high school students.
There are some, but, uh, but if you, I guess if you're a programmer and you know a high school student
that could be interested in this,
you can just Google your country and Olympiad Informatics,
and each country has their own national program
where their students can compete,
and then they'll send one or two teams to the international contest.
So yeah, when those two contests,
like the people competing in them or training,
they'll use sites like Topcoder and Codeforces
because they try to emulate the actual in-person contest,
whereas HackerRank and LeetCode.
LeetCode specifically, they gear their site
towards preparing for technical interviews.
So a lot of people use that site
when they are preparing for an interview that they have with like Google or Amazon or Facebook,
because the questions that you'll get in those interviews are very, very heavy on algorithms and
data structures. And so they those problems sort of avoid like advanced graph theory and anything
that relies on like heavy knowledge of advanced mathematics.
They typically focus on string questions
and something that you'll need a hash table for,
something you'll need a node of binary searches for,
whereas Topcoder and Codeforces, they'll cover all problems, basically.
That's at a high level what the difference is between the sites are.
I'm curious about the live coding ones that you mentioned.
So that sounds kind of like the place to get an early start if you're in high school or college.
What is the end goal, if you will?
So you go and you do this competitive programming and you submit your answers and then they're scored and then, and then what happens? Um, so for the, uh, I'm not as sure about the
IOI cause I never did that one. Um, but I think the reason people compete in them is at the time,
they're just interested in there. They're a lot of fun to do, but at the end of the day,
if you end up at the international uh level competing
in the intercollegiate programming contest like you can choose where you want to work basically
like i think the one of the top i think he's ranked first on the code forces site and either
second and third on the top coder site currently his name he goes by two different handles uh his
name is ganadi and his handle is tourist.
But he competed all throughout, I think the IOI.
If you look at his Wikipedia page, it's, you know, his CV is so long.
And so I think he's a, he's won multiple times.
And he currently, I think is studying.
But he said in certain posts that like, he's been offered jobs by by google like multiple times and other companies and
he just turns them down and he said maybe one day he'll be interested and there's other there's
other top people at you know petra is another one um i think he currently works at google and
speaking of spacex actually so there's uh he was before my time but I've read of a guy. His name is Tomek.
So he also was a top guy for a long time.
And he used to work at Google, but now works at SpaceX.
So I'm not sure if he's a listener.
But yeah.
So I think the end goal is it's great prep.
Some people use these online sites because they never did either the high school or the university contests.
But yeah, it's like if you do well, you're going to have a really easy time finding a job.
Interesting.
I wanted to interrupt this discussion for just a moment to bring you a word from our sponsors.
Jason and I had a super interesting podcast with Arno back in January. He's the CTO of ThinkCell, the number one graphic software used in consulting
firms. He's still looking to grow his team, and what they offer is quite appealing. They work on
extremely challenging C++ development tasks, and they offer more than pleasant working conditions.
With them, you could be working on things like solving linear constraints for automated layout
or reverse engineering PowerPoint with IDA.
They have a large library of generic algorithms, extending the functionality of STL and Boost, in particular improving Boost ranges.
So what you contribute could be used immediately throughout their half million lines of product code.
They're always using the latest C++ features that are available in the latest version of Visual C++ and Clang.
That's because ThinkCell software is cross-platform for Windows and Mac.
As for working conditions, I'm talking about no overtime, no meetings, no deadlines,
and any technical issues can be discussed directly with Arno.
With them, you join a team of 20-plus knowledgeable and creative programmers
with a mix of young and experienced developers
coming from 20 different nationalities from all over the world.
It's a family-friendly environment, and they pay 120k euro annually after just one year.
So if you like what you've heard so far, go to thinkcell.com slash cppcast
to find out all about the job and apply today.
So is C++ kind of the language of choice among these sites,
or do some of them just use pseudocode or some of them allow you to
use different languages? How does that usually work? Yeah. So, uh, it's definitely not pseudocode.
You have to use a, an actual language. Um, and it, it depends on the site. So I actually looked
this up, uh, and on top coder and code forces is it's overwhelmingly C++.
So I think I found a post by someone who wrote a
script and went and queried all the
submissions and you can check what people are writing in
and that was in 2015
and he found that
87% of people are using C++.
And then after that
I think it was 6.2%
Java and less than
3% Python.
And then the remainder was a plethora of other languages.
And the reason for that is that on Topcoder and Codeforces, there's a time limit per question and a memory limit.
And that doesn't vary based on the language.
So C++ just wins because, you know, what do they say? Speed is king.
So yeah, so on Topcoder and CodeForce, overwhelmingly, it's C++. That being said,
on HackerRank, they actually, so I guess I should mention, to answer your other question,
you know, what are the languages they let you use? There's only five on Topcoder.
It's Java, C++, C Sharp, VB.NET, and Python.
And then on Codeforces, they have a few more.
There's 17.
They add D, Haskell, PHP, and some others, JavaScript.
And HackerRank has 49, so you name it,
you can probably, yeah, there's languages I've never heard of.
You know, D...
Well, these ones, you know, D, Rust, Haskell, Kotlin.
But they've got languages like Erlang.
They've got something called Brain with an expletive after it.
Oh, yeah.
Yeah.
So if you want to, you know, Fortran, they've got everything.
And on HackerRank, so they actually have custom time limits per language.
So they try and even it out.
So for C++, it's two seconds.
For Python, it's ten seconds.
And for Java, it's four seconds.
This is the actual execution time.
Execution time, yeah.
Yeah, so I think the way it works is that uh
the oj what they call the online judge it can process uh up to like 10 to the 8 operations
or sort of elements a second so um a lot of the times the easier problems you don't need to worry
about complexity but you know that if you have uh you know input that is 10 to the fifth
and you have a quadratic solution,
that's going to time out
or what they call time limit exceeded.
So based on the length of the input that you're given
and the number of operations you have to do,
you can sort of work out, reverse engineer,
what is the complexity of the algorithm
that you need to use
in order to successfully pass the problem.
That being said, I think on HackerRank, it's hard to find the
statistics for that. But there was a post by HackerRank, and it seemed like Java was the number
one at roughly 30%. And then C++ and Python had roughly 20% each. And I couldn't find anything
for leak code there. They don't even actually mention anything about their time limits.
But I have seen posts where a certain solution will work for C++,
and then someone will post the corresponding code in Java,
and then someone using Python will say,
Python doesn't work, it times out.
So I think C++ in general is used more often on average across the sites.
You know, I love C++.
I use it every day.
I teach it, but I have to say it seems a little unfair
if it does not include the compilation time on the compiled languages.
You only have to compile once.
Yeah, but still.
I've been thinking about that because now with all the constexpr stuff you technically write some code that you know generates your
solutions you know pre-computes them um i do know that i think that at the at the inter the icpc
contest they do have rules around that because when I competed in regionals, I think there was a guy that tried to like, you know, there's a queue when you're getting your solutions processed.
So, you know, someone submits and another guy submits, you get in line and some person was trying to like, you know, ruin the line by basically creating some code that took forever to compile.
And so, you know, while they weren't submitting, they trying to block other people from submitting um and they got in trouble that's fair
yeah although i am curious too though for real like uh all almost all the languages you mentioned
they've had like recent fairly fairly recent large upgrades to the language that changed things like
c++ 11 14 17 and you've like and Python 3 caused a pretty big upset.
Do they let you choose what standard you can use for these?
It depends on the site, but definitely on CodeForce,
you actually not only get to choose, well, I guess you choose your compiler.
So they got one for C++11, they got one for C++ 11 they got one for c++ 14 none of the
sites support c++ 17 yet um but yeah uh hacker rank they've got python they've got python 3
um so you actually you get to choose which version not for all languages but for the popular ones
yeah interesting okay so you've talked about how the in-person conferences can be, or in-person competitive
coding can be really great for kind of building up your CV, your resume. Um, and some of these
sites are just good for practicing for interviews. Is there any other like kind of more tangible
benefits, like just by competing in top coder record forces and being on top of the rank,
would that look pretty good on your resume too? Yeah definitely like the the two main benefits of uh competitive programming are one
like the technical prep you get for interviews but two depending on the site some of them actually
have sponsored contests so i know i know hacker rank had a goldman sachs sponsored contest a
couple weeks ago.
Sometimes it's location based.
So you have to be in a certain country to qualify for an interview.
But they'll say, you know, top 10 people in this contest get an interview.
On top of that, I'm not sure if recruiters are supposed to do this, but I definitely know that recruiters will directly reach out just purely based on your,
like your competitive programming profile on a site. So if you do well enough and you're high
enough on a rank, uh, on a leaderboard, they will just reach out to you and message you like,
so they'll create an account and say, Hey, I'm a recruiter at Google. Um, would you like to
interview? Uh, and so it's, it's, yeah, it's, it's great for career opportunities.
I think, you know, on top of that, it also, you just become a better programmer, like a lot of
times, for leetcode, they if you submit your code, and it fails, it'll, it'll give you the test case
that it failed on. So immediately, you'll be able to see, you know, the test case that it failed on. So immediately you'll be able to see the corner case that you missed.
But on the other three sites, when you submit,
at least on HackerRank and CodeForces,
it'll test your code on a subset of the system testing,
which is all the test cases.
And so you could fail even though they'll give you two or three test cases
so you think you've written it correctly.
And so you have to figure out what's the edge case that I missed.
So it helps you develop the ability to identify edge cases in the code that you're writing that you're not thinking about.
It helps you learn how to optimize your code.
You'll write an algorithm, realize it wasn't efficient enough, and you think about how could I be writing this more efficiently? Things like that.
Do any of them have cash prizes?
Yeah, so I think in Topcoder, they have a whole ongoing sort of tournament throughout the year.
And then it ends in the TCO, the Topcoder Open, um, which is like, you know, the, the best of the best.
And I think I definitely know this year, which is actually part of the reason that I decided to make
the YouTube channel. Um, but they might've done it, uh, last year as well. They actually have live
commentating on, on the, uh, on the contest, which is, uh, it's very interesting because
you at, at that level, when you've got
the best people in the world, uh, you've at top coder, it's a 75 minute contest and there's only
three problems. And, um, the problems are very, very difficult. Like they involve a lot of high
level mathematics and dynamic programming, and usually they're very involved. So it's not just,
you know, it's three problems in one or four problems in one.
And so for the first 20 or 30 minutes of the contest,
you're just sitting there
and they've got this leaderboard that shows,
you know, who's submitted a solution,
but nothing happens for like the first
20 or 30 minutes of the contest.
And so it's interesting to see what the commentator says.
But, you know, some people are speculating
that it's going to become like the next eSports. know esports is sort of becoming really big now and they have live
commentating on on some games now and this could be the next thing uh and so yeah sorry so you asked
is there cash prizes so i think tco their cash prize is five thousand dollars for first place
um so you know you're not gonna you're not gonna, you're not going to be
able to retire off of your, uh, your competitive programming winnings. Um, but there, there are
other, uh, there's other sites that I know that some people that compete on competitive programming,
they, they do make more money off of those sites. So on Topcoder, they have ongoing challenges that aren't actual
competitive programming contests, but they're more like, you know, we have this app that we
need to be written. It's a contest and it's like a thousand dollars for the first place. And,
or they've got some sort of user interface that needs to be designed. It's a thousand dollars for
the first place. And so you can go and look and at any given time there's you know 40 or 50 outstanding challenges all varying from you know five hundred dollars to two thousand dollars a
first place prize wow and there's also i'm sure you guys have heard of kagle i have not i'm not
sure if i have oh um so yeah kagle is very similar to hackerackerRank, but it's like HackerRank for data science.
So you're using mostly like R and Python to solve, you know, like artificial intelligence
machine learning problems.
And their prizes are ridiculous.
So for a long time, Homeland, Department of Homeland Security had a 1.5 million dollar prize
for a top algorithm
on or I'm not sure if it was all paid out
probably it wasn't all paid out to one person but like that
was the prize pool for
like passenger screening
I think I saw
okay
it's the defense
you know I'm in Canada but you know defense spending going to the right place, I guess.
And I've seen other contests.
There was a $1.2 million one for home value prediction, I think.
That was put on by a company called Zillow.
Yeah.
And then there's other ones.
I think I've seen Mercedes, a lot of car companies,
they'll, they'll put some, you know, recognition or, you know, computer vision for, uh, self-driving
cars and whatnot.
Um, and they'll have like $50,000 prizes and $30,000 prizes.
And there's actually like, you know, teams of people and companies that are competing
for this money.
Um, so, uh, so yeah, there's, there's, there's contests out there that you can win a lot but
pure competitive programming i don't think um yeah i don't think you're going to be able to
make that much on a consistent basis at least that's uh pretty wild i didn't know about the
data science ones for sure yeah that's really interesting. Well, are you currently still competing in these or just following now?
No, no.
So yeah, I compete.
I work, so obviously there's a lot of contests during the week that I can't compete in.
But LeetCode, their contests are regularly scheduled.
So they're every Saturday night, 9.30 Eastern time.
So I typically try and write that one. And whenever the other sites have contests that are not during work hours, I'll enter those.
And a couple of the websites, too, they let you compete virtually afterwards.
So a lot of times if I have to make a video on some of them, I'll go and compete virtually as if it were the contest. And it doesn't impact your ranking,
but you still get to do the problems as if it were a contest.
So you mentioned 9 p.m. Eastern, and you're in Canada,
so that's Eastern North America time.
Do you know if there's any of these competitions
that are held for our European listeners
and times that would be good for them?
Yes.
Well, so on all three of the other sites, the contests are scheduled all over the place.
So CodeForce, as I know, they're like a Russian-based site.
And some of their contests are like 5 a.m our time and they're at crazy hours um so but i assume
they're normal hours for russia and europe it's all perspective uh and and and there are
on hacker rank one of their contests is called a week of code where every uh every day for a week
they'll release a problem at 2 a.m and then you have, you can solve it at any point during the week, but each day that goes by, the score of the problem decreases by 10%.
Anyway, so those problems you can solve at any point in that 24-hour period after the 2 a.m. release.
So there's contests that go for an hour or two, and there's some contests that go
for a week long. So it doesn't really matter where you are in the world, you can still compete in
them. Everything that you've said makes me think this game's kind of like Stack Overflow in a way,
although it's an actual competition. So if the contest is released at 2am I'm guessing you have to have the answer in by like
2.45 if you actually want to win
by 45 do you mean
like 45 minutes past the end?
yeah basically like 45 minutes later
because if you actually submit your thing like a day later
then everyone else has already submitted their answers
so the week doesn't,
am I exaggerating the situation?
Well,
no,
I was going to say like the top guys,
they solve,
it depends on the difficulty level of the problem,
but it's,
it's,
it's minutes.
I guess 45 is a minute,
but like,
uh,
for instance,
like on the lead code contest,
that's an hour and a half contest.
And there's typically four problems.
And, uh uh you know
average person will solve two to three of them in that 90 minute period but the top people on the
site they're done all four problems in like 20 minutes um wow and and they'll submit the first
one in like you know it can be seconds uh uh that you know they a lot of the you know i don't want to call them professional
competitive programmers but they train like so much during university while they're preparing
for the icpc to to be able to crack those easy problems out in in literally seconds um and like
you they'll recognize a problem is just a variation of another problem they've seen before so they it's
not even it's not even like they have to think about it it's like a reflex okay and uh and yeah so the the top people are super super fast um uh yeah
i am curious um how much the ability to answer those questions very quickly
uh translates to productivity and like a real company. Like if you worked with
any of the top ranked people, not that you have to give names or anything, but you know, I'm just
definitely, I haven't worked with them. I'm not, I know that there's a couple of people
at my workplace that I've sort of dabbled in competitive programming. But uh yeah i haven't worked with them um i definitely know it does help in
terms of the ability to debug but a lot of times when you're working in a code base it's it's
completely different right you're not you're understanding a framework and making a refactoring
change or something like that you're, you're not starting from scratch.
So that being said, it definitely helps.
One of the comments I got from a Redditor was that I was doing a bunch of things wrong that I shouldn't do.
One of them being I shouldn't be using namespace STD.
The other one, I shouldn't be using macros.
The other one is I shouldn't be using type aliases or type defs,
which are all true statements for maybe a code base.
But for competitive programming, you're trying to go as fast as possible.
So using a macro that shaves off.
Like a lot of the top guys, they'll define a macro B, E for begin and E or B for begin and E for end.
And they'll have macros for their their for loops and all of the types like, you know, unsigned long, long, that's ULL and long, long is LL.
And they'll have like type deft or type alias now um you know like a vector of int is vi a vector
of strings is vs and so a lot of times when you're reading this code it's um it's it's very very
difficult to read and so that's what the redditor's comment was was that you know when you're defining
a macro for your for loop you know now i need to know what your macro means and i said that was a
good point and so in my videos now like i don't use macros, but for the actual competition,
you definitely should be, if you're trying to compete at a high level, because every character
stroke of your keyboard, uh, uh, matters. So some of the top guys code is, is very, uh,
it looks not even like C plus plus Do any of them just copy in?
Do they start the problem and just copy in their macros?
Yeah, that's usually...
I'm not sure what the rules are.
I think LeetCode, maybe you're not supposed to do that,
but definitely on TopCoder,
you're actually, when you watch the TopCoder open,
you can see them actually going.
They're allowed to use any and all resources. So they can go to Geeks for Geeks, they can see them actually going, they're allowed to use like any and all
resources. So they can go to Geeks for Geeks, they can go to Wolfram, Alpha, if they need to
check out some sort of, you know, math integration or derivation or something. And a lot of times
they'll copy and paste in a lot of code. So there's certain problems that require like modular
arithmetic, like so the, it'll be some combinatorial problem,
and they'll say return the number of combinations
of whatever the problem is, modulus,
10 to the power of 9 plus 7.
And so if you have to write your algorithm
always taking the modulus,
and for division and multiplication and exponents,
it's all different.
A lot of them just have, they copy and paste in a type-deft type called mint.
When you use that type, it just automatically takes care of all the modular arithmetic.
So yeah, there's a lot of tricks.
I definitely don't know them all because I haven't been doing it as long as those guys at the top have. But every once in a while, you can go and you can look at what the top guy's code looks like,
and you see some interesting things.
Interesting.
So on your YouTube channel, you go over some of the problems in these contests
and show your answers to them. Are you taking those answers from some of the problems in these contests and, you know, show your answers to them. Are you
taking those answers from some of these top programmers or are you coming up with the answers
on your own? Typically what I try to do, um, because I'm also using this as like an opportunity
for, you know, me to improve as well as I'll have the problems that I cover are problems that, um,
I solved myself. And I always
compare it with other people's code to make sure that you know, I didn't miss something
completely obvious. But a lot of the times on those problems, it's similar solutions to what
other people got. And the other half, I try to focus on problems that like I had trouble with
that I either partially solve, but didn't't completely solve or that i missed something on and that requires you know spending a lot of time reading other
people's code um and actually that's sort of the reason that i started this youtube channel similar
to the reason you guys started this podcast is i think at one point you guys said you were you
were looking around for a c++ podcast and there wasn't really one so you just decided to start it
and i was you know
the way they say you can improve in these contests is to you know read other people's code and sort
of look at solutions to problems that you are not able to currently get because just doing problems
that you know how to do doesn't help you improve it just helps you get a bit quicker and so i
looked around because reading people's code is can be tedious at times. And I figured there'd be some sort of tutorial resource or some,
some videos out there, but there wasn't really.
So I figured if, if I'm looking for this,
I'm sure there's other people out there looking for it as well.
And, and yeah.
All right.
Okay.
Well,
is there anything else you wanted to share before we let you go,
Connor?
No, I think, I think that we covered a lot. Okay. Well, Is there anything else you wanted to share before we let you go, Connor? No.
I think that we covered a lot.
Okay.
Well, obviously we're going to be putting links to your YouTube channel in the show notes.
But where can people find you online?
Are you on Twitter or Facebook or anything?
Yeah, I'm just on Twitter and YouTube and GitHub. Code underscore report is both the Twitter and the YouTube handle, I guess.
All right.
Okay.
Well, it's been great having you on the show today.
Yeah.
Thanks so much for having me, guys.
Sure.
Thanks for joining us.
Thanks so much for listening in as we chat about C++.
I'd love to hear what you think of the podcast.
Please let me know if we're discussing the stuff you're interested in. or if you have a suggestion for a topic, I'd love to hear about
that too. You can email all your thoughts to feedback at cppcast.com. I'd also appreciate
if you like CppCast on Facebook and follow CppCast on Twitter. You can also follow me at
Rob W. Irving and Jason at Leftkiss on Twitter. And of course, you can find all that info and the show notes on the podcast website
at cppcast.com.
Theme music for this episode
is provided by podcastthemes.com.