Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Advent of Code

206 views
Skip to first unread message

Lawrence Woodman

unread,
Dec 1, 2018, 10:27:28 AM12/1/18
to
Hello All,

For those unaware the Advent of Code challenge (https://adventofcode.com)
has started today. It's a bit of fun and a nice way to count down
to Christmas.

I'm going to do it in TCL (and possibly other languages):
https://github.com/lawrencewoodman/adventofcode


Best wishes


Lorry

heinrichmartin

unread,
Dec 1, 2018, 4:11:31 PM12/1/18
to
Spoilers ahead.

On Monday, November 26, 2018 at 10:53:45 AM UTC+1, Ralf Fassel wrote:
> TCL practicing (& advocacy :-)
> Careful: it's highly addictive :-)

On Saturday, December 1, 2018 at 4:27:28 PM UTC+1, Lawrence Woodman wrote:
> https://github.com/lawrencewoodman/adventofcode

In the sense of advocacy, I'd really like to add that the input need not be split - it is a Tcl list right away.
And how about ::tcl::mathop along with {*}$input ;-)

But thanks for reminding me of dict or array for sets.

No worries, I will not comment all your code. Actually, I was unsure whether I should do so at all - and if so, whether in public or not. I saw newbies on c.l.t., that's why I made this single comment. Judge me, if need be.

Martin

Lawrence Woodman

unread,
Dec 2, 2018, 1:14:15 AM12/2/18
to
Thanks Martin, any comments appreciated. I'm always trying to improve
my style and often with things like the split string, we can do things
out of habit, without making full use of the nature of the language
in which we are programming.

I particularly like the ::tcl::mathop one as it makes the code really
succinct.

I have updated the repo to reflect your suggestions.

Best wishes


Lawrence Woodman



---
https://techtinkering.com - Retro Computers, Programming and General Technical Tinkering

Gerald Lester

