r/computerscience • • Apr 18 '24

Article Simplest problem you can find today. /s

Post image
240 Upvotes

Source : post on X by original author.


r/computerscience • • Oct 27 '20

I'm building a computer, and i was looking at this diagram. I was wondering how the control unit did its job if it didn't have a a direct line to the user inputs.

Post image
239 Upvotes

r/computerscience • • Mar 18 '25

Why do games use udp instead of tcp?

238 Upvotes

I’m learning computer networks right now in school and i’ve learned online games use udp instead of tcp but i don’t really understand why? I understand udp transmits packets faster which I can see being valuable in online games that are constantly updating, but no congestion or flow control or rdt seems like too big of a drawback in them too. Wouldn’t it be better to ensure every packet is accurate in competitive games for accuracy or is udp that much faster that it doesn’t matter? Also, would congestion and flow control help when servers experience a lot of traffic and help prevent lagging and crashing or would it just make it worse?


r/computerscience • • Jan 21 '20

Tom Scott - Why My Teenage Code Was Terrible: Sorting Algorithms and Big O Notation

Thumbnail
youtube.com
236 Upvotes

r/computerscience • • Feb 07 '26

Any-Angle Flow Field Algorithm for Navigation

Thumbnail
gallery
235 Upvotes

TL;DR - I've been working on this flow field navigation approach, and I wanted to share a bit of my work with you all.

If I misuse terminology or say something incorrect, please let me know so that I can correct the issue.

What Are Flow Fields?

If you aren't familiar with flow field pathfinding, flow fields (generally) works like this:

  • You have a uniform grid with "tiles" (traversable) and "walls" (non-traversable).

  • To compute the flow field, you iterate over every tile and store information in them.

  • To use the flow field, an agent uses data from the local tiles to determine a heading.

A simple example of this would be Dijkstra Maps; each tile stores its distance from the target, and agents move in the direction of the tile with the lowest cost.

One common issue of naive flow field algorithms is that they're limited to 8-direction instructions (the cardinal and ordinal headings). There are some approaches that create any-angle paths (e.g. Field D*), and I've been working on my own solution to this for the better part of two months.

What's The First Image Showing?

Barring the effects of GIF compression, you should be able to at least somewhat see my algorithm in action.

The color of each line represents the distance of the connection from the target. So, red lines are connected directly to the target, orange lines are connected to a point close to the target, yellow lines are connected to a point farther from the target, and so on and so forth.

As you can (hopefully) see, the algorithm spreads out from the target (the light blue box) and creates paths from every reachable point.

The Second & Third Image

The second image is showing off the order that the arrows move in. Basically, this entire system hinges on arrows with the least diagonal steps moving first. This guarantees that, when a diagonal arrows steps, the tiles to its back left, back right, and rear have all been connected.

The third image is an example of how the algorithm leverages that fact to create optimal connections. One simple rule you can implement is "if the back left and back right tile connect to the same point, then this tile can also connect to that point".

The algorithm uses rules like this (albeit a little more complex) to choose points to connect to. I'm not certain if you only need the back three tiles to create cover all cases, but I've been able to do a lot with just those three.

The Graph

The graph is a bit of benchmark data I collected from my algorithm and a naive version that only computes 8-directions.

Both lines are made of 1000 samples on randomly generated map layouts. As you can see, both of them scale linearly with the number of tiles they explore. My algorithm is a little more costly due to the extra computations it performs per-tile, but it doesn't exceed O(n) time complexity.

Conclusion

If you have any questions or need clarification, feel free to ask. Thanks for reading, and have a nice day.


r/computerscience • • Jul 19 '21

Advice How can I learn computer science at home?

235 Upvotes

The basics and bit of advanced.


r/computerscience • • Jun 08 '25

Discussion Do yall actually like programming?

232 Upvotes

Anytime I talk to someone online or in person about comp sci they just complain about it I’m I the only one who genuinely likes programming or I’m I just a masochist


r/computerscience • • Feb 16 '25

1bit half adder in dominoes

Post image
231 Upvotes

Made a 1bit half adder in dominoes. Left gate is a XOR gate between blue and orange for the sum and right gate is a an AND gate for carrying bit output.


r/computerscience • • Jan 22 '21

Good CS books that explain stuff clearly

230 Upvotes

I really enjoyed these books so far:

  • Code: The Hidden Language of Computer Hardware and Software: The author builds an imaginary computer from telegraph relays, chapter by chapter he explains everything clearly. Telegraph relays to logic gates to binary adders to RAM and a CPU and even a barebone assembly language. Very neat stuff!

  • Writing a Intepreter in Go and its sequel Writing a Compiler in Go: The author starts from scratch and explains every little part of making a programming language, from the lexer to the parser to the interpreter with a REPL. In the second book he codes a VM and compiles the language to bytecodes that run on the VM

