Quick brainteaser

Just a really quick one today…

What’s the point of this code? Does it have any point at all?

public static class Extensions
{
    public static void Add<T>(this ICollection<T> source, T item)
    {
        source.Add(item);
    }
}

Bonus marks if you can work out what made me think about it.

I suggest you ROT-13 answers to avoid spoilers for other readers.

32 thoughts on “Quick brainteaser”

  1. Guvf nqqf n trarevp Nqq rkgrafvba zrgubq gb trarevp pbyyrpgvbaf. Fb jura nqqvat na vgrz, vgf glcr vf rkcyvpvgyl zragvbarq. Ab vqrn jul gubhtu… :| Ernqnovyvgl? :)

  2. Zl thrff vf gung lbh’er hfvat guvf gb trg nebhaq pnfgvat qhr gb na rkcyvpvg vagresnpr vzcyrzragngvba.

    Vs fb, creuncf lbh’er hfvat PbapheeragQvpgvbanel naq ner naablrq gung Erzbir() vf rkcyvpvgyl vzcyrzragrq naq qba’g jnag gb hfr GelErzbir(), orpnhfr lbh qba’g pner nobhg gur bhg cnenzrgref :)

  3. Qhaab, znlor gur pynff lbh jnag gb nqq gb rkcyvpvgyl vzcyrzragf gur vagresnpr VPbyyrpgvba. Fb guvf zvtug or gb fnir n pnfg?

  4. Vg yrgf lbh pnyy Nqq ba na vafgnapr bs n glcr juvpu rkcyvpvgyl vzcyrzragf VPbyyrpgvba jvgubhg arrqvat gb hfr n ohapu bs cneragurfrf gb pnfg vg.

    Also, your captcha is not working in Chrome Version 33.0.1750.154 m.

  5. Rirel glcr vzcyrzragvat VPbyyrpgvba zhfg unir na Nqq zrgubq. Va guvf jnl gur qrsnhyg vzcyrzragngvba nyjnlf uvqrf lbhe rkgrafvba zrgubq.

  6. Vs unf fbzrguvat gb qb jvgu gur arj PFunec FVK srngher: Nqq rkgrafvba zrgubqf sbe pbyyrpgvba vavgvnyvmref. Ohg hasbeghangryl V qba’g xabj jung’f gur cbvag fvapr jr pna hfr pbyyrpgvba vavgvnyvref jvgu VPbyyrpgvba vzcyrzragngvbaf (rt Yvfg)

  7. Guvf jvyy “frnzyrffyl” vaibxr na rkcyvpvgyl-vzcyrzragrq Nqq zrgubq jvgubhg erdhvevat gur pnyyre gb rkcyvpvgyl pnfg gb VPbyyrpgvba. Abg fher jung zvtug unir cebzcgrq guvf…

  8. Vg’yy nyybj lbh gb pbzcvyr n pnyy gb Nqq ba n ErnqBaylPbyyrpgvba (juvpu unf na rkcyvpvg vzcyrzragngvba bs VPbyyrpgvba.Nqq), fb gung lbh’yy vafgrnq trg n AbgFhccbegrqRkprcgvba ng ehagvzr. Zber trarenyyl, vg’f hauvqvat gur rkcyvpvg vagresnpr vzcyrzragngvba; znlor gung’f npghnyyl hfrshy ba nabgure glcr. Vg whfg frrzf yvxr n tbbq jnl gb trg crbcyr gb jevgr ohtf jura ivrjrq sebz gur crefcrpgvir bs n ErnqBaylPbyyrpgvba, gubhtu.

  9. Vg frrzf gb zr yvxr guvf pbqr vf vagraqrq gb cebivqr n phfgbz vzcyrzragngvba bs Nqq gb na VPbyyrpgvba. Ubjrire, fvapr VPbyyrpgvba nyernql unf na Nqq (aba trarevp) zrgubq, gur glcr vasrerapr qbrfa’g jbex. Gur erfhyg vf gung rirel gvzr guvf Nqq zrgubq vf tbvat gb or pnyyrq, gur glcr zhfg or cebivqrq be ryfr gur aba trarevp qrsnhyg zrgubq vf pnyyrq. Sbe rknzcyr

    VPbyyrpgvba crbcyr = arj Yvfg();
    crbcyr.Nqq
    (arj Crefba());//pnyy Nqq
    crbcyr.Nqq(arj Crefba());//pnyy Nqq, ybfg glcr vasrerapr

    Vg jbhyq frrz gur erprag npgvivgl sebz p# 6 fcnjarq guvf, naq lbhe cerivbhf pbzzragf nobhg rkgrafvba zrgubqf vf cebonoyl jul lbh ner erivfvgvat gurfr.

  10. Fb lbh pna pnyy na rkcyvpvgyl vzcyrzragrq zrzore ivn vagresnpr. Sbe rknzcyr, vg jbhyq yrg zr qb fbzrguvat yvxr guvf:

    YvaxrqYvfg yvaxrqYvfg = arj YvaxrqYvfg();
    yvaxrqYvfg.Nqq(11);

    Gur rknzcyr vf abg irel hfrshy, ohg V pna frr vg orvat unaql fbzrgvzrf.

  11. V ernyyl ubcr guvf vfa’g gur nafjre… ohg jung lbh’ir perngrq gurer vf n cnggrea juvpu znxrf guvf pynff ‘hfnoyr’:

    choyvp pynff ZhygvPbyyrpgvba
    : VPbyyrpgvba
    , VPbyyrpgvba
    jurer F : pynff
    jurer G : fgehpg
    {
    … gjb rkcyvpvg vagresnpr vzcyrzragngvbaf tb urer
    }

  12. Jvgu guvf rkgrafvba, lbh jvyy or noyr gb jevgr pbqr yvxr “pbyyrpgvba.Nqq(vgrz)” rira vs pbyyrpgvba vzcyrzragf VPbyyrpgvba rkcyvpvgyl, r.t. vgf npghny glcr vf Neenl.

  13. Vs n pynff vzcyrzragf VPbyyrpgvba<G> ohg vzcyrzragf gur Nqq-zrgubq rkcyvpvgryl (ibvq VPbyyrpgvba<G>.Nqq(G vgrz)), lbh pnaabg pnyy gur Nqq-zrgubq qverpgyl ba na vafgnapr bs gung pynff. Lbh pna rvgure pnfg vg gb VPbyyrpgvba<G> svefg, be hfr guvf rkgrafvba zrgubq.

  14. Dhvpx dhrfgvba, Vs V vzcyrzragrq na rkgrafvba zrgubq jvgu gur fnzr anzr bs na rkvfgvat bar; juvpu bar bs gurz gur PYE jvyy eha?

  15. Vf vg gb fubj lbh pna pnyy gur Nqq rkgrafvba zrgubq sebz n pbyyrpgvba vavgvnyvmre (P#6 srngher)?
    Cerivbhfyl, IO pbhyq pnyy na Nqq rkgrafvba zrgubq ohg P# pbhyqa’g jura vavgvnyvfvat n pbyyrpgvba. Gur pbqr nf vg fgnaqf qbrfa’g qb zhpu gubhtu…

  16. Nppbeqvat gb Zvpebfbsg qbphzragngvba, rkgrafvba zrgubqf nera’g pnyyrq vs gurve fvtangher whfg zngpurf gur bar va gur fcrpvsvp glcr:

    uggc://zfqa.zvpebfbsg.pbz/ra-hf/yvoenel/oo383977.nfck

    Ubjrire, vg frrzf n pnfr yvxr guvf jbhyq tb guebhtu gur rkgrafvba zrgubq vafgrnq bs gur rkcyvpvgyl vzcyrzragrq vagresnpr zrgubq:

    choyvp pynff ZlPbyyrpgvba : VPbyyrpgvba
    {
    ibvq VPbyyrpgvba
    .Nqq(G vgrz)
    {
    // …
    }

    // …
    }

    Gur “gevpx” bayl jbexf jura gur bowrpg vf bs ZlPbyyrpgvba “funcr” vafgrnq bs VPbyyrpgvba. Gung vf, guvf jbhyq tb guebhtu gur rkgrafvba zrgubq:

    ZlPbyyrpgvba pbyyrpgvba = arj ZlPbyyrpgvba();
    pbyyrpgvba.Nqq(“N”);

    Ohg guvf jvyy tb guebhtu ZlPbyyrpgvba.Nqq zrgubq

    VPbyyrpgvba pbyyrpgvba = arj ZlPbyyrpgvba();
    pbyyrpgvba.Nqq(“N”);

    Znlor Zvpebfbsg’f fgngrzrag fubhyq fgngr gung gur bayl zrgubqf gb gnxr vagb nppbhag sbe qvfnzovthngvba ner gubfr npprffvoyr sbe gur pheerag “funcr” bs gur bowrpg. Gung vf, gur vagresnpr gur bowrpg vf rkcbfvat guebhtu gur glcr bs inevnoyr vg vf fgberq gb.

  17. Sebz uggc://zfqa.zvpebfbsg.pbz/ra-hf//yvoenel/oo383977.nfck:
    Vs lbh qb vzcyrzrag rkgrafvba zrgubqf sbe n tvira glcr, erzrzore gur sbyybjvat cbvagf:
    1)Na rkgrafvba zrgubq jvyy arire or pnyyrq vs vg unf gur fnzr fvtangher nf n zrgubq qrsvarq va gur glcr.
    2)Rkgrafvba zrgubqf ner oebhtug vagb fpbcr ng gur anzrfcnpr yriry. Sbe rknzcyr, vs lbh unir zhygvcyr fgngvp pynffrf gung pbagnva rkgrafvba zrgubqf va n fvatyr anzrfcnpr anzrq Rkgrafvbaf, gurl jvyy nyy or oebhtug vagb fpbcr ol gur hfvat Rkgrafvbaf; qverpgvir.

    2 vf ab ybatre gehr va P# 6. V fhfcrpg fbzrguvat qvssrerag jvyy unccra va P# 6 guna va cerivbhf irefvbaf, ohg guvf fgvyy ybbxf yvxr vg fubhyq arire or pnyyrq gb zr.

  18. @Bryan: They’re rot13-encoded to prevent spoilers, basically. Copy and paste one into rot13.com and you’ll see the plaintext.

  19. Lbh jnag gb frr vs rkgrafvbaf pna funqbj onfr shapgvbaf

    Also, Cthulhu has awakened after these comments. I hope you’re proud of yourself now!

  20. Vg nyybjf lbh gb nibvq gur rkcyvpvg pnfg gb VPbyyrpgvba va beqre gb pnyy Nqq ba na vafgnapr gung rkcyvpvgyl vzcyrzragf gur vagresnpr zrgubq. Lbh gubhtug nobhg vg orpnhfr lbh jrer jbaqrevat jul gur Nqq zrgubq jnf nccrnevat nf na rkgrafvba zrgubq va VagryyvFrafr sbe na bowrpg bs glcr ErnqBaylPbyyrpgvba?

Comments are closed.