top of page
  • Writer's pictureJack Orenstein

8 Queens as a Marcel One-Liner

Yes, the 8 Queens problem can be solved in marcel, as a one-liner even. If you want the details, you can find them here. But the basic idea is this:

  • Use Python's itertools.permutations to generate candidates.

  • Write a function to check the candidate for queen attacks along diagonals.

  • Pipe the candidates to the checking function.

Well, that's cheating, isn't it? I mean, all the work is being done in Python, either with a library function (itertools.permutation) or a lambda.

That's sort of the point. Marcel makes it really easy to use Python from the command line, and then combine those bits of logic. Sure, you could write, and the code would be much the same. Or, if for some reason you really want to do 8 queens as a shell script, bash can do the job. But right from the command line? I don't think any other shells can do that.

69 views0 comments

Recent Posts

See All

Marcel in more places

Thanks to two different pilot errors on my part, I have broken the packaging system of two OSes that package marcel. I would have had no idea they were including marcel otherwise. In any case, I'm hap

Marcel and Jupyter

For years, I kept hearing about iPython, as a vastly improved Python REPL. I played with it a little bit, and yes, I saw that. I found that Object Shell (a forerunner of marcel) ran in iPython with no


bottom of page