These books are nice in that they're not heavy with literature and math like most textbooks, they explain stuff clearly step by step and I feel like I learned so much from them and I want more

Any suggestions?


r/computerscience • • Sep 02 '20

Laugh at my pain

230 Upvotes

Well I was dual booting Linux and windows, playing with Linux commands and my curiosity got the better of me.. thinking that the windows partition wasn’t mounted to mint’s filesystem I ran sudo rm / -r —no-preserve-root, it was kinda cool when everything started crashing, the terminal closed, the wallpaper disappeared, and the icons left when I clicked on them. The only things that were left was the void and a tiny white cursor.

When I grew tired of the ruins former OS, I discovered that not only had this powerful command recursively removed the home directory, but also the entire contents of my boot drive, the windows partitions and all.

A day of fighting with windows installation media and a pot of coffee later I’m back up and running, but this is definitely a lesson I’ll only learn once.

TLDR If you play with fire, it can burn your system down.


r/computerscience • • Feb 04 '26

Learning "pixel" positions in a visual field

229 Upvotes

Hi, I've been gnawing on this problem for a couple years and thought it would be fun to see if maybe other people are also interested in gnawing on it. The idea of doing this came from the thought that I don't think the positions of the "pixels" in our visual field are hard-coded, they are learned:

Take a video and treat each pixel position as a separate data stream (its RGB values over all frames). Now shuffle the positions of the pixels, without shuffling them over time. Think of plucking a pixel off of your screen and putting it somewhere else. Can you put them back without having seen the unshuffled video, or at least rearrange them close to the unshuffled version (rotated, flipped, a few pixels out of place)? I think this might be possible as long as the video is long, colorful, and widely varied because neighboring pixels in a video have similar color sequences over time. A pixel showing "blue, blue, red, green..." probably belongs next to another pixel with a similar pattern, not next to one showing "white, black, white, black...".

Right now I'm calling "neighbor dissonance" the metric to focus on, where it tells you how related one pixel's color over time is to its surrounding positions. You want the arrangement of pixel positions that minimizes neighbor dissonance. I'm not sure how to formalize that but that is the notion. I've found that the metric that seems to work the best that I've tried is taking the average of Euclidean distances of the surrounding pixel position time series.

The gif provided illustrates swapping pixel positions while preserving how the pixels change color over time. The idea is that you do random swaps many times until it looks like random noise, then you try and figure out where the pixels go again.

If anyone happens to know anything about this topic or similar research, maybe you could send it my way? Thank you


r/computerscience • • Apr 05 '23

I love discrete math, but why do I need this? When would you use this in the real world? Not saying it's useless, just curious.

Post image
227 Upvotes

r/computerscience • • Sep 01 '20

What are your "must read" book recommendations on Computer Science?

227 Upvotes

I'm looking for book recommendations, lately I've been reading "Grokking Algorithms (An Illustrated Guide for Programmers and Other Curious People)" which has been FENOMENAL!

So I'm looking for similar books. In case it matters, I'm a Front-End developer who's learning NodeJS and due to my job will have to transition to GraphQL


r/computerscience • • Sep 03 '18

queue some joke about and dsl lines and pings

Post image
227 Upvotes

r/computerscience • • Mar 17 '23

Prior to this morning, Bing's AI didn't know how to calculate modulo

Thumbnail
gallery
226 Upvotes

r/computerscience • • Sep 07 '20

The Missing Semester of Your CS Education

Thumbnail missing.csail.mit.edu
225 Upvotes

r/computerscience • • Jun 29 '19

Boeing's 737 Max Software Outsourced to $9-an-Hour Software Engineers

Thumbnail
bloomberg.com
224 Upvotes

r/computerscience • • Oct 14 '26

Help Is the best case here O(1)?

Post image
223 Upvotes

Hi, still new to algorithm analysis and need some help confirming my answer or not.

I assumed that best case would be O(1) in this scenario if size of the array is either 0 or 1. But trying to review my answer with online resources, it say's that O(1) doesn't count here?

What is the definite answer here?

EDIT: Hey everyone! Glad everyone got to interact and give responses. The answer was O(N) in the end! Confirmed with my professor.


r/computerscience • • Feb 26 '24

General What are your interests outside of Computer Science?

223 Upvotes

I've taken the holland career code quiz and am wondering if people really have relatively stable interest types. I'm asking on this forum and I'll ask on other professional forums and compare. I can come back and tell you what I got from others or you can click on my name to find my posts. What hobbies do you guys have? What do you do in your spare time? What topics do you like to read about when you can read about anything you want, like with magazines? What informational stuff do you watch on youtube and tv? Do you think it is different for people in different types of professions?


r/computerscience • • Apr 15 '22

Discussion How can Spotify’s search by lyrics feature be so ridiculously fast?

222 Upvotes

