back to article On the first day of Christmas, my true love gave to me... a coding puzzle and it's a doozy

It's that time of year again, when all good little developers count down to the festive season with the Advent of Code. It's a gloriously simple concept. Much like the Advent Calendar, each day in December, up to and including the 25th, contains a treat. However, rather than pictures or vaguely stale chocolates, each Advent …

  1. ShadowSystems
    Coat

    I challenge you to use a better language...

    Logo! There's nothing that turtle can't do! =-D

    *Cough*

    I'll get my coat, it's the one with the pen in the pocket...

    1. Aladdin Sane Silver badge

      Re: I challenge you to use a better language...

      The turtle moves!

      GNU Sir Pterry

    2. b0llchit Silver badge
      Joke

      Re: I challenge you to use a better language...

      Wouldn't you need to "invent a species of robots, let them evolve and develop language" to use a better language?

    3. Arthur the cat Silver badge

      Re: I challenge you to use a better language...

      Come on! Use the one true programming language for challenges - INTERCAL.

      Just using it is a challenge.

      1. Red Ted Silver badge
        Go

        Re: I challenge you to use a better language...

        From the Intercal Introduction:

        "The INTERCAL programming language was designed the morning of May 26, 1972 by Donald R. Woods and James M. Lyon, at Princeton University. Exactly when in the morning will become apparent in the course of this manual."

        1. Neil Barnes Silver badge

          Re: I challenge you to use a better language...

          Pah. Real programmers merely set the starting conditions of the universe so that when a program is required, it exists.

        2. Swarthy Silver badge

          Re: I challenge you to use a better language...

          A real challenge: Malbolge

      2. John Brown (no body) Silver badge

        Re: I challenge you to use a better language...

        LOL :-)

        On the other hand, for what may be the ultimate in RISC languages, try CESIL

        1. Beleagured Greybeard
          Happy

          Re: I challenge you to use a better language...

          CESIL.

          WOW! That takes me back!

          Computer Education in Schools Instructional Language.

          Waaaaaaaay back in school when I chose "Computer Studies" as an O-level subject, it was my very first exposure to a programming langauge, used mainly to teach the concepts of operators, operands, input, output, variables and constants, etc. After a term of learning it we switched to BASIC and never touched CESIL again.

          If I remember correctly (it was 40yrs ago now!) it only had 12 instructions:

          IN, OUT, STORE, LOAD, ADD, SUBTRACT, MULTIPY, DIVIDE, JUMP, JINEG JIZERO and HALT.

          You couldn't work on 2 variables at a time, just one variable (or a consant) and the Accumulator!

          something like c=a+b would be

          LOAD A

          ADD B

          STORE C

          There was no IF type comparison. Basically the only 2 conditions were JINEG (Jump If Negative) and JIZERO (Jump If Zero), used (if memory serves) to learn the construct of loops.

          Happy days in a simpler world.

    4. Stumpy

      Re: I challenge you to use a better language...

      Someone I know is trying to see how far they can go using Sinclair Basic on a Spectrum 128

      1. David 132 Silver badge
        Happy

        Re: I challenge you to use a better language...

        Oooh, la-de-dah, look at Mister Fancy here with his 128KB of memory.

        Pass me that blu-tack, will you, my ZX RAMpack is wobbling again…

        1. katrinab Silver badge
          Paris Hilton

          Re: I challenge you to use a better language...

          I'll keep my Threadripper Pro with 128GB of RAM thank you very much.

  2. heyrick Silver badge
    Happy

    Rust?

    ?

    If you want a proper challenge, write the solution in Brainfuck.

    1. Skiron
      1. djack

        Re: Rust?

        Ot the perl module Lingua::Romana::Perligata:

        i now have the sudden urge to try and learn Latin

        1. ICL1900-G3 Bronze badge

          Re: Rust?

          Latin is wonderful, regular in grammar and pronunciation. Why they went to the trouble to invent Esperanto and Glossa is beyond me.

          1. Swarthy Silver badge

            Re: Rust?

            Latin is a dead language

            Dead as dead can be

            First, it killed the Romans

            And now, it's killing me

          2. idiot taxpayer here again Bronze badge

            Re: Rust?

            @ICL1900-G3

            I had to learn the stupid waste of time language at school. It was and still is shit. And more to there point useless. I have never heard anyone ask for a pint and/or scratchings in Latin. And whilst I am at it, only Southerners and social workers trying to be "common" ask for "pork scratchings". As if there was any other sort...

            1. Anonymous Coward
              Anonymous Coward

              Re: Rust?

              idiot taxpayer here again,

              May I will call you 'idiot' for short !!! :)

              Mr/Ms/Mx 'idiot' you are so so so wrong !!!

              Approximately, 30% to 60% of English vocabulary comes from Latin. (Exact figures are debatable !!!)

              Many European languages are derived from latin and the words/word roots are similar.

              Latin is useful, enabling you to ' sort of' understand other languages if you have never had the opportunity to learn them.

              Latin is the source of the jargon in medicine, the sciences and law to name a few important fields of knowledge.

              It makes the latin jokes in 'Life of Brian' much better !!!

              I could go on but you should get my drift ..... so to speak !!! :)

              1. idiot taxpayer here again Bronze badge

                Re: Rust?

                @A/C

                You may call me what you want.

                As you are an A/C you are a borderline irrelevance.

                1. Anonymous Coward
                  Anonymous Coward

                  Re: Rust?

                  idiot taxpayer here again,

                  I am 'Borderline' many things BUT the real question is am I right .... re: Latin.

                  P.S. Does knowing my name change a truth to a falsehood or vice versa.

                  P.P.S. Obviously my 'Borderline' humour missed you somehow and no doubt will again :)

              2. CuChulainn Silver badge

                Re: Rust?

                But apart from the vocabulary, European languages, grammar, medical jargon, and the Life of Brian... what has Latin ever done for us? :-D

                You are right in your comments about its relevance, BTW.

            2. LionelB Bronze badge

              Re: Rust?

              I thought so too until meeting my lovely Spanish partner. At which point I realised that I already understood verb conjugation, the subjunctive mood and the imperfect past tense. (In fact I am still slightly disappointed that Spanish nouns don't decline.) I even find myself correcting Spanish speakers' own (mis)usage of direct and indirect object pronouns; they're surprisingly crap at it - so much so that they have names for it: leísmo and laísmo.

    2. Loyal Commenter Silver badge
      Trollface

      Re: Rust?

      BEFUNGE or go home

      1. idiot taxpayer here again Bronze badge

        Re: Rust?

        @Loyal Commenter.

        I have no idea what "befunge" is, but I have now stolen it to use as a replacement for "fucker". As in, "fuck off you befunger". Oh joy!!

        1. Anonymous Coward
          Anonymous Coward

          Re: Rust?

          idiot taxpayer here again,

          Hic est notitia ..... google est, amici !!! :)

          https://en.wikipedia.org/wiki/Befunge

          1. John Brown (no body) Silver badge
            Happy

            Re: Rust?

            "a cross between Forth and Lemmings"

            Love it.

  3. Caver_Dave
    Thumb Down

    I was going to take a look

    Until Rust was mentioned.

  4. DarkwavePunk

    I hate these things...

    1) I never completely understand the question (I'm a moron). 2) Even if I do vaguely glean the problem I'll try and solve it with some mutant hybrid of bash/sed/awk/bc (I'm a moron). Once tried that Project Euler thing. Got a little way through it mostly because there's a Unix util called "primes". Attempted to use Python but that added more misery and woe. They all seem to descend into "Your late uncle's half brother's sister married a fridge stolen from your great aunt. How many magnets do you need?". Have I mentioned I'm a moron?

    1. ICL1900-G3 Bronze badge

      Re: I hate these things...

      Hey.. A soulmate!

  5. AIBailey
    Big Brother

    When all you have is a hammer...

    ...every problem looks like a nail.

    Considering I've solved day one on a works PC, where it's pretty locked down, the only hammer I have is VBA in Excel.

    Still, it got the job done.

    Icon, because that's how it feels when your computer is locked down.

    1. W.S.Gosset Silver badge

      Re: When all you have is a hammer...

      Pfft. Don't need VBA.

      {=SUM( IF( OFFSET(Depths, 1, 0, (ROWS(Depths) - 1), 1) > OFFSET(OFFSET(Depths, 1, 0, (ROWS(Depths) - 1), 1), -1,0), 1,0))}

      .

      (The glunging OFFSET is to fix a fencepost error on my much more readable original:

      {=SUM( IF(Depths > OFFSET(Depths, -1,0), 1,0))} .

      Note to get the {}s you need to force interpretation as an Array formula by holding down ctrl-shift as you hit Enter.)

  6. trevorde Silver badge

    Only if I can cheat

    Once had to do the ubiquitous 'FizzBuzz' challenge at a job interview. I pointed out that you could pre-compute the results, so the problem reduced to simply looking up the result. I didn't get the job.

    1. Loyal Commenter Silver badge

      Re: Only if I can cheat

      You were too good for them.

      Pre-computing lookup tables used to be a common feature of 8-bit programming back when processors ran at 2 MHz...

  7. veti Silver badge

    Followed the link, but I can't see anything that looks like a puzzle. Is the challenge to work out wtf that page is saying?

    1. Alistair Wall

      You have to log in before you see the puzzle.

    2. FrogsAndChips

      If you click on the days (currently only 1 and 2 are available), you'll get a description of the challenge. Then you'll need to login to access the actual puzzle data and submit your answer.

      1. Anonymous Coward
        Anonymous Coward

        Though looking at the first two puzzles, you could solve them with pen and paper

        1. Loyal Commenter Silver badge

          Slowly. The examples are only a dozen lines or so long, but the inputs for the actual exercises are thousands of entries. They can be solved a lot more quickly by saving the inputs to a file, reading them into memory a line at a time, and processing, and with a dozen lines of code, or so.

          Pretty much every language I have ever used has low-level file operations (open, read, close), and most allow you to read a line at a time, with standard line endings.

  8. YetAnotherJoeBlow Bronze badge

    pdp-11 assembly and C on simh

    1. Dagg
      Pint

      pdp-11 the 1st true love of my life.

      014747

  9. Ian Johnston Silver badge

    Advent is four weeks leading up to Christmas, not 25 days in December.

    Oh and while I'm at it it, Sunday 26th isn't Boxing Day this year - it's Christmas Sunday. The BBC unilaterally changed the definition of Boxing Day quite recently.

    And even the government website gets the order of bank holidays wrong: Monday 27th is the Boxing Day bank holiday (first working day after Christmas) and Tuesday 28th is the Christmas Day bank holiday (first working day after Christmas, but Boxing Day has already nabbed 27th).

    Now get off my lawn.

    1. FrogsAndChips
      Trollface

      So Xmay Day Bank holiday and Boxing Day bank holiday are both 'first working day after Christmas'? No wonder the BBC got it all mixed up.

      1. idiot taxpayer here again Bronze badge

        @FrogsAndChips

        I think you may have mean't to write "Christmas Day" and not "Xmay day".

      2. Ian Johnston Silver badge

        So Xmay Day Bank holiday and Boxing Day bank holiday are both 'first working day after Christmas'?

        Yes, basically, but the Boxing Day one is defined first, so after it gets the Monday, Tuesday becomes the first working day after Christmas and therefore cops the (in-lieu-of) Christmas bank holiday. Used to be a great question for pub quizzes.

    2. AdamT

      Legislation is like bad code....

      I had to look into all this once (when the UK Gov decided to just change a bunch of Bank Holidays and it broke some stuff).

      I think the logic is:

      - Christmas Day and Good Friday are "common law" holidays. i.e. everyone knows what they are and when they are

      - All other Bank Holidays are described with reference to Xmas and GF by the Banking and Financial Dealings Act 1971. i.e. that no one can be made to do anything on a Bank Holiday that they can't be made to do on Xmas or GF [1]

      - The Bank Holidays are listed in the Appendix to that Act [2]

      - The astute observer will note that this list does not include several Bank Holidays that we expect, not does it include getting a Tuesday if Xmas + Boxing are on the weekend

      - However, as regular as clockwork, the Queen will proclaim the additional Bank Holidays (because some one in UK Gov asks her to) [3]

      So actually it looks like we are mostly governed by really bad code. i.e. hardly anything is re-written, it is just patched and tweaked and then someone sets up a cron job to update something on certain years, etc. etc.

      1 - https://www.legislation.gov.uk/ukpga/1971/80/section/1

      2 - https://www.legislation.gov.uk/ukpga/1971/80/schedule/1

      3 - https://www.thegazette.co.uk/notice/3846031

      1. Ian Johnston Silver badge

        Re: Legislation is like bad code....

        Thanks! Some years ago the (Glasgow) Herald newspaper tried to find out who sets the dates of the Glasgow Fair Weekend and Fortnight. Sure, we all know it's a week later than the Paisley one, but that's just pushing the problem down the line.

        They concluded in the end that nobody actually sets it, or makes a decision ... it just coalesces as "something everyone knows" each year.

        1. katrinab Silver badge
          Paris Hilton

          Re: Legislation is like bad code....

          Glasgow City Council?

          https://www.glasgow.gov.uk/article/3741/Public-General-Holidays

      2. J.G.Harston Silver badge

        Re: Legislation is like bad code....

        I seem to remember that British Summer Time was similarly not in legislation but declared as an order in council or somesuch. I remember a couple of years having a desk diary with a note at the begining saying something like "BST dates as marked are provisional as the Government have not published the dates yet". Even though everybody *knows* it's last-Sun-in-Oct and last-Sun-in-Mar. HMG still had to publish a notice declaring it, just like the Roman Calends.

    3. dcsprior

      "Advent is four weeks leading up to Christmas, not 25 days in December."

      The traditional/religious definition maybe, the modern one no.

      Whilst Christmas may have started as a religious festival it is now also a cultural festival for people of any religion and none. The same is true of some festivals in other religions.

  10. Robert Grant Silver badge

    After using Python, I then solved day 1 using very basic Excel; just line up the columns and sum a cell comparison!

  11. Grunchy

    I got 50 ⭐️ last year!

    I think I cracked the top 1,000 one time only.

    I used C#, because who cares!

  12. AdamWill

    Attention headline scansion department

    "A coding puzzle and it's a doozy" has one too many syllables. May I suggest "A coding puzzle, it's a doozy"?

POST COMMENT House rules

Not a member of The Register? Create a new account here.

  • Enter your comment

  • Add an icon

Anonymous cowards cannot choose their icon

Biting the hand that feeds IT © 1998–2022