« first day    last day (893 days later) » 

12:08 AM
@sehe Hey! Just because Java has a Garbage Collector does not mean you can shove your garbage in this room ;-)
 
12:30 AM
:) I can't?
 
 
3 hours later…
3:51 AM
Ohaider
So... are we looking at an empty room?
 
 
19 hours later…
user142019
10:30 PM
Hello!
 
Do you think this question is too hard:
 
user142019
@FredOverflow Change the colon to a question mark, then no.
 
Fill in the blanks: "Ranges are defined by two iterators. One of them points _____ the first element, and the other points _____ the last."
 
user142019
"to" and "to one position after"?
 
You would have nailed it :)
 
user142019
10:32 PM
Are students supposed to know that?
 
user142019
If yes, then I think it’s not a bad question.
 
Yes, they have been working with iterators for about half of the semester.
If they don't know that, I'm gonna shoot myself in the foot. With C++.
 
user142019
I’d say it’s a good question then. It’s quite fundamental to "end".
 
user142019
@FredOverflow you’ll blow off your whole leg.
 
So what, I got two :)
Okay, let me browse for another candidate...
 
user142019
10:33 PM
UB—maybe the other one disappears too.
 
Simplify the following expression: to_be || !to_be
 
user142019
Type of to_be?
 
Nothing fancy, they don't know it can be overloaded :)
 
user142019
If it’s just a bool, the answer is true.
 
Correct. Let me fetch my vanilla tea.
 
user142019
10:35 PM
No wait
 
user142019
the answer can also be 42 depending on context.
 
user142019
:D
 
It's a pure C++ question :)
 
user142019
Pure C++?
 
user142019
I mean that 42 may be implicitly cast to true in some situations.
 
10:37 PM
I kept them shielded from most of the strange implicit casts.
 
user142019
++fred.score :P
 
I didn't even tell them that "hello" was actually not of type std::string :)
 
user142019
lol :P
 
I didn't even tell them about stupid postfix ++. Makes it easy to spot when somebody does copy/paste from some solution on the Internet :)
 
user142019
heh
 
user142019
10:38 PM
Our code base from school inconsistently uses pre- and postfix ++.
 
user142019
It’s because all the noobs use postfix ++ and I use prefix ++. xD
 
user142019
Teachers never explained the difference, though. And I don’t know whether it’s mentioned in the book since, well… guess what.
 
Do you know what the stupidest reason I ever heard for using postfix increment was?
 
user142019
Performance-related crap?
 
"It's more object-oriented."
 
user142019
10:39 PM
lolwatthefuck
 
You know, first the object, then the method :)
 
user142019
Oh. xd
 
user142019
I want operator<- in C++.
 
I'm pissing myself right now, it's such a stupid "reason".
 
user142019
themember<-thepointer :)
 
10:41 PM
Anyway, simplify this: !money && !life
 
user142019
true
 
LOL
seriously considering to accept that as a potential answer :)
But seriously, can you simplify it?
 
user142019
!(money || life)
 
correct
 
user142019
Don’t know whether it’d be "simpler" though.
 
user142019
10:42 PM
Define "simplify".
 
It's one less operator.
 
user142019
I consider () an operator!
 
The less operators, the better.
But it doesn't do anything besides grouping.
 
user142019
Okay. :P
 
Okay, let me redefine: the less operations the better.
 
user142019
10:43 PM
Do you make bonus questions?
 
No, but I give bonus points for very smart answers.
 
user142019
ah nice :P
 
user142019
That’s good. Stimulating.
 
For example, if somebody knows that "hello" is actually const char[6] or something.
 
user142019
litb should make these exams.
 
user142019
10:44 PM
Students would get crazy.
 
Everybody would fail with 0 points. Or maybe even less than that.
 
user142019
xd
 
How often does the body of this loop run? for (int i = 0; i == 10; ++i) { /* ... */ }
 
user142019
Never!
 
Can you express that as a number? :)
 
user142019
10:46 PM
The first comparison already fails since 0 != 10, so zero times.
 
user142019
UNLESS
 
zero is correct.
 
user142019
You jump into it using a goto. :D
 