Spotify offers a feature where you can search for a song writing the song’s lyrics in the search field. Spotify’s servers answer your query in a matter of seconds, if not milliseconds.

Now, my question is: from an algorithmic point of view, how can that be even remotely possible? I kind of understand how that would work when you are searching for a song title (a very efficient search algorithm operating on pre-sorted data on a server with a lot of computational power), but how can that work when looking for something like lyrics, where what you input is just enough words to make the result unique?

(Of course, the Spotify example is just an example, and I’m sure lots of services offer similar and even more impressing features.)

Thanks to anyone who will take the time to answer my question :)


r/computerscience • • Jan 20 '21

If I brought an iPhone to 1946, how long would it take for the scientists to figure it out?

222 Upvotes

Just a hypothetical question came to my mind.

  • 1946, when the first computer ENIAC was completed.

  • assuming all the scientists in the world work together to figure it out without any other future technologies.

  • instead of asking how long would it be asking how do they start and what is their process are more realistic.


r/computerscience • • Apr 15 '18

I love computer science. I hate my fellow computer science classmates.

222 Upvotes

I need to get this off my chest, so please read my entire post instead of downvoting me based on my arrogant title.

I am a computer science undergrad myself. I've always been fascinated with computers and the Internet ever since I was young. I simply cannot see myself working outside of this area - the incredible space for innovation and the power of exponential technologies is, to me, simply the most exciting thing I can think of. I constantly read about future technologies (shoutout to /r/Futurology) and find it disappointing that not many people share this admiration of mine, especially in this fantastic time period in which we live.

I could spend hours talking about why I chose to study computer science, but I'll leave that for some other time. I need to talk about why I dislike my peers.

I am definitely an introvert, but in my class of initially 50 people* I was probably the most outgoing. I haven't made many friends in college, which truly made me sad in the beginning because I could see myself making more (and better) friends if I were to study pretty much anything else. The only thing that me and 90% of my classmates have in common is that we, for different reasons, chose to study CS. Most of these people are your typical anime-loving gamers, which is of no interest to me. Most of them plan on focusing on game development, which is fine, but they simply don't have an open mind for other ideas an technologies. They play games and want to make games, as if that is even a realistic scenario.

I don't even need to mention most of them are awkward as hell. This is no reason for me to dislike any of them, but it definitely makes it more difficult for me to bond with them. I have one good friend who shares common interests with me and doesn't act awkward at all. My other friends are nice people and (sometimes) good to hang out with, but they are definitely weird. I almost forgot to mention there is only one girl in my class, which really disappoints me, but I can't say I don't comprehend.

I feel like we need more people in CS who are also interested in the arts and humanities, as I see this as an important trait for understanding the power of the technologies we deal with. As Steve Jobs said it, "Edwin Land of Polaroid talked about the intersection of the humanities and science, I like that intersection. There’s something magical about that place."

I think it is important to note that I am from Rio de Janeiro, Brazil, and this is based on my point of view, I don't want to generalize CS students. I guess in a more developed country more people would be interested and open to the possibility of studying CS, and therefore providing more diversity among students. And that is exactly what I would like to see.

I hope I haven't offended any readers in any way with my personal thoughts. I'm just very passionate about technology and can't seem to get the same vibe from the people I deal with on a daily basis.

*I would say 50% of the people who started college with me already quit. Every semester some people leave, and we only had 2 (TWO) people graduating in CS last semester. But CS is hard, nothing new here.


r/computerscience • • Oct 08 '25

Why do so many '80s and '90s programmers seem like legends? What made them so good?

221 Upvotes

I’ve been thinking a lot lately about how the early generations of programmers—especially from the 1980s and 1990s—built so many foundational systems that we still depend on today. Operating systems, protocols, programming languages, databases—much of it originated or matured during that era.

So my questions are:

What did they actually learn back then that made them capable of such deep work?

Was it just "computer science basics" or something more?

Did having fewer abstractions make them better engineers because they had to understand everything from the metal up?

Is today's developer culture too reliant on tools and frameworks, while they built things from scratch?

I'm genuinely curious—did the limitations of the time force them to think differently, or are we missing something in how we approach learning today?

Would love to hear from people who were around back then or who study that era. What was the mindset like? How did you learn OS design, networking, or programming when the internet wasn’t full of tutorials?

Let’s talk about it.


r/computerscience • • Jun 25 '24

Advice Program for Counting Holes

Post image
221 Upvotes

Okay. I just landed a job with an ecology department at my school, and my advisor wants me to set up some way to automatically count all the crab burrows (the holes) in photographs. I have never taken a computer science class and am not very good at this. I have no idea if this is even the right place to post this.

I’ve tried ImageJ, eCognition, and dabbled a little with python but to no avail. I feel so incredibly frustrated and can’t get any programs to properly count the holes. If anyone has suggestions or advice PLEASE lmk 😭😭😭