News for hackers. Stuff that matters.

Ask HN: How have you applied computer science IRL?

Sooo... I just got done putting away a load of laundry and realized I've applied efficiency techniques to the process. I first sorted the clothing types into buckets (piles IRL) then performed type-specific processing on each of the buckets, reducing as much as possible my disk I/O (turning around and taking a couple steps to put the clothes in the drawer/on the rack IRL).

How have you changed some process in your life based on computer science algorithms or principles?

( 38 comments | 30 points | on HN )
Re:Ask HN: How have you applied computer science IRL? by jcsalterego on Thursday October 28, 2010 @01:43AM (#1841900)
I don't know about you guys but when I go grab dinner with my philosophical-type friends, we all share a fork and knife.
Re:Ask HN: How have you applied computer science IRL? by itsnotvalid on Thursday October 28, 2010 @04:23AM (#1842181)
That sounds like a problem where computer science techniques must be applied to solve. Lucily there aren't just forks.
Re:Ask HN: How have you applied computer science IRL? by ericHosick on Thursday October 28, 2010 @06:30AM (#1842401)
Any one of your friends starve?
Re:Ask HN: How have you applied computer science IRL? by nl on Thursday October 28, 2010 @01:50AM (#1841916)
Sure.. exponential back-off for trying to get my son to sleep at night. Didn't work.

Mark & Sweep Garbage Collection for my desk. Commonly used stuff stays on the top, and then I periodically pause for garbage collection where I drop the lower layers into a draw. Occasionally I do survivor generation compaction, too.

When doing washing, I always build an index by hanging it out in order, so then putting it away can utilize the index (in English - I put pairs of socks together when I hang them out, so when I bring them in they are already paired)

Re:Ask HN: How have you applied computer science IRL? by corin_ on Thursday October 28, 2010 @02:27AM (#1841975)
I was trying to spot my friend in a crowded room so I did a regexp visual search for people with brown hair.

I was feeling pretty tired last night so I decided to put myself into sleep mode.

I'm now too ashamed of myself to make up a third.

Re:Ask HN: How have you applied computer science IRL? by pavel_lishin on Thursday October 28, 2010 @12:48PM (#1843646)
I usually grep for socks.
Re:Ask HN: How have you applied computer science IRL? by alanthonyc on Thursday October 28, 2010 @01:53AM (#1841923)
I use binary search all the time for practical problems.
Re:Ask HN: How have you applied computer science IRL? by stakent on Thursday October 28, 2010 @02:28AM (#1841976)
For example fault localisation in control systems.

At least when there is some documentation and one can deduce the signal path in the system.

Re:Ask HN: How have you applied computer science IRL? by yogsototh on Thursday October 28, 2010 @04:29AM (#1842192)
I count to 31 with one hand.

I use the standard count up to 5 with one hand just for communication purpose.

Re:Ask HN: How have you applied computer science IRL? by eqdw on Thursday October 28, 2010 @12:10PM (#1843457)
I use base six, with one hand being 6s and one hand being 1s. It's a tradeoff between counting capacity and ease of calculation.
Re:Ask HN: How have you applied computer science IRL? by RiderOfGiraffes on Thursday October 28, 2010 @05:50AM (#1842340)
I used to do that, but found some of the various combinations too difficult to maintain. I tend to count to 10 on each hand, counting the thumb as five and a fist as ten.
Re:Ask HN: How have you applied computer science IRL? by mzl on Thursday October 28, 2010 @08:45AM (#1842627)
Slightly more efficient, and still easy to do, is to use one hand for 0-9 (thumb counts as five), and the other for 0,10,20,...,90. Easy counting, setting, and reading of the current number.
Re:Ask HN: How have you applied computer science IRL? by RiderOfGiraffes on Thursday October 28, 2010 @08:56AM (#1842663)
Er, that's exactly what I meant. Sorry if I didn't make it clear, but I never considered that someone would believe I counted to 10 on one hand, then another 10 on the other.
Re:Ask HN: How have you applied computer science IRL? by chad_oliver on Thursday October 28, 2010 @05:42AM (#1842326)
how? I can understand 12 (use your thumb to count the 3 joints on each of your 4 fingers), but 31?
Re:Ask HN: How have you applied computer science IRL? by RiderOfGiraffes on Thursday October 28, 2010 @05:49AM (#1842335)
Binary. Five (biological) digits giving 5 bits.

So color me confused - your profile says:

  > I love hardware hacking
  > and low-level programming.
How can you not see 31 and think "5 bits" ?
Re:Ask HN: How have you applied computer science IRL? by chad_oliver on Thursday October 28, 2010 @09:03PM (#1845633)
That's a cool solution!

In answer to your question: because I'm still learning. I'm in my first year at university, and while I love working with microcontrollers, a lot of the knowledge hasn't quite got there. I'm working on it!

Also, I forgot about starting at zero (yeah, I know).

Re:Ask HN: How have you applied computer science IRL? by edanm on Thursday October 28, 2010 @03:35AM (#1842092)
I usually don't post comics, but this fits too well:

http://xkcd.com/287/

That's what I use my CS degree for :)

Re:Ask HN: How have you applied computer science IRL? by dackmilliken on Thursday October 28, 2010 @02:02AM (#1841936)
I work in retail atm and use algorithms a lot (in my head at least).

E.g.: to stock beer we have a big pile with myriad brands. To make it easier to stock I stack it to where each type is easily accessible. Maybe analogous to certain heap paradigms... .

I also think about how I can reduce touching of the actual product (unload truck -> floor, as opposed to unload truck -> belt -> stock -> floor).

Basically being lazy and trying to make my life more efficient/easier leads me to utilize algorithms.

Re:Ask HN: How have you applied computer science IRL? by teach on Thursday October 28, 2010 @04:23AM (#1842179)
I'm a musician, and have a folder full of songs in my repertoire. I used to strictly alphabetize, but now I use dividers lettered A-Z (hash table), with each letter organized alpha at first, but move-to-front whenever I perform a song (MRU). I can now often find the song I want in 1 or 2 lookups, which really beats binary search.
Re:Ask HN: How have you applied computer science IRL? by stakent on Thursday October 28, 2010 @02:35AM (#1841989)
Sorting room full of dated reports from several dozens of years.

First pass: put raports in the bins year by year maintaining sort order in the bins. Binary search used to place new report in the bin.

Second pass: put year by year sorted reports in the correct order on the shelfs.

I don't remeber the name of the algorithm used and the book from which it come was given to the library.

Re:Ask HN: How have you applied computer science IRL? by Natsu on Thursday October 28, 2010 @05:08AM (#1842261)
That's radix sort.

For what it's worth, I often have piles of sorted documents to sort together, so I've used merge sort on RL objects fairly regularly. Binary search, too, though I use the optimization where it's not strictly binary when I have a guess about where the item should be.

I've probably used a few other algorithms, but I can't think of any off the top of my head.

Re:Ask HN: How have you applied computer science IRL? by pronoiac on Thursday October 28, 2010 @02:49AM (#1842007)
I'd break the first pass down further, putting items into the (yearly) bins without sorting within each bin, freeing up bins, then subdividing them into smaller piles (say, by month), then sorting those.

This insight is courtesy of a sorting algorithm that's optimal for systems with very limited memory but multiple tape systems, if I remember correctly. Also IIRC insertion sort can beat doing the binary sort in situations of 7-20 or so? Much over a dozen, I can't use my fingers of one hand as bookmarks to do, say, three comparisons to find the right place, & I'd rather break it down into more piles.

Re:Ask HN: How have you applied computer science IRL? by allenp on Thursday October 28, 2010 @09:19AM (#1842726)
Also if you just put them into bins by year, you could have others do the sorting per bin - so more of a distributed model.
Re:Ask HN: How have you applied computer science IRL? by bayareaguy on Thursday October 28, 2010 @05:55AM (#1842352)
I try never to use more than 70% of my available space or other resources.

If asked to do something, I usually give a promise that I'll do whatever asked but generally defer the actual work until forced.

I always follow the tit-for-tat strategy whenever dealing with anyone.

I make a point of including redundant details in all communications so that others can catch my errors.

Re:Ask HN: How have you applied computer science IRL? by dasil003 on Thursday October 28, 2010 @03:19AM (#1842060)
The quiet satisfaction of knowing that dynamic programming is something much cooler than Ruby.
Re:Ask HN: How have you applied computer science IRL? by mulletcat on Thursday October 28, 2010 @04:18AM (#1842167)
My friends and I figured out that the counter showing beer consumption at a restaurant with a beer tap on each table wouldn't increase if we poured an amount smaller than the smallest amount necessary to increment the counter. Many glasses of beer were had by pouring tiny amounts repeatedly.
Re:Ask HN: How have you applied computer science IRL? by anrope on Thursday October 28, 2010 @01:23AM (#1841851)
I have a specific schedule that I follow when starting different parts of dinner to make sure that everything is done at the same time, including adjustments for different pots that I know cook differently. I suppose you could think of this as some sort of scheduling algorithm.
Re:Ask HN: How have you applied computer science IRL? by Travis on Thursday October 28, 2010 @12:37PM (#1843590)
I use graph algorithms when I'm walking somewhere downtown. With the shortest path defined by lights that are green / red. Sometimes I'll switch it up a bit and use a different search algorithm just for variety.
Re:Ask HN: How have you applied computer science IRL? by klochner on Thursday October 28, 2010 @03:00AM (#1842023)
Re:Ask HN: How have you applied computer science IRL? by adamcharnock on Thursday October 28, 2010 @06:49AM (#1842430)
I realised that throwing more of my time at a task is an O(n) solution to the problem of not having enough time. There must be a better way...
Re:Ask HN: How have you applied computer science IRL? by _b8r0 on Thursday October 28, 2010 @03:26AM (#1842078)
I use the nearest neighbour algorithm to solve the travelling salesman problem, when travelling to sales meetings.

I'm going to shower now. I feel dirty.

Re:Ask HN: How have you applied computer science IRL? by eqdw on Thursday October 28, 2010 @12:09PM (#1843449)
I've used resource allocation and scheduling quite a bit. It's amazing how much of Operating Systems bleeds over into the real world
Re:Ask HN: How have you applied computer science IRL? by chewbranca on Thursday October 28, 2010 @02:14AM (#1841961)
The concept of job scheduling algorithms made me much more conscious about the order of approaching things in my day to day life.
Re:Ask HN: How have you applied computer science IRL? by itsnotvalid on Thursday October 28, 2010 @04:24AM (#1842182)
I remembered sorting out stuff by asking a few classmates to sort some of it individually and then combine them.
Re:Ask HN: How have you applied computer science IRL? by binarymax on Thursday October 28, 2010 @05:53AM (#1842344)
Was playing 9ball last night, used a quicksort to rack them in order.
Re:Ask HN: How have you applied computer science IRL? by JoeAltmaier on Thursday October 28, 2010 @09:40AM (#1842805)
I park first-fit; my wife parks best-fit. We drive each other crazy.
Re:Ask HN: How have you applied computer science IRL? by cloudwalking on Thursday October 28, 2010 @03:50AM (#1842112)
Quicksort is great when you have to sort people by birthday.
Re:Ask HN: How have you applied computer science IRL? by bockris on Thursday October 28, 2010 @09:39AM (#1842795)