Sign In
Fabulous Adventures In Coding
Eric Lippert's Blog
Tags
Aargh! (8)
accuracy (6)
Arrays (8)
ASP (11)
AStar (5)
Async (15)
bad jokes (14)
Begging the question (4)
Benford's Law (3)
Best Of FAIC (12)
Big Words (5)
Books (23)
Breaking Changes (24)
Brittle Base Classes (6)
C# (327)
C# 4.0 (39)
C# 5.0 (10)
Cargo Cult Programming (4)
cast operator (3)
Channel 9 (6)
Charts (6)
closures (3)
Code Generation (10)
Code Quality (29)
COM Programming (57)
Conditional Operator (3)
Continuation Passing Style (11)
Conversions (16)
Covariance and Contravariance (22)
customer service (4)
declaration spaces (5)
definite assignment (3)
Dialogue (14)
English Usage (11)
exception handling (9)
Floating Point Arithmetic (15)
grammars (9)
graph colouring (5)
GUIDs (4)
Hashing (9)
High Dimensional Spaces (5)
Immutability (27)
integer arithmetic (5)
Interviewing (8)
Introduction (6)
It Hurts When I Do This (5)
Iterators (10)
JScript (93)
JScript .NET (29)
keywords (4)
Lambda Expressions (20)
Language Design (62)
local variables (3)
localization (3)
Mathematics (18)
Memory Management (13)
Metablogging (9)
Mistakes (6)
Music (6)
myths (7)
namespaces (5)
Non-computer (37)
Optional arguments (5)
Overload Resolution (9)
Pages (25)
Performance (48)
precedence (4)
precision (7)
protected (7)
Puzzles (49)
quotable quotations (4)
Rants (51)
Rarefied Heights (52)
reachability (4)
Recursion (26)
reference (4)
Regular Expressions (13)
Relationships (4)
Salt (4)
Science (12)
scope (5)
Scripting (189)
Security (47)
shadowcasting (6)
SimpleScript (30)
Software development methodology (13)
Static Methods (6)
Threading (18)
Topological Sort (4)
Type Inference (18)
type safety (4)
unsafe code (4)
Value Types (11)
VBScript (80)
Video (12)
virtual dispatch (9)
VSTO (10)
warnings (5)
What's The Difference? (11)
Zombies (4)
Browse by Tags
MSDN Blogs
>
Fabulous Adventures In Coding
>
All Tags
>
puzzles
Tagged Content List
Blog Post:
A brief digression
Eric Lippert
Before we continue our exploration of truthiness in C#, a brief digression. I mentioned last time the "knights and knaves" puzzles of logician Raymond Smullyan. Though I do enjoy those puzzles, my favourite of his puzzles are his chess puzzles, and my second favourite are his combinatory logic puzzles...
on
17 Apr 2012
Blog Post:
The Solution To The Simple Puzzle
Eric Lippert
The first time I ran my histogram visualizer I asked for a Cauchy distribution with a minimum of -10 and a maximum of 10, and of course I got a graph that looks much like the one from my article of last week: Looks perfectly reasonable; I guess my program is correct right out of the gate, because I am...
on
27 Feb 2012
Blog Post:
A Simple Puzzle
Eric Lippert
My original version of the histogram-generating code that I whipped up for the previous episode of FAIC contained a subtle bug. Can you spot it without going back and reading the corrected code? private static int[] CreateHistogram(IEnumerable<double> data, int buckets, double min, double max)...
on
24 Feb 2012
Blog Post:
The curious property revealed
Eric Lippert
Today is the fifteenth anniversary of my first day of full time work here at Microsoft. Hard to believe it has been a decade and a half of writing developer tools. I am tremendously fortunate to be able to work with such a great team on such a great toolset for such great customers. I'm looking forward...
on
15 Jul 2011
Blog Post:
What curious property does this string have?
Eric Lippert
There are all kinds of interesting things in the Unicode standard. For example, the block of characters from U+A000 to U+A48F is for representing syllables in the "Yi script". Apparently it is a Chinese language writing system developed during the Tang Dynasty. A string drawn from this block has an...
on
12 Jul 2011
Blog Post:
To box or not to box, that is the question
Eric Lippert
Suppose you have an immutable value type that is also disposable. Perhaps it represents some sort of handle. struct MyHandle : IDisposable { public MyHandle(int handle) : this() { this.Handle = handle; } public int Handle { get; private set; } public void Dispose() { Somehow.Close(this.Handle);...
on
14 Mar 2011
Blog Post:
Spoiler Alert
Eric Lippert
The remaining video of the talk with Neal Gafter and me at NDC is up on the streaming content server now, here . However, spoiler alert: if you don't want to know the solutions to the eight puzzles we present, don't watch the video. Of course, long time readers of this blog have probably seen about...
on
8 Jul 2010
Blog Post:
Murky Research
Eric Lippert
No computers today, but some interesting - and important - math. (And, happy Canada Day, Canadians!) " Car Talk " is a popular weekly phone-in program that has been on National Public Radio for several decades now, in which Bostonian brothers Tom and Ray crack wise and diagnose car (and relationship...
on
1 Jul 2010
Blog Post:
Always write a spec, part one
Eric Lippert
Joel had a great series of articles many years ago about the benefits of writing functional specifications , that is, specifications of how the product looks to its users. I want to talk a bit about technical specifications, that is, a specification of how something actually works behind the scenes....
on
19 Nov 2009
Blog Post:
Simple names are not so simple, Part Two, plus, volcanoes and fried foods
Eric Lippert
I've returned from a brief vacation, visiting friends on the island of Maui. I'd never been to that part of the world before. Turns out, it's a small island in the middle of the Pacific Ocean, entirely made out of volcanoes. Weird! But delightful. The most impressive thing about the Hawaiian Islands...
on
5 Nov 2009
Blog Post:
Simple names are not so simple
Eric Lippert
C# has many rules that are designed to prevent some common sources of bugs and encourage good programming practices. So many, in fact, that it is often quite confusing to sort out exactly which rule has been violated. I thought I might spend some time talking about what the different rules are. We'll...
on
2 Nov 2009
Blog Post:
Color Color
Eric Lippert
Pop quiz: What does the following code do when compiled and run? class C { public static void M(string x) { System.Console.WriteLine("static M(string)"); } public void M(object s) { System.Console.WriteLine("M(object)"); } } class Program { static void Main() { C c = new C(); c.M("hello"); } } ...
on
6 Jul 2009
Blog Post:
What Would Tufte Do?
Eric Lippert
What is this a chart of? I'll post the answer tomorrow. UPDATE: Someone has already correctly deduced the answer. (And man, that was fast!) So don't read the comments if you don't want spoilers.
on
27 May 2009
Blog Post:
Comma Quibbling
Eric Lippert
[UPDATE: Holy goodness. Apparently this was a more popular pasttime than I anticipated. There's like a hundred solutions in there. Who knew there were that many ways to stick commas in a string? It will take me some time to go through them all, so don't be surprised if it's a couple of weeks until I...
on
15 Apr 2009
Blog Post:
Mutating Readonly Structs
Eric Lippert
Consider this program which attempts to mutate a readonly mutable struct. What happens? struct Mutable { private int x; public int Mutate() { this.x = this.x + 1; return this.x; } } class Test { public readonly Mutable m = new Mutable(); static void Main(string[] args) { Test t = new Test(); System...
on
14 May 2008
Blog Post:
Why Do Initializers Run In The Opposite Order As Constructors? Part Two
Eric Lippert
As you might have figured out, the answer to last week's puzzle is "if the constructors and initializers run in their actual order then an initialized readonly field of reference type is guaranteed to be non null in any possible call. That guarantee cannot be met if the initializers run in the expected...
on
18 Feb 2008
Blog Post:
Why Do Initializers Run In The Opposite Order As Constructors? Part One
Eric Lippert
Pop quiz! What do you expect the output of this program to be? using System; class Foo { public Foo(string s) { Console.WriteLine("Foo constructor: {0}", s); } public void Bar() { } } class Base { readonly Foo baseFoo = new Foo("Base initializer"); public Base() { Console.WriteLine("Base...
on
15 Feb 2008
Blog Post:
Psychic Debugging, Part Two
Eric Lippert
A number of readers have the mysterious fifth sense which gives them the ability to deduce that the GetBars method from yesterday's post contains a yield return and is therefore an iterator. Remember, as the standard states (in section 10.14.4): [...] execution of the code in the iterator block occurs...
on
6 Sep 2007
Blog Post:
Psychic Debugging, Part One
Eric Lippert
Here is a compiler bug report I got the other day. The user is trying to write a unit test for a method which takes a Foo and returns a collection of Bar s. The test is supposed to confirm that GetBars throws an exception if the argument is null . The test was failing with “got no exception”. The user...
on
5 Sep 2007
Blog Post:
An Inheritance Puzzle, Part Two
Eric Lippert
Today, the answer to Friday's puzzle . It prints "Int32". But why? Some readers hypothesized that M would print out "Int32" because the declaration B : A<int> somehow tells B that T is to be treated as int , now and forever. Though the answer is right, the explanation is not quite right. One...
on
30 Jul 2007
Blog Post:
An Inheritance Puzzle, Part One
Eric Lippert
Once more I have returned from my ancestral homeland, after some weeks of sun, rain, storms, wind, calm, friends and family. I could certainly use another few weeks, but it is good to be back too. Well, enough chit-chat; back to programming language design. Here's an interesting combination of subclassing...
on
27 Jul 2007
Blog Post:
Even More Conversion Trivia, Part Two
Eric Lippert
Reader Barry Kelly came up with the solution I was thinking of for my trivia question yesterday. If the value in question is, say, a nullable integer which has no value then casting it explicitly to object results in the null object. Calling a virtual method on a null object results in an exception at...
on
1 May 2007
Blog Post:
Even More Conversion Trivia
Eric Lippert
I learn something new about C# every day. This is a subtle and tricky language. Pop quiz: foo is of a type which has a base class which has made a normal, everyday virtual override of System.Object.ToString . There are no additional overrides, hides, etc of ToString anywhere in foo 's inheritance...
on
30 Apr 2007
Blog Post:
Chained user-defined explicit conversions in C#, Part Three
Eric Lippert
Jeroen Frijters knew the answer to my challenge of last time: how is it that Foo foo = new Foo(); can cause a runtime conversion failure? And how is it that Bar bar = (Bar)(new Baz()); can succeed even if there is no user-defined conversion or built-in implicit conversion between Baz and Bar ? The...
on
20 Apr 2007
Blog Post:
Chained user-defined explicit conversions in C#, Part Two
Eric Lippert
Reader Larry Lard asks a follow-up question regarding the subject of Monday’s blog entry . Why is it that the compiler knows that (int)(new Base()) will always fail, and therefore makes the conversion illegal, but does not know that (Derived)(new Base()) will always fail, and make that conversion illegal...
on
18 Apr 2007
Page 1 of 2 (49 items)
1
2