Oct 23, 2015

Задача византийских генералов

Википедия: Задача византийских генералов

g1 g2 g3 g4
(1,2,x,4) (1,2,x,4) (1,2,x,4) (1,2,x,4)
(1,2,y,4) (1,2,y,4) (1,2,y,4) (1,2,y,4)
(a,b,c,d) (e,f,g,h) (1,2,3,4) (i,j,k,l)
(1,2,z,4) (1,2,z,4) (1,2,z,4) (1,2,z,4)

Aug 19, 2015

“Маркетолог спрашивает программиста: в чём сложность поддержки большого проекта?
Программист: ну представь, что ты писатель и поддерживаешь проект “Война и мир”. У тебя ТЗ — написать главу как Наташа Ростова гуляла под дождём по парку. Ты пишешь “шёл дождь”, сохраняешь, вылетает сообщение об ошибке “Наташа Ростова умерла, продолжение невозможно”. Почему умерла? Начинаешь разбираться. Выясняется, что у Пьера Безухова скользкие туфли, он упал, его пистолет ударился о землю и выстрелил в столб, а пуля от столба срикошетила в Наташу. Что делать? Зарядить пистолет холостыми? Поменять туфли? Решили убрать столб. Получаем сообщение “Поручик Ржевский умер.” Выясняется, что он в следующей главе облокачивается о столб, которого уже нет..”

Jun 22, 2015

Jun 8, 2015

Parallel Programming

Amdahl's law
The speedup of a program using multiple processors in parallel computing is limited by the time needed for the sequential fraction of the program. For example, if a program needs 20 hours using a single processor core, and a particular portion of the program which takes one hour to execute cannot be parallelized, while the remaining 19 hours (95%) of execution time can be parallelized, then regardless of how many processors are devoted to a parallelized execution of this program, the minimum execution time cannot be less than that critical one hour. Hence the speedup is limited to at most 20×.

Gustafson–Barsis' law
Says that computations involving arbitrarily large data sets can be efficiently parallelized.

May 21, 2015

May 13, 2015

May 5, 2015

У скольких целых чисел, лежащих в диапазоне от 1 до 1000, есть цифра 3?

Сначала узнаем, сколько чисел не имеют 3 в своей записи. Для этого на каждое место ставим 9 цифр, не включающие 3 т.е. 9 * 9 * 9 = 729. Если всего чисел 1000, то ответ 1000 – 729 = 271.

http://tproger.ru/problems/count-digit-3-in-numbers-from-1-to-1000/

Apr 28, 2015

Mar 17, 2015

Mar 5, 2015

Feb 24, 2015

Everybody is a genius. But if you judge a fish by its ability to climb a tree, it will live its whole life believing that it is stupid. 

Albert Einstein

Feb 11, 2015

Feb 9, 2015

If Carpenters Were Hired Like Programmers

Interviewer: So, you're a carpenter, are you?Carpenter: That's right, that's what I do.

Interviewer: How long have you been doing it?
Carpenter: Ten years.

Interviewer: Great, that's good. Now, I have a few technical questions to ask you to see if you're a fit for our team. OK?
Carpenter: Sure, that'd be fine.

Interviewer: First of all, we're working in a subdivision building a lot of brown houses. Have you built a lot of brown houses before?
Carpenter: Well, I'm a carpenter, so I build houses, and people pretty much paint them the way they want.

Interviewer: Yes, I understand that, but can you give me an idea of how much experience you have with brown? Roughly.
Carpenter: Gosh, I really don't know. Once they're built I don't care what color they get painted. Maybe six months?

Interviewer: Six months? Well, we were looking for someone with a lot more brown experience, but let me ask you some more questions.
Carpenter: Well, OK, but paint is paint, you know.

Interviewer: Yes, well. What about walnut?
Carpenter: What about it?

Interviewer: Have you worked much with walnut?
Carpenter: Sure, walnut, pine, oak, mahogony -- you name it.

Interviewer: But how many years of walnut do you have?
Carpenter: Gosh, I really don't know -- was I supposed to be counting the walnut?

Interviewer: Well, estimate for me.
Carpenter: OK, I'd say I have a year and a half of walnut.

Interviewer: Would you say you're an entry level walnut guy or a walnut guru?
Carpenter: A walnut guru? What's a walnut guru? Sure, I've used walnut.

Interviewer: But you're not a walnut guru?
Carpenter: Well, I'm a carpenter, so I've worked with all kinds of wood, you know, and there are some differences, but I think if you're a good carpenter ...

Interviewer: Yes, yes, but we're using Walnut, is that OK?
Carpenter: Walnut is fine! Whatever you want. I'm a carpenter.

Interviewer: What about black walnut?
Carpenter: What about it?

Interviewer: Well we've had some walnut carpenters in here, but come to find out they weren't black walnut carpenters. Do you have black walnut experience?
Carpenter: Sure, a little. It'd be good to have more for my resume, I suppose.

Interviewer: OK. Hang on let me check off the box...
Carpenter: Go right ahead.

Interviewer: OK, one more thing for today. We're using Rock 5.1 to bang nails with. Have you used Rock 5.1?
Carpenter: [Turning white...] Well, I know a lot of carpenters are starting to use rocks to bang nails with since Craftsman bought a quarry, but you know, to be honest I've had more luck with my nailgun. Or a hammer, for that matter. I find I hit my fingers too much with the rock, and my other hand hurts because the rock is so big.

Interviewer: But other companies are using rocks. Are you saying rocks don't work?
Carpenter: No, I'm not saying rocks don't work, exactly, it's just that I think nail guns work better.

Interviewer: Well, our architects have all started using rocks, and they like it.
Carpenter: Well, sure they do, but I bang nails all day, and -- well, look, I need the work, so I'm definitely willing to use rocks if you want. I try to keep an open mind.

Interviewer: OK, well we have a few other candidates we're looking at, so we'll let you know.
Carpenter: Well, thanks for your time. I enjoyed meeting you.

NEXT DAY:

Ring...

Interviewer: Hello?
Carpenter: Hello. Remember me, I'm the carpenter you interviewed for the black walnut job. Just wanted to touch base to see if you've made a decision.

Interviewer: Actually, we have. We liked your experience overall, but we decided to go with someone who has done a lot of work with brown.
Carpenter: Really, is that it? So I lost the job because I didn't have enough brown?

Interviewer: Well, it was partly that, but partly we got the other fellow a lot cheaper.
Carpenter: Really -- how much experience does he have?

Interviewer: Well, he's not really a carpenter, he's a car salesman -- but he's sold a lot of brown cars and he's worked with walnut interiors.
Carpenter: [click]

http://www.jasonbock.net/jb/News/Item/7c334037d1a9437d9fa6506e2f35eaac

Jan 21, 2015