I did a C++ University Assignment

Поділитися
Вставка
  • Опубліковано 18 тра 2024
  • The first 1,000 people to use this link will get a 1 month free trial of Skillshare: skl.sh/thecherno07211
    Patreon ► / thecherno
    Instagram ► / thecherno
    Twitter ► / thecherno
    Discord ► thecherno.com/discord
    0:00 - Intro
    3:30 - Assignment requirements
    12:56 - Doing the assignment
    49:10 - Outro
    Code ► Coming soon...
    Send an email to chernoreview@gmail.com with your source code, a brief explanation, and what you need help with/want me to review and you could be in the next episode of my Code Review series! Also let me know if you would like to remain anonymous.
    This video is sponsored by Skillshare.

КОМЕНТАРІ • 559

  • @TheCherno
    @TheCherno  2 роки тому +117

    Hope you all enjoyed the video, let me know what you think of this format! Don't forget the first 1,000 people to use this link will get a 1 month free trial of Skillshare: skl.sh/thecherno07211

    • @AKsevenFOUR
      @AKsevenFOUR 2 роки тому +2

      The specs did specifically state that the data should be a lowercase English word. Although the cases didn't actually test for it, you didn't know that before submitting the code. Good luck with that.

    • @Theawesomeking4444
      @Theawesomeking4444 2 роки тому +1

      Hi, will u ever do an OpenGL Compute Shader tutorial?

    • @arash1934
      @arash1934 2 роки тому

      This was perfect! I really really loved the commentary of how you approach a problem and it gave me more confidence for some reason. Thank you!

    • @Futureblur
      @Futureblur 2 роки тому

      Yes we loved it please do more :) (Even though this assignment was a bit weird xD)

    • @ArunKumar-dv3dp
      @ArunKumar-dv3dp 2 роки тому

      Please make videos on design patterns with cpp your videos are really amazing 🤩

  • @AgentM124
    @AgentM124 2 роки тому +830

    This assignment is a perfect learning exercise for following instructions and wishes of uneducated users or incompetent product owners, with no knowledge of how the internals work.

    • @jonohiggs
      @jonohiggs 2 роки тому +29

      I was going to say it is good for using some old arcane library with wierd usage requirements

    • @felixinfinita3777
      @felixinfinita3777 2 роки тому +68

      The main takeaway should be: don't follow such assignments and find better job/university/course

    • @Gerz970
      @Gerz970 2 роки тому +12

      @@felixinfinita3777 this is what my assignments look like...

    • @cervixcrusader85
      @cervixcrusader85 2 роки тому +56

      @@felixinfinita3777 many of us are stuck with limited choices for education because of financial and other personal reasons. So my peers and I at our school are always learning things on our own time and just going through University for that slip of paper that makes the job filtering process *slightly* easier for us :((

    • @pawwilon
      @pawwilon 2 роки тому +67

      @@felixinfinita3777 the main takeaway here is that it doesn't matter. It's simply there to let people learn about array, loops, play with pointers and references while adhering to a tight spec. It's not supposed to be a realistic scenario

  • @jacky261198
    @jacky261198 2 роки тому +372

    The fact that status is not an enum physically hurts me.

    • @ghosthookcc2050
      @ghosthookcc2050 2 роки тому +27

      Thought the same it's just really weird in my opinion. But hey school assignments are often pretty shit. Atleast speaking from personal experience...

    • @blank-vw2sb
      @blank-vw2sb 2 роки тому +1

      Typical cpp dev
      High five, bruh

    • @RicoBrassers
      @RicoBrassers 2 роки тому +13

      Indeed. Personally, i would extract those status strings at least into constants (or similiar) in the code, so typos wouldn't be a thing to look out for.
      Should be done with all "magic values", in my opinion, just as Cherno did with the size of the hash table.

    • @berylliosis5250
      @berylliosis5250 2 роки тому +9

      It hurts my soul when schools teach terrible practices like that. They're on their second year, if they don't know what enums are they should be able to figure it out for the assignment

    • @betterfly7398
      @betterfly7398 2 роки тому +1

      The fact that you don't have to ensure any safety spurs up the anxiety within me.

  • @ColinBroderickMaths
    @ColinBroderickMaths 2 роки тому +218

    I think we should take it easy on the students here, but not on the person creating the assignment. The student is learning, so obviously they're not always going to make the best choices because they don't know what the best choices are. They're trying to learn a language and are getting precisely zero feedback on the quality of their code. The fact that it works is all we check, which is kind of worthless if they're being allowed to write terrible code and nobody is helping them improve.

    • @niamhsknits
      @niamhsknits 2 роки тому +5

      I had to write my first programming assignments in C, particularly my second assignment, which was a pain in the butt. Now that it's submitted I can see so many areas of improvement that I might rewrite it this holidays.

    • @scootypoot3205
      @scootypoot3205 2 роки тому +9

      Writing "good code" is something my CS professor has been trying to drill into us the last 2 years, and the more I learn the more I really appreciate being taught that in the beginning. She makes us comment every part of our code to explain why we are utilizing it as well as making flowcharts for every one of our assignments/ programs. I really fear the next CS professor I have b/c I know many of them suck at giving detailed feedback.

    • @ImperatorZed
      @ImperatorZed 2 роки тому +5

      @@scootypoot3205 Flowcharts should *not* be neccessary. Good comments (meaning not on every part of the code but where it's appropriate) plus good test cases should suffice. You are writing test cases, right?

    • @taoliu3949
      @taoliu3949 2 роки тому +3

      @@ImperatorZed A lot of it is more of to makesure the students actually understand and know what they are doing. It's like pseudocode, nobody writes pseudocode after that first year or so.

    • @aeb1305
      @aeb1305 2 роки тому +2

      yeah, i think teachers mainly focus on "as long as it runs" rather than emphasizing good coding practice, which I see is rarely taught at university.

  • @ignacior.dealmeida8581
    @ignacior.dealmeida8581 2 роки тому +32

    Here I am, procrastinating my own assignments to watch someone else doing assignments.

    • @mokoepa
      @mokoepa 2 роки тому

      😂 🤣 🤣 🤣

  • @guywithknife
    @guywithknife 2 роки тому +325

    The strange thing about this assignment is that it dictates how the internals are to be implemented (hash function, number of buckets, states etc) yet its graded purely on the externally visible behaviour. The grading would never know if you just used an std::unordered_set

    • @DFYX
      @DFYX 2 роки тому +25

      Well, not quite. It relies on the output being in the right order. But apart from that, yes. I paused the video after the instructions and implemented it for myself. Some tweaks seemed just more logical to me than what the instructions say:
      - an enum for the slot states
      - Add doesn't need to check if the key exists before finding a place to insert. It can just do both at the same time.

    • @superscatboy
      @superscatboy 2 роки тому +7

      Yeah, that struck me as odd. As long as you wrote a program that accurately simulated the behaviour they were looking for, you'd get 10/10, regardless of the implementation.

    • @Mark-kt5mh
      @Mark-kt5mh 2 роки тому +12

      @@DFYX When I graded assignments as a TA, I would only read the code AFTER the sample passes validation tests.

    • @JohnDoe-sp3dc
      @JohnDoe-sp3dc 2 роки тому

      Welcome to higher education.

    • @RedTriangle53
      @RedTriangle53 2 роки тому +8

      from my experience, university assignments are *never* graded purely on externally visible behavior. Automatically evaluating whether the program works is a convenience, usually it would have to be run manually to check the output. If the program does work, checking its implementation is of course a given too. A lot of people seem to be confused as to why the assignment requires a specific kind of implementation when it is not the best or simplest way to perform the task. Remember that university assignments are for one purpose only, learning. If it asks you to implement a hash table search, it is to train the student to understand and use real hash tables, through a simpler example.
      If your first programming assignment asks you to write a for loop to count to 1000, its purpose is not to teach the student the number 1000, it is to make the student understand and use for loops.

  • @karotto594
    @karotto594 2 роки тому +7

    I don't know C++, but I did the assignment in C# and I am proud that it worked the first time, without errors.

  • @oblivion_2852
    @oblivion_2852 2 роки тому +100

    Imagine university actually teaching you how to make a proper hash table. It'd be cool to see templating, hash calculation, bucketing for collisions etc.

    • @JonasBergling
      @JonasBergling 2 роки тому +16

      That's what we had to do in the algorithms and data structures course at Stockholm uni, also a second year course. We got one week to do that and one or two other assignments, and that was one of the easier weeks of that course. If they had three weeks to do this they must have had multiple simultaneous/overlapping assignments.

    • @darkbibni
      @darkbibni 2 роки тому +2

      Same in France in 2nd year during DataStructure courses

    • @axelpothier2957
      @axelpothier2957 2 роки тому +1

      I did this in my data structures course at Oregon State, it was one of the easier assignments in that class

    • @muesligangster
      @muesligangster 2 роки тому +1

      well a good university teaching that....

    • @oblivion_2852
      @oblivion_2852 2 роки тому

      My university doesn't formally teach C++ (only C). And the data structures and algorithms assignment was only a finite state machine and a very primitive binary tree.

  • @basaramstefan3098
    @basaramstefan3098 2 роки тому +171

    This is a great video! I would like to see more and I'm sure many others agree.

  • @pancreasdragonheart9765
    @pancreasdragonheart9765 2 роки тому +16

    I really liked this type of format. I hope there will be more of it!

  • @marknn3
    @marknn3 2 роки тому +131

    The Find function will return true for tombstone entries for a matching entry string. I think this can fail the test in some edge case.

    • @TheCherno
      @TheCherno  2 роки тому +85

      You're right, that's what I get for not clearing the data... 🤦‍♂️

    • @nyanlauncher7350
      @nyanlauncher7350 2 роки тому

      @@TheCherno c++ series, make template video and how memory works (heap, stack, etc)

    • @ibrahimhabibeh6904
      @ibrahimhabibeh6904 2 роки тому +6

      @@nyanlauncher7350 pretty sure he already has those in the C++ series

    • @IndrekL
      @IndrekL 2 роки тому +1

      @@TheCherno Clearing the data is not enough.
      Then you can get double "orange" by calling:
      Aapple Aorange Dapple Aorange
      You need to keep searching if the status is "tombstone".
      EDIT: My bad. You are actually checking for a match or "never used" status. So clearing should work.

    • @itsbk6192
      @itsbk6192 2 роки тому +4

      @@IndrekL i think the solution you were thinking of was to rewrite this in rust ( ͡~ ͜ʖ ͡°) jk lol

  • @collwyr
    @collwyr 2 роки тому +6

    was very enjoyable to see your approach to this assignment, taught me some interesting library uses too which is always helpful in expanding my knowledge. 10/10 would watch again!

  • @MrJdcirbo
    @MrJdcirbo Рік тому +1

    These in-depth videos are informative and helpful. I, for one, love seeing how skilled programmers implement strategies in detail. So, my vote is for more of these.

  • @eatyofacen00b
    @eatyofacen00b 2 роки тому +31

    when he said "I'm not going to go into the design document"
    I literally put my breakfast down I was so sad.

  • @AllanPichardo
    @AllanPichardo 2 роки тому +4

    Your channel actually got me through university c++/computer graphics

  • @CrosSeaX
    @CrosSeaX 2 роки тому +1

    I'm new to programming and learning C++ by myself. Even though many instructions mentioned there are even unclear for me, this video still provides me a tons of useful information about how I can think of my code, when next time I'm trying to solve a specific problem. Also a tons of practical functions learned along the way.
    Great work body! Need more video like this.

  • @zb1123
    @zb1123 2 роки тому +2

    Fantastic video, really helpful to head your thought process "live" as you went!

  • @HiGherReZ
    @HiGherReZ 2 роки тому +1

    New to your channel but I’m loving your videos man, thanks for the efforts you put in.

  • @bruno.myrrha
    @bruno.myrrha 2 роки тому +5

    As someone who already program in another language this was a great way to get the basics of C++ and some of your code styling. Can we please have more of those? Maybe some HackerRank tests if you're out of Uni assignments.

  • @arash1934
    @arash1934 2 роки тому +40

    Holy moly this is the best thing ever. I haven’t reached the stuff that is the assignment was talking about but its nothing i can’t understand and this video actually was the best way to learn it. You, literally typing along and thinking/commentating for some reason gives me confidence in my own coding and also shows me ways to approach a problem/question which is perfect!
    Thank you and please do more!

  • @brunooliveirasoares7489
    @brunooliveirasoares7489 2 роки тому

    What a video! Even in my case (I work with C++) it was possible to learn watching your solutions!
    Please, continue this format!

  • @TheSilver812
    @TheSilver812 2 роки тому +3

    I love this series

  • @stephen9849
    @stephen9849 2 роки тому +3

    great! I can't wait to watch the full video :)

  • @johndurham7703
    @johndurham7703 2 роки тому +3

    Absolutely! More University/General coding assignments and challenges. More importantly, real life coding from start to finish, whiteboarding and all. An entire project.

  • @ma77bc
    @ma77bc 2 роки тому +5

    This makes me want to go back to my old college assignments and redo them... What have you done to me?
    Really like these kinds of videos.

  • @BS-vm5bt
    @BS-vm5bt 2 роки тому +3

    This gives me memories of my first year in CS where we had to create a sort search algorithm with a red black tree in haskell. That was a fun time though I prefer assembly and other object orentead programming. That year was a nightmare since I knew very little about programming when startead and after 4 months I had to write those types of sorting algorithms and learn reccurion in a week. Though it was a fun experience with the downside of missing some understanding of some concepts that had to re-lern later(not enough time to go through it thorrow).

  • @EmbeddedSorcery
    @EmbeddedSorcery 2 роки тому +8

    I would love watching a series where you just solve Code Wars puzzles!

  • @hishamsomroz6913
    @hishamsomroz6913 2 роки тому +4

    We love you The Cherno

  • @lionkor98
    @lionkor98 2 роки тому +2

    It's fascinating, feel free to do more if you feel like it!

  • @andreivlad6874
    @andreivlad6874 2 роки тому +10

    Really great video! Didn't felt like 50 minutes passed! :D

  • @hubertlenningrad2252
    @hubertlenningrad2252 2 роки тому +1

    Learned a lot of random things I wouldn't have thought to ask. Thanks!

  • @ahmadalbaz6059
    @ahmadalbaz6059 2 роки тому

    i love your videos to the level that i watched the full ad at the beginning

  • @mahmoudel-hawawshy5198
    @mahmoudel-hawawshy5198 2 роки тому

    More of this please!

  • @michaelkotthaus7120
    @michaelkotthaus7120 2 роки тому +4

    Thank you, Yan, for this great video.
    28:50 I think 'constexpr' is already available in C++11. So, you could define the array size by a constant expression.

  • @PlGGS
    @PlGGS 2 роки тому +256

    This assignment is definitely written by a java professor who got stuck teaching a c++ class

    • @nobytes2
      @nobytes2 2 роки тому +20

      sadly most professors never worked an actual job

    • @caenir
      @caenir 2 роки тому +4

      @@nobytes2 At my uni you can see all the papers they have published, and sometimes you hear about where they used to work.

    • @tolkienfan1972
      @tolkienfan1972 Рік тому +3

      The mere idea of "java professor" is, frankly, ridiculous.

  • @ScorpioHR
    @ScorpioHR Рік тому

    Using mod for wrapping around blew my mind!
    THANK YOU

  • @yassineacherkouk
    @yassineacherkouk 6 місяців тому

    I start learning programing 5 month ago, after i learn all height value algorithms and data structures, and did a lot of problems in Leetcode this second years assignment seams to me soo easy, that mean i m in a good path, and also thanks to you for your c++ course a learn a lot from your channel.

  • @manucanedo8039
    @manucanedo8039 2 роки тому +1

    Hey Cherno, great format! I got covid and this was a nice way of chilling at home inbetween paracetamol dosis!
    I'd add to the code maybe the usage of range based loops if you are iterating over the whole array of Entries? It's a good best practices to teach IMO. Other than that, it can't get any better for those specs :)

  • @DFYX
    @DFYX 2 роки тому +64

    You actually have a slight mistake in your Find method, it doesn't handle "tombstone" correctly. "Aapple Dapple Aapple" would result in an empty output while the expected output is "apple".

    • @Splines
      @Splines 2 роки тому +1

      You could also adjust the Add method. If a key exists, don't just return but set the state to "occupied" beforehand. This way, no need to clear any data in find. For "Aapple Dapple Aapple": after Dapple, "apple" is still stored, just set to "tombstone". Then when wewant to add another "apple", we just set it from "tombstone" to "occupied" and it will print again. We update the data only if it becomes stale.

  • @erickr199
    @erickr199 2 роки тому +3

    A series in which you speed run university assignments sounds cool

  • @EmbeddedSorcery
    @EmbeddedSorcery 2 роки тому +4

    I kind of like getting down to the command line compilation. Nice change lol. I really wish C++ had a Rust style build system though... would be super nice.

  • @anthienvo
    @anthienvo 2 роки тому +3

    Oh yes. More of this with medium/hard Leetcode questions, please!

  • @pponcho8245
    @pponcho8245 Рік тому +1

    I really enjoyed this video! It makes me feel as if I know how to do this because you explain it so well, but trust me, I would not be able to do this on my own lol

  • @Upzia
    @Upzia 2 роки тому +8

    3 Weeks, wow, that’s a long time for this.
    Pretty clean code, good explanation of thought process. Fun to see what other educational institutes does in diff countries.

    • @humptyDumptyHadAGreatFall
      @humptyDumptyHadAGreatFall 2 роки тому +3

      Well its 3 weeks because this is not the only thing you have to do... Keep in mind there are lots of other projects, exams, homework etc. for other classes.

    •  2 роки тому

      @@humptyDumptyHadAGreatFall Haha, at my uni we get new programmings assignments every week. Deadline is always in 2 weeks, but you get bonus points if you submit it in the first week. Plus the difficulty of our assignments is on another level and we can only use C. :) And there is still a lot of other things for other classes to do...

    • @epiram
      @epiram 2 роки тому +1

      @@humptyDumptyHadAGreatFall more importantly people that never used c++ before wont finish this assignment as fast

    • @humptyDumptyHadAGreatFall
      @humptyDumptyHadAGreatFall 2 роки тому

      @ Yes, we get new C++ assignments every week too. Our deadline is one week and no exceptions.
      I was just pointing out to people who are self thought programmers and comment on how long they have on the assignment, that it's in not as simple when you are at uni and have other shit 2.

  • @simyosimyo
    @simyosimyo 2 роки тому +11

    This is kinda like watching a speedrun

  • @siwi5315
    @siwi5315 2 роки тому +2

    This is a hashtable, it's called hasing with linear search. There are other implementation of hashtables, for example a hastable with lists.

  • @gagandeepiiitd4377
    @gagandeepiiitd4377 2 роки тому

    Excellent video!

  • @KorrZ226
    @KorrZ226 2 роки тому +1

    Interesting video! Would like to see more like it.

  • @CRBarchager
    @CRBarchager 2 роки тому +1

    47:50 It brings me joy to see the workaround the trailing space as I've always felt that doing stuff like this myself was a bad or a wrong way to do it. I don't know why. It works as it should but just felt that there should be an easier way to do it.

    • @lewistherin4096
      @lewistherin4096 2 роки тому

      Perhaps you should have a look to std::accumulate, check the third example with dash_fold lambda in the documentation.

  • @enif_plays
    @enif_plays 2 роки тому +6

    One edge case you missed(and the test cases didn't cover) was in the input checking. Valid keys were supposed to be lowercase English words, so any keys with upper case or other non word characters should have been ignored.

  • @abdelwahhabfellahi9790
    @abdelwahhabfellahi9790 2 роки тому

    Thank You Very Much You Really Deserve The Best Man ! ❤️

  • @salman8562
    @salman8562 2 роки тому +1

    I would love cherno to review more things like this, even big codebases that are in C++ because they aren't that much material available for that language, I love C++ but I don't know what are the best practices, test cases, and stuff like that.

  • @simonluner8093
    @simonluner8093 2 роки тому +11

    You can use range based for loop in your Print function. They were in language since C++11.

    • @totalermist
      @totalermist 2 роки тому

      You could also split Entry into two separate arrays "status" and "data" and use std::copy_if with a std::ostream_iterator and have the STL take care of the loop and the correct separator-handling like so:
      std::copy_if(std::begin(data), std::end(data), std::ostream_iterator{ std::cout, " " }, [&](auto&& key) {
      auto slot = std::distance(data, &key);
      return status[slot] == "occupied";
      });
      Two birds, one stone😉

    • @electronpie
      @electronpie 10 місяців тому

      Another thing that exists in C++11 is constexpr (both variables and functions), unlike what Cherno said at 23:46

  • @codystar3669
    @codystar3669 2 роки тому +1

    I love this channel ♥️
    I regular viewer of this channel ✨💕
    And I learnt many things form this channel
    Thankyou thankyou very much🙏✨✨
    Thankyou for this video also🔆

  • @LamboPita
    @LamboPita 2 роки тому +1

    @22:05 The substring method is hopefully more performant than constructing a new string from a const char*. The c_str method should be used in the other case to guarantee null termination. Although, I believe all implementations of std::string null terminate the buffer by default, so it wouldn't cause an issue (hopefully).

  • @greob
    @greob 2 роки тому

    Thanks for sharing, very interesting.

  • @niallrussell7184
    @niallrussell7184 2 роки тому +1

    the -'a' triggers me, when there is uppercase in the input stream!🤣

  • @StevenMartinGuitar
    @StevenMartinGuitar 2 роки тому

    Yeah great! More of this!

  • @pseudounknow5559
    @pseudounknow5559 2 роки тому

    Very cool video !

  • @mtheos
    @mtheos 2 роки тому

    A hash set is a specific kind of hash table where the key is the value. Hash tables are associative arrays and are usually implemented as an array because it gives optimal O(1) best-case performance. They can be implemented as trees which have better worst-case performance at the cost of best-case performance.
    Other than having a terrible hash function this is just a linear probing hash table/set with a fixed size.

  • @nickhamilton5322
    @nickhamilton5322 2 роки тому +4

    You comment a couple of times that the spec doesn't talk about terminating the find after a certain number of iterations. It does though - "keep trying until key is found, or we're certain it doesn't exist". If we've checked all the slots we can be certain it doesn't exist and should therefore stop, returning false in your case

  • @dwolrdcojp
    @dwolrdcojp 2 роки тому

    More videos like this please!!!!

  • @mrsmellybeard8338
    @mrsmellybeard8338 2 роки тому +6

    It's always fun to tinker with problems to solve :)
    It doesn't really matter because the test cases don't check for it, but I think you can save yourself that infinite loop and still adhere to the requirements. The requirements say "Keep trying until key is found, or we're certain it doesn't exist" ... If you've tried every slot and haven't found it, you're not going to find it on any subsequent iterations so you probably just stop there.
    Anyway, thanks for the video!

    • @pemifo260
      @pemifo260 Рік тому

      He probably thought some data status can be “tombstone” in the future, so it’s place can be changed

  • @samljer
    @samljer 2 роки тому

    holy hell you made that way more convoluted then it had to be.

  • @insu_na
    @insu_na 2 роки тому +20

    Do you ever check on the 10 character limit for the inputs? Because the assignment also says you need to discard invalid inputs, and any input over 10 characters would be invalid...

    • @theairaccumulator7144
      @theairaccumulator7144 Рік тому

      You don't know how these kind of assignments work. You will **never** recieve invalid inputs outside of the ones they want you to check specifically (the first letter here). You assume the user knows the rules before giving inputs to your program.

    • @jonispatented
      @jonispatented 11 місяців тому

      @the air accumulator you never assume the user knows the rules. My professors absolutely required that I implemented guards against the inputs they told me were invalid.

  • @syedkumailhussainsherazi3871
    @syedkumailhussainsherazi3871 2 роки тому

    More videos like this plz.

  • @dannikolaides6270
    @dannikolaides6270 2 роки тому +2

    I think you've missed a rather important requirement for searching - it says "or we're certain doesn't exist". If you loop through the entire "hash table" you can be certain the entry does not exist. You probably shouldn't let it infinitely loop! I would expect the automated test to fail that case.

  • @YogeshKumar-ct4de
    @YogeshKumar-ct4de 2 роки тому +5

    There is a small bug in the code. After deleting an entry if try to find it again it will return true. So it will fail on a test case like Aapple Dapple Aapple. This can be resolved by setting the data to empty string in delete.

  • @fmdj
    @fmdj 2 роки тому +2

    The flag strings all start with different letters so string comparison in this case just compares one char, not a big deal. Also, if you want to avoid typing mistakes just define them as constants.

  • @mobslicer1529
    @mobslicer1529 2 роки тому +1

    To my knowledge every function, not just main, will return the value 0 appropriately cast to the return value if the return statement is omitted.

  • @thecease6910
    @thecease6910 2 роки тому +1

    I don't code in Cpp, but I watched this full video, it's very enjoyable. It was oddly relaxing.

  • @Erackness1
    @Erackness1 7 місяців тому

    Attaching the code and assignment would be very helpful for us to follow along!

  • @PeterfoxUwU
    @PeterfoxUwU 2 роки тому +1

    with the space at the end, you could also always pop the last character of the string since you know it will be a space

    • @AssemblyWizard
      @AssemblyWizard 2 роки тому

      This isn't a string, it's printed to stdout

    • @PeterfoxUwU
      @PeterfoxUwU 2 роки тому

      @@AssemblyWizard ohh 😪

  • @AdroSlice
    @AdroSlice 2 роки тому +12

    When I get assignments like this at trade school, I like to make a "lawful" edition, following the instructions as closely as possible, and an "anarchy" edition where I still fulfill the core requirements of the program, while restructuring everything else to make more sense.
    Of course, this kind of effort wouldn't be worth it to everyone.

    • @berylliosis5250
      @berylliosis5250 2 роки тому +7

      This assignment's requirements sound like what would happen if a mostly-nontechnical person tried to tell you how to implement something. As the programmer, it's part of your job to tell the business when their requirements make no sense from either a business standpoint or a technical standpoint. Even though the professor wants the lawful version, the anarchy version is the correct way to solve the problem, and in a real professional context it would be your responsibility to tell him that.

  • @jgurtz
    @jgurtz 2 роки тому +1

    Love this format really but feel like it was a missed opportunity to create a small Makefile since we're in Linux land. That could also be used not only to do the compilation/linking, but also to run all the functional tests as well with a test virtual target. Makefile are a saving grace when working in the cli and translate very well into ci/cd systems in the real world.

  • @siddharthasarmah9266
    @siddharthasarmah9266 2 роки тому +28

    a video thecherno has always promised in the c++ series and never made is 'how the heck memory works and memory allocation works'. Just pointing out to this topic to remind you.

    • @kartikeyagarwal6087
      @kartikeyagarwal6087 2 роки тому +1

      Also templates

    • @andreialdea6072
      @andreialdea6072 2 роки тому +1

      I second this reminder

    • @Borgilian
      @Borgilian 2 роки тому +1

      Check handmade hero for memory allocation. It's much more in-depth, better, and goes beyond most of these "just use the std::vector / STL bro" type of videos.

    • @D3r3k2323
      @D3r3k2323 2 роки тому

      That would be a very long video lol

    • @siddharthasarmah9266
      @siddharthasarmah9266 2 роки тому +2

      @@kartikeyagarwal6087 he already has one on that. Just search for thecherno templates. And you will get the video

  • @gamersfunnl2067
    @gamersfunnl2067 2 роки тому +21

    Could you make a video about the keyboard shortcuts you use?
    Your navigation and editing is so fast and efficient.
    I'm sure loads of people would learn a few new things and could become faster themselves.

    • @robbertzzzzz
      @robbertzzzzz 2 роки тому +3

      Looks like just a lot of ctrl+arrow keys for jumping left and right by full words, shift+arrow keys to select characters, ctrl+shift+arrow keys to select full words. Double clicking a word also selects it. Nothing more special than that other than doing it really quickly from what I can tell

    • @gamersfunnl2067
      @gamersfunnl2067 2 роки тому

      @@robbertzzzzz how about moving to the start/end of the line, selecting the entire line, deleting the entire line and moving the line up/down?

    • @robbertzzzzz
      @robbertzzzzz 2 роки тому +1

      @@gamersfunnl2067 end/home, shift+end/home, and I think hitting ctrl+x with nothing selected cuts the entire line.

    • @salman8562
      @salman8562 2 роки тому

      Same

    • @ryan-heath
      @ryan-heath 2 роки тому +1

      @@gamersfunnl2067 move lines up/down alt+up,alt+down
      copy lines up/down shift+alt+up,shift+alt+down
      no need to select

  • @sebastianwilke626
    @sebastianwilke626 2 роки тому

    Cherno's the type of guy who explains what a code review is

  • @romanbujna9567
    @romanbujna9567 2 місяці тому

    @TheCherno There is an infinite loop in Find function, when the table is full and you try to add other element

  • @promortalgaming4562
    @promortalgaming4562 2 роки тому +1

    Please make a video on standard getline function of C++

  • @semerjamsi4469
    @semerjamsi4469 2 роки тому

    thank you gentleman

  • @justtegan2
    @justtegan2 2 роки тому

    This is how my classes are very in-depth with lots of reqs that helps us make code that we won't use after college

    • @archardor3392
      @archardor3392 2 роки тому +1

      Keep doing them, even if they feel boring. They teach you to think and cement the algorithms and programmers way of thinking into your brain. You won't use that code after college, but the principles will remain the same and THAT you will use :)

  • @abdomohamed4962
    @abdomohamed4962 2 роки тому +1

    Finally done with the c++ serius .. time for the game engine serius :)

  • @Revin2402
    @Revin2402 2 роки тому +4

    What bothers me most is probably that even if you have to use strings for those statuses I would at least have defined them as static const variables or something for the sake of readability and to prevent typos etc. Sure there are other optimizations especially regarding performance, but that just bothered me really.

  • @henningerhenningstone691
    @henningerhenningstone691 2 роки тому

    47:22 and that's what I love about C#, there it's literally 1 line and super descriptive:
    string.Join(" ", m_Entries.Where(entry => entry.Status == "occupied").Select(entry => entry.Data))

    • @ABaumstumpf
      @ABaumstumpf 2 роки тому

      Yeah... you can write that in 1 line in C++ as well - but i would say neither is "descriptive" or even acceptable code.

    • @epajarjestys9981
      @epajarjestys9981 2 роки тому

      @@ABaumstumpf If you are used to functional programming then that line is perfectly easily readable and tells me in one glance exactly what it does.
      I wonder how you'd write that in C++. Sadly I haven't used C++ since before lambda functions were introduced there. But from a quick glance it does seem to require a lot more verbosity to use functional approaches there.
      So how would you actually write that in a C++ one-liner?
      In JavaScript it would look like this (very similar to the C# example):
      m_Entries.filter(entry => entry.Status === "occupied").map(entry => entry.Data).join(" ");

    • @ABaumstumpf
      @ABaumstumpf 2 роки тому

      @@epajarjestys9981 "If you are used to functional programming then that line is perfectly easily readable and tells me in one glance exactly what it does."
      ... there are always people that says this even about brainfuck.
      for how to do it:
      in general i would give the object a function to print the filtered content, then outputting it would be simple.
      Or one can use either boosts ranges-join, or std::rangers with filter/join (just the lambdas become a bit long).
      "for( const auto& elem : toBePrinted | std::views::filter([](auto ele){ return ele.status == OCCUPIED; }) ) result += ((result.empty() ? "" : " ," ) + elem.data);"

  • @jfmiguez
    @jfmiguez 2 роки тому

    The Cherno, an idea for your C++ channel... making some videos about Design Patterns. Cheers and keep these coming!

  • @lwave9544
    @lwave9544 2 роки тому +4

    Please read carefully. You have to ensure termination in the Find method. The requirements say you have to keep searching until it is found, or your are certain it does not exist. Imagine a full table with entries "a" and you search for "b". In your case the program doesn't terminate. But it should after 26 iterations.

  • @katanasteel
    @katanasteel 2 роки тому +1

    Your Print function's for loop could be simplified with a ranged for, since it's iterating over a member array it will know the size. Like this:
    for ( auto &entry: m_Entries)
    {
    }

  • @AssemblyWizard
    @AssemblyWizard 2 роки тому +1

    Your Add function loops twice over the table, both in Find and GetInsertIndex. Instead you can add an outInsertIndex parameter to find (it can be different than outIndex because of tombstones).
    Also, I don't like the Size being hardcoded 26 without an explanation. Instead I'd suggest ('z' - 'a' + 1), which explains why 26 and also avoids potential mistakes. In python it's even better, len(string.ascii_lowercase).
    btw having automated testing doesn't mean there is no human testing, it's very common to have both to let the human focus on less trivial problems.

  • @MrRys
    @MrRys Рік тому

    well, the assignment says that you should keep trying until you are certain that the key doesn't exist, so it's not just if you encounter "never used" but also if you get back to your original point, so it doesn't have to (shouldn't) loop infinitely

  • @rishiniranjan1746
    @rishiniranjan1746 2 роки тому

    it really helping us learn c++

  • @TheTimster02
    @TheTimster02 2 роки тому +1

    With the print issue at the end, I would personally just build a string first and cut off the trailing space before printing the complete string.

  • @jerrya17
    @jerrya17 2 роки тому +4

    Your videos are rekindling my interest to get back into programming. Thank you

  • @cm5754
    @cm5754 2 роки тому

    Someone else mentioned the need to skip bad inputs. Something like ABad that isn’t all lowercase would be illegal, so the input validation should make sure to skip it. Same if the key is longer than 10 characters. I would expect at least one test case to make sure many kinds of invalid inputs are actually being ignored.

  • @jacoboneill3735
    @jacoboneill3735 6 місяців тому

    Would love to see how to make design documents. Because I didn't do Computer Science at College or University level, never had to learn it. Would be interesting to know how it's done properly. Love the C++ videos!

  • @xvoidee
    @xvoidee 2 роки тому

    Can you please do the review of your workplace? :) Which hardware do you use, keyboard, mouse, trackpad, etc.

  • @keithle_
    @keithle_ 2 роки тому +2

    I showed this assignment to my teacher and he found this interesting too. He agreed to let me use this assignment as practice before the real assignment drops but he added another requirement: not to use sstream but to use string or string.h instead. Idk if it's harder or not but I'll try.

    • @SeanHayesT
      @SeanHayesT 2 роки тому

      The stringstream can be avoided fairly easily to just use cin directly. For example, while(cin.peek() != '
      ') ...

  • @BukhariTechnologies
    @BukhariTechnologies 2 роки тому

    If you miss the return 0. It is automatically if needed will be included by the compiler.

  • @vilkillian
    @vilkillian Рік тому

    Assignment said that you should keep searching until we are sure that there is no such key in hashtable.
    so limit on 'Size' number of iterations actually is there

  • @e.i.p3471
    @e.i.p3471 2 роки тому

    I got really happy to see how easy univ assignments will be and then I read comments below 😥