❔ I have a problem in my code and can't find it

Gist
Program.cs
GitHub Gist: instantly share code, notes, and snippets.
80 Replies
Anchy
Anchy2y ago
How do you know there is a problem?
Jimmacle
Jimmacle2y ago
come on man after all the other threads you just drop the entire program without explaining anything and expect someone to fix it?
Anchy
Anchy2y ago
looks like there is lore I don't know kekw
Jimmacle
Jimmacle2y ago
significant lore i think this has spanned 4 threads now
Pobiega
Pobiega2y ago
4-5 threads and 2+ weeks of time, probably around 10 helpers involved at this point... for binary search over strings and ints
The king of kings
Sorry for not mentioning my problem with the code
The king of kings
Th problem with the code is that it's not prompting to do the searching for searching Binary https://gist.github.com/Programmer-Faraj/062cfae47d7084660edb4ce546d502ed
Gist
Program.cs
GitHub Gist: instantly share code, notes, and snippets.
MODiX
MODiX2y ago
Faraj#6089
From Faraj#6089
React with ❌ to remove this embed.
Milenov
Milenov2y ago
You would probably need decent names of the variables und methods. Prefferably in English.
The king of kings
Sorry, it's written in Swedish. But I could translate to English too. Let me try
Milenov
Milenov2y ago
It‘s a bit hard to read right know but i‘ll run it and see if i can make sence of it 🙂 On a first sight i think you need to think abou some more methods There‘s a lot of code in that switch
The king of kings
Here is the English version, although the translation might not be very accurate, but you'll get the idea https://gist.github.com/Programmer-Faraj/53fb8998584150d4264d19a2cc9dda85
Gist
Program.cs
GitHub Gist: instantly share code, notes, and snippets.
Milenov
Milenov2y ago
hmm it's not whole yet
The king of kings
Well! I know this project can be condensed to a less implementation, but the problem is not here, the problem is what I mentioned above. Really
Milenov
Milenov2y ago
jup you're missing 300 lines 😄
The king of kings
OMG 😆
Milenov
Milenov2y ago
also i see you're using a list Lists have they own sorting method
The king of kings
I know all that bro. But, I need to learn implementing the Binary search, Bobble sort both for numbers and strings. Otherwise, I would've used the methods that you mentioned and save a ton of headache.
Milenov
Milenov2y ago
your sort algorhytm seems alright upload the complete code in english and i'll probably understand where the problem is 🙂
The king of kings
Man, I tried to translate to English, but after some failures, I couldn't do it. It's sooo dame long 😆 The sort algo is correctly implemented, but I need to implement the checking if the list is sorted or not and this is where I got stuck.
Haze.
Haze.2y ago
Surely you just sort the list just before you need to use it?
The king of kings
But isn't Bubble sort's job to sort the list?
Haze.
Haze.2y ago
Can't you just use List<T>.Sort()? Or is it part of the assignment to make bubble sort?
The king of kings
A part of assignment is to learn algorithms and how they work. They have giving me un-completed project for practicing the bubbl, binary leaner which's the above one and another one which I had to create it from the beginning which's this one and functions based on the requirements. https://gist.github.com/Programmer-Faraj/8963d73d17e16380e1ed108758e80270
Gist
Program.cs
GitHub Gist: instantly share code, notes, and snippets.
The king of kings
Implementing their un-completed project was a bit tuff for me, since creating my own is much easier. I learned that you apply bubble for sorting unsorted list and binary for searching the element, but I didn't know that you need to check if the list/array is sorted or not using a function.
Milenov
Milenov2y ago
Well that‘s easy use a boolean variable You‘re using one for the loop. Same principle Initialize with false at start and change it in your sorting method Explain to me again what binary search means. I‘m getting confused cause i learn that stuff in german 😃
The king of kings
Aha! Ok! I'm not really familiar with the implementation that you mentioned. But I would like to see an example. You mean using a while loop? Oh! Really. So you're German citizen and I'm from Sweden btw. Sure, I can do that.
Milenov
Milenov2y ago
You don’t even need a loop Pass the array and the boolean to the other method and then simple if Statement
Milenov
Milenov2y ago
Milenov
Milenov2y ago
something like that for example
Haze.
Haze.2y ago
You could even mess around with out parameters if you wanted
The king of kings
Binary search is the fastest search as I learned from the tutorials. We use Binary search to search for a specific element either integers or strings or even char should be included too. The way Binary search works is like the following. Let's say we have a list/array first we compare if the element that we're searching for is in the middle. if it is in the middle then we hit the target. If not, then we split the list/array in half and we compare if the element that we're searching for is greater than the the middle, then we will throw the left side of the array and compare on the right and if it's not, if it's less than the elements on the right then we throw the right side and only compare on the left side until we narrow the list/array and it gets smaller and smaller until we find the element that we're searching for or hit the target.
Milenov
Milenov2y ago
ah ok i understand now
The king of kings
Ok! Well!That's very easy. But, I'm not sure if this will solve the problem. Yeah! It's not that hard to understand it and the integer implementation is super easy, but I struggled for a week applying it to strings.
Milenov
Milenov2y ago
it should work the same
The king of kings
Since you would need to use these methods Compare(x, y) or StringComparer.OrdinalIgnoreCase.Compare() or CompareTo()
Milenov
Milenov2y ago
but be sure you apply ToLower or ToUpper when you search
The king of kings
Exactly, you mean case-sensitive or insensitive.
Milenov
Milenov2y ago
yep
The king of kings
You have an idea about it already I learned it recently
Milenov
Milenov2y ago
well i did walked the same way you do now 🙂
The king of kings
Ok This video explains it clearly
The king of kings
Daniel Simionescu
YouTube
Binary Search in C# (Beginner Tutorial)
Let's implement the Binary Search algorithm in C# Code https://danielsimionescu.com/csharp/arrays/binarysearch.html GitHub https://github.com/danielsimionescu/csharp-binarysearch Codementor Book a session with me here: https://www.codementor.io/danielsimionescu1996 Gear Laptop: Asus F550JK i7-4720HQ, 15.6 FHD, GTX 950M, 250GB SSD, 12GB RAM, ...
The king of kings
I heard that it's a requirement when doing interviews, but not sure if these algorithms are must.
Milenov
Milenov2y ago
well i should be able to write one but you'll mostly use the ones built in the classes they're vastly more efficient
Milenov
Milenov2y ago
About - Project Euler
A website dedicated to the fascinating world of mathematics and programming
Milenov
Milenov2y ago
check this out it's a nice practice for algorhythms some problems can be brute forced but others will take your programs hours to solve them with brute force it's a nice practice
The king of kings
You're right. The .NET is updating every year and you have some really good and easy LINQ where you can implement all these algorithms in less and readable code, why the hell go through all this mess 🤷🏻‍♂️ Really! I'll check this link and review the content. Aha! Recently, I was recommended of one of the members about practicing by using this link. Thanks for recommending it.
Milenov
Milenov2y ago
well those are the basics and you need to understand them in order to use them correctly
The king of kings
Which ones?
Milenov
Milenov2y ago
i meant such sort and search algorhytms and they will not always work as they are if you are comparing object you need to set your own rules about the sorting but that's implementing of interfaces so you still have a bit to learn till you get to that part
The king of kings
Ok! Yeah! It's always good to learn them when you need to implement them in a various projects.
Milenov
Milenov2y ago
that's the point you will need to do it in more complex projects 🙂
The king of kings
Ok! Really. You mean rules like cultural, ordinal case-sensitive and etc..?
Haze.
Haze.2y ago
Oh god, not another level of complication
The king of kings
What do you mean by interfaces? You're reading my mind lol no complex stuff distilldowo
Milenov
Milenov2y ago
it could be pretty wide range of varieties depends on the project you'er not there yet 🙂 don't worry about it just yet 🙂
The king of kings
Aha! Ok! I get your point. I haven't touch any advanced stuff yet.
Milenov
Milenov2y ago
not so easy to be explained until you got your hands on OOP but it'll come in good time 🙂
The king of kings
Ok I have some knowledge about OOP and I know that you can use interface methods type
Milenov
Milenov2y ago
sometimes you must in order that you program works
The king of kings
Ok
Milenov
Milenov2y ago
interfaces help for the communication between classes
The king of kings
Yeah
Milenov
Milenov2y ago
it has basicaly only method signatures and what exactly the method does it's up to your implementation
The king of kings
Ok! I get what you mean. I haven't used it, but I will in the future. Man you have some good knowledge, you don't seem a beginner like me
Milenov
Milenov2y ago
Believe me i am 😅 I‘m strugling with a simple Snake game at the moment
The king of kings
Really, you're not alone. I'm the same bro. How long have you been learning the c# fundamentals?
Milenov
Milenov2y ago
well i started last summer myself but the actual course with a tutor started arround october sooo little over 6 months now
The king of kings
Oh! Me too man 😆 it's been a year for me only in the fundamentals and people criticize me so often for spending a year.
Milenov
Milenov2y ago
everybody needs their own time
The king of kings
You've got be kidding with me 😄 I started my course with a local school online on October too 😆 that's very funny.
Milenov
Milenov2y ago
so ignore those comments i am not overly happy with my progress as well but i've sen worse 😄 starting an internship next month that's where the magic is suposed to happen but i need to learn PHP and Typo3 for it and i really don't have the time cause of the school project 😄
The king of kings
I know, I don't pay attention on what they say, everyone is different in learning and this is a new skill and we all agree that it will take time, unless you're a genius like Elon Musk or Bill Gates. It's hard skill and many people give up Yeah! Many people struggle as so called thought learner. Well, that's a good progress starting internship, isn't that where you work for free just for learning sake? Why do you need to learn those languages? I know man, it's been a week since my deadline has ended for my another current course and I barely can submit it my assignments now.
Milenov
Milenov2y ago
yep cause they are working with those
The king of kings
Aha! So they're demanding you to learn these languages to use them at your position! I would really like to do an internship with the c# just to test the software developing environment and see how things work in a career level.
Milenov
Milenov2y ago
couldn't get such i would've liked that too but there was actualy only one company in the area who worked with c# and i didn't get it there
The king of kings
Oh! Really. Maybe you should try like LinkedIn or other sites might help you to find for c#
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity. Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server