LOL
Can you jump over int i = 0?
 
user142019
I guess you can’t in C++. :<
 
user142019
10:47 PM
However, consider C.
 
Right, that would work.
Unfortunately, I haven't taught my students goto ;)
 
user142019
int i = 5;
goto foo;

for (i = 0; i < 10; ++i) {
    foo:;
}
 
user142019
How often would this body run?
 
user142019
Does the goto really enter the loop?
 
I think it will run 5 times. Not sure though. Test it on ideone or something if you're curious.
Are you ready for one more question?
 
user142019
@FredOverflow Sure.
 
std::vector<int> numbers;
numbers.push_back(97);
numbers.push_back(42);
auto x = numbers.end() - numbers.begin();
What is the value of x?
 
user142019
2.
 
correct!
type? ;)
 
user142019
I prefer std::distance.
 
user142019
10:50 PM
@FredOverflow decltype(numbers.end() - numbers.begin())
 
I think it's ptrdiff_t.
bool operator_____(foo a, foo b)
{
    return !(b < a);
}
What operator is implemented here?
 
user142019
operator>=
 
There is no such thing.
 
user142019
ugh brainfart
 
user142019
I was confused, I typed that initially but thought "no that’s a half-arsed bind operator". :|
 
10:52 PM
Okay, that's an existing operator, but it's wrong :)
 
user142019
huh?
 
user142019
Okay okay. operator!< xd okay I give up.
 
user142019
OHH
 
user142019
operator<=
 
correct
I love this one.
 
user142019
10:53 PM
FRED Y U SWAP a AND b YOU'RE SO MEAN :'(
 
user142019
(I’d kill my colleagues if they did this in real code.)
 
Because that's the idiomatic way to overload operator<=, it's not my fault!
 
user142019
wat
 
user142019
T_T
 
How would you do it?
 
user142019
10:54 PM
return a.x <= b.x; assuming you want to compare foo::x.
 
No no no, you overload operator< for real, and then you delegate the work from the other operators to operator<. Else you get logic duplication.
 
user142019
But at least it’s readable to me. :)
 
Or even better, just overload operator< and inherit from boost::operators<foo>, then it generates the magic in the background.
But my students don't know what "boost" is :)
 
user142019
Heh. Standard library has that too. I think.
 
It's called rel_ops. It sucks, and it doesn't work in practice.
 
user142019
10:56 PM
Oh. xD
 
Hm, I guess that's all for "interesting" questions, the rest is just lame stuff like "implement swap" or "What's the complexity of algorithm xy".
 
user142019
Complexity you say?
 
user142019
I never done things like determining complexity of algos.
 
You cannot talk about algorithms and not discuss complexity :)
 
user142019
All I know is that I invent a lot of overly complex algorithms. :)
 
10:58 PM
Do they work? :)
 
user142019
Yup. :P
 
On real data sets, do they terminate before the Universe terminates? :)
 
user142019
Although I did once write a very efficient function to get the closest match to a sequence from a list of sequences, comparing the Levenshtein distance.
 
user142019
@FredOverflow the latter. :P
 
user142019
It was based around the assumption that if you have three sequences A, B and C, and 2 * |A| <= |B|, and |A| >= |C|, then the Levenshtein distance between A and C would always be equal to or smaller than the Levenshtein distance between A and B.
 
user142019
11:00 PM
(IIRC. :P)
 
user142019
Where |X| is length of sequence X.
 
user142019
If the strings you have to match have very different lengths, this can be quite efficient since you can basically skip half of the strings except when no match was found.
 
Fuck it's Midnight already?!?
 
user142019
No, that was three minutes and twenty seconds ago.
 
OMG I <3 THIS ROOM
I'm going to link to it everytime a Java fanboy asks "Y U C# HATE JAVA?"
 
11:08 PM
@CCInc It was actually very simple to create this room. The system asked me if I'm sure I didn't want the "Java room" or the "S room" (whatever that is...) and BANG there it was.
We don't talk that much about why Java sucks, though. So don't get your hopes up.
 
Aww.
 
But nobody's stopping you, of course!
 

« first day    last day (893 days later) »