Jump to content

pmcgee

Members
  • Content Count

    50
  • Joined

  • Last visited

  • Days Won

    1

pmcgee last won the day on December 12

pmcgee had the most liked content!

Community Reputation

23 Excellent

1 Follower

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. pmcgee

    The Advent of Code 2024.

    Personally, I post everything that it takes to recreate my answer. And any sundry files (like Excel) I might employ to help along the way. Reproducible Research™ 🙂 Ha. I feel this pain. 😅 I have often found my code volume increasing like an expanding balloon ... until I have worked out what I should have been doing, then the cutting away begins ... and 80 lines drops back to 20. I have this currently in my solution for Problem 5 Part 2. 60 out of 120 lines became unnecessary as I realised the information I needed to gather ... but the exploration process was necessary to come to that understanding in the first place. 🙂
  2. pmcgee

    What is this flashing message doing there?

    If you can see it on the screen, you can capture video of your screen. If it's in the IDE, then eg Delphi has a CodeInsight bar that buzzes up a little for a moderate size project (like DevCpp), loading or analyzing some stuff, then disappears.
  3. pmcgee

    The Advent of Code 2024.

    I was following an idea that I had thought of yesterday ... and now have the form of the solution. I was assuming the data was less strictly complete than it is, so in reality it's not so hard actually.
  4. pmcgee

    The Advent of Code 2024.

    I made a quick video of an (unsolved atm) part I liked of Q5-2 ...
  5. pmcgee

    The Advent of Code 2024.

    @JohnLM ... (Throwing a possible small spanner) ... I'm not sure from the gif ... are you sorting the two lists?
  6. pmcgee

    The Advent of Code 2024.

    One thing that is part of the challenge, from my perspective ... is when you can deal with Part 2 with only a reasonably small modification of your Part 1 solution. Maybe it's just me, but I find that very satisfying when it happens. 😎
  7. pmcgee

    The Advent of Code 2024.

    I don't think you should be bothered about watermarks. In my favourite 'podcast with slides' of well over 100 episodes, the 'Activate Windows' logo has become an expected, even demanded, regular character.
  8. @jesu I see this was a while back, but I'd encourage you to look up the idea of an Optional type. (One of) the points of an optional type, is that it doesn't reduce the value space of your inhabited type. Using 'NaN' or '-1' or whatever as a magic value might interfere with the validity of your use of the Double value. With an optional type , the inhabited type is uncontaminated by any other interpretation or usage. You can look at what it looks like in eg Spring4D, but here's the basic idea : type Maybe_Double = record // or Optional_Double ok : boolean; d : double; end; function Safe_Sqrt( i:integer ) : Maybe_Double; begin if i<0 then result.ok := false else begin result.ok := true; result.d := sqrt(i); end; end; begin for var i:= -2 to 2 do begin var ss := Safe_Sqrt(i); if ss.ok then writeln(i, ' ', d) else writeln(i, ' ','Undefined'); end; end. PS : Another feature of an optional type is that all uses of the inhabited type transfer into the "optional world". // If you have a function F( d:double ) : string, // then you can automatically have an 'identical' function OptF( od:maybe_double ) : maybe_string; begin if od.ok then exit( F(od) ) else exit( <the nil case> ) end;
  9. pmcgee

    The Advent of Code 2024.

    @JohnLM Great. This is perfectly reasonable .. for at least two reasons. 1) The challenge is about achieving a solution - dissecting the problem in a way that makes it solvable. 2) Eg in the day 2 and 3 problems, I put the data in Excel to manipulate it around, get a perspective on the contents, and to provide results to crosscheck against while I am only part way towards constructing my approach. I have kept them in my Github repo. 3) Also, some of the challenge is just reading in the data ... which can be sometimes tedious and/or obvious. I have used Excel and Notepad++ to make the data into a Delphi unit holding the info, when moving text with code was unrewarding. PS : There's a cool video from the guy that creates and runs the challenges from very recently. People solve the problems in many different ways - and not just with code. CppNorth - Keynote: Advent of Code, Behind the Scenes - Eric Wastl
  10. pmcgee

    The Advent of Code 2024.

    Done. I've never used these before. 🙂
  11. pmcgee

    The Advent of Code 2024.

    I'm lagging a little bit behind ... my solutions are here : https://github.com/pmcgee69/Advent-of-Code-2024/ My ultimate aim is to try to use a functional approach ... and to get ideas for better syntax for Delphi into the future. I'd really like to also solve in Rust and C++, for the learning but also for the ideas on syntax. I will definitely try to lean on eg Claude.io to work out solutions in those two. There's only so much time available!
  12. pmcgee

    The Advent of Code 2024.

    The Advent of Code 2024. ChatGPT >> I’d like to encourage lots of Delphi people to have a crack and maybe compare solutions - online or at a meeting. Each day is pretty much independent of the others … but the concepts might build upon previous days’ puzzles. Fun starts on 1st December. Link → The Advent of Code 2024
  13. pmcgee

    A gem from the past (Goto)

    Something I posted on the ADUG forum ... this C code (when I saw it) was posted on twitter as an amusing post about C. [ Cursed C code ] But after I'd thought about it for a bit, it occurred to me that maybe I could do the same in Delphi. And we can. 🙂 {$APPTYPE CONSOLE} program Project1; type range_struct = record type Tstate = (at_start, in_loop, done); var stop, step, i, start : integer; state : Tstate; function resume() : integer; constructor λ ( _start, _stop : integer; _step : integer = 1); end; constructor range_struct.λ( _start, _stop, _step:integer); begin start := _start; stop := _stop; step := _step; state := at_start; end; function range_struct.resume() : integer; label α,β,δ; begin case state of at_start : goto α; in_loop : goto β; done : goto δ; end; α : i:=start; repeat begin state := in_loop; exit(i); β : i := i + step; end until i >= stop; state := done; δ : exit(0); end; begin var ρ := range_struct.λ(1,20,2); var π := range_struct.λ(2,20,2); for var i in [1..5] do begin writeln('a ',i:2, 'th call : ', ρ.resume); writeln(' b ',i:2, 'th call : ', π.resume); end; writeln; writeln('Mwah ha ha. GOTO is back, baby!'); readln; end. That wasn't the original function-calling code that I had posted. It was only after a bit of mental digestion that I realised that this is (in my opinion) a really good, simplified, understandable model of a coroutine. ... and soon after I found out the original C code was part of an article commenting on c++ coroutines : https://probablydance.com/2021/10/31/c-coroutines-do-not-spark-joy/
  14. It is, in a sense, a bit sad that the lack of user-definable infix operators leads to this sort of "creative interpretation". Shouldn't we complain about this almost as much as about 'With' eg ? This could have (should have?) been implemented by a JoinTo( s1, s2 : string) function. An actual Equality Operator should exhibit the qualities of being reflexive (a=a), symmetric (a=b => b=a), and transitive (a=b, b=c => a=c) (and going back to the first question ... it wouldn't need to return a boolean. Eg some cases, like a partial order, it might return an optional boolean)
  15. ^ I don't have D2007. Your D10+ version works in freepascal using {$mode delphi} and this works in fpc without it : sig2: FileSig = (Offset: 10; arrSig: ($00,$01,$02); );
×