unread,
Dec 2, 2018, 10:58:11 PM12/2/18
to
On 12/01/2018 09:27 AM, Lawrence Woodman wrote:
> For those unaware the Advent of Code challenge (https://adventofcode.com)
> has started today. It's a bit of fun and a nice way to count down
> to Christmas.
>
> I'm going to do it in TCL (and possibly other languages):
> https://github.com/lawrencewoodman/adventofcode

I'm doing them, if anyone would like to see sample solutions see:
https://chiselapp.com/user/gwlester/repository/AdventOfCode/home

It includes a driver that runs in either CLI or GUI mode.

--
+----------------------------------------------------------------------+
| Gerald W. Lester, President, KNG Consulting LLC |
| Email: Gerald...@kng-consulting.net |
+----------------------------------------------------------------------+

Ralf Fassel

unread,
Dec 3, 2018, 4:33:54 AM12/3/18
to
* Gerald Lester <Gerald...@KnG-Consulting.net>
| On 12/01/2018 09:27 AM, Lawrence Woodman wrote:
| > For those unaware the Advent of Code challenge
| > (https://adventofcode.com) has started today. It's a bit of fun and
| > a nice way to count down to Christmas.
| >
| > I'm going to do it in TCL (and possibly other languages):
| > https://github.com/lawrencewoodman/adventofcode
>
| I'm doing them, if anyone would like to see sample solutions see:
| https://chiselapp.com/user/gwlester/repository/AdventOfCode/home

Me 2 :-), joining the club on the somewhat 'official' solutions forum on
https://www.reddit.com/r/adventofcode/
Lots of languages there, even FORTRAN and Minecraft...
Especially some perl solutions are mind-boggling...

R'

Gerald Lester

unread,
Dec 3, 2018, 7:07:56 PM12/3/18
to
Made some corrections to the driver and the "templates".

Lawrence Woodman

unread,
Dec 4, 2018, 10:47:18 AM12/4/18
to
On Sun, 02 Dec 2018 21:58:07 -0600, Gerald Lester wrote:

> On 12/01/2018 09:27 AM, Lawrence Woodman wrote:
>> For those unaware the Advent of Code challenge (https://adventofcode.com)
>> has started today. It's a bit of fun and a nice way to count down
>> to Christmas.
>>
>> I'm going to do it in TCL (and possibly other languages):
>> https://github.com/lawrencewoodman/adventofcode
>
> I'm doing them, if anyone would like to see sample solutions see:
> https://chiselapp.com/user/gwlester/repository/AdventOfCode/home
>
> It includes a driver that runs in either CLI or GUI mode.

It's great to see the different approaches to the puzzles. Looking
at them shows what a unique language Tcl is in many ways.

I have now decided to do each challenge in Tcl first as a prototype,
and then do a different language for each of the other days as an
extra challenge. This will total 25 different languages in 25 days.

https://techtinkering.com/articles/advent-of-code-2018-25-days-25-languages/


Best wishes


Lorry

--
https://techtinkering.com - Retro computers, programming and general technical tinkering.

Che2n

unread,
Dec 8, 2018, 6:38:07 AM12/8/18
to
On Monday, December 3, 2018 at 7:58:11 AM UTC+4, Gerald Lester wrote:
> On 12/01/2018 09:27 AM, Lawrence Woodman wrote:
> > For those unaware the Advent of Code challenge (https://adventofcode.com)
> > has started today. It's a bit of fun and a nice way to count down
> > to Christmas.
> >
> > I'm going to do it in TCL (and possibly other languages):
> > https://github.com/lawrencewoodman/adventofcode
>
> I'm doing them, if anyone would like to see sample solutions see:
> https://chiselapp.com/user/gwlester/repository/AdventOfCode/home
>
> It includes a driver that runs in either CLI or GUI mode.
>

Hello,

I have checked your solution for D7P2 and I was impressed by this

proc Step {prereq must be finished before step dependent can begin} {
...
}

proc Solution {input} {
...
uplevel #0 eval [join $input "\n"]
...
}

I have not thought about this trick, nice job.

regards

biancasoare...@gmail.com

unread,
Dec 8, 2018, 8:27:37 AM12/8/18
to
Hi
I'm looking for updated Tcl information.
but the book I have is from 2005
(Tcl / Tk - Linux Programming
By Alexander Franca)

Is the Tcl language currently used to schedule servers / backend?

Gerald Lester

unread,
Dec 8, 2018, 12:29:55 PM12/8/18
to
Yes, e.g. FlightAware.com

onem...@gmail.com

unread,
Dec 8, 2018, 3:49:51 PM12/8/18
to
This reminds me - seeing your original post inspired me to play along and post my solutions. I've been putting them on Github for convenient examination:
https://github.com/theerik/adventofcode
Hopefully I've managed to do something interesting somewhere. :)

--Erik

Gerald Lester

unread,
Dec 8, 2018, 5:58:31 PM12/8/18
to
Well, Tcl has been used to create mini-languages since day 1!

In a "real" production system, I would have evaluated the input in a
Safe Interp. with just the Step command existing and aliasing back into
the main interp -- but that was a little overkill for this.

heinrichmartin

unread,
Dec 9, 2018, 5:49:37 AM12/9/18
to
On Saturday, December 8, 2018 at 11:58:31 PM UTC+1, Gerald Lester wrote:
> > proc Step {prereq must be finished before step dependent can begin} {
> > ...
> > }
> In a "real" production system, I would have evaluated the input in a
> Safe Interp. with just the Step command existing and aliasing back into
> the main interp -- but that was a little overkill for this.

Is there a real benefit over a regexp (for a single command)?

Gerald Lester

unread,
Dec 9, 2018, 4:57:26 PM12/9/18
to
Well, not sure why you would bother with regexp, lindex would be easier.

It all depends on how "real benefit" is defined -- one thing something
like Advent of Code does is show ways to use the language, thus in this
case there was a "real benefit" to Erik.

That being said, your mileage may vary.

heinrichmartin

unread,
Dec 10, 2018, 10:28:41 AM12/10/18
to
On Sunday, December 9, 2018 at 10:57:26 PM UTC+1, Gerald Lester wrote:
> Well, not sure why you would bother with regexp, lindex would be easier.
>
> It all depends on how "real benefit" is defined -- one thing something
> like Advent of Code does is show ways to use the language, thus in this
> case there was a "real benefit" to Erik.

When I read "production system", I think of robustness and performance. I like the character of Tcl a lot, but hacking a puzzle does not generate production code. In this regard, it does not matter which of the Tcl parsers (script, list, [in another context] expr) are or are not used.

The question should have been: What is the benefit of using a Tcl built-in *parser* rather than string processing (regexp, scan, lsearch, ...) in *production code*?

Btw, in this special case (simple input, all space separated) one could even just [source] the input file, which is indeed very cool!
0 new messages