A fun little puzzle for the weekend!

I know that many here (including me) enjoy the challenge of working out workflows, and it’s great to be able to help others with resolving a problem. But I thought, since it’s the weekend, how about putting up a workflow and asking a question purely for fun.

So here is a puzzle for you. Some may find it easy (if they know), some might find it more challenging.

Attached is a workflow.

It reads in a CSV file that is supplied in the workflow’s data area.

It does (intentionally undocumented) “stuff” to this data, and at the far end it produces a piece of poetry.

But the “stuff” that it does will not work unless some simple rules are applied to the data, as described in the annotations.

Your mission (should you choose to accept it) is to apply those rules in place of the red and orange annotation box.

But… your challenge, is to USE ONLY ONE NODE, and further it MUST NOT BE any of the java/python/R nodes, and it must not be either of the Column Expression nodes.

… off you go… :wink:

A fun little puzzle for the weekend.knwf (44.0 KB)

10 Likes

Hi @takbb , I am not going to present my workflow as I usually do so that there is no spoiler, so I have attached my comments/reasoning inside my workflow.

Here’s my workflow for you to check: A fun little puzzle for the weekend - Bruno.knwf (48.1 KB)

2 Likes

Thanks Bruno for not spoiling. I won’t comment on your comment yet, but it looks like I am going to have to make the logic harder specifically for you for the “next one”… :wink:

It looks like somewhere between me “finalising” my workflow, and exporting it, I managed to alter the config of one of the nodes, so it doesn’t appear in the correct order at the end! Node 58 (String to Number) should be converting the column “seq” to numeric, but somehow I’d managed to have it convert the column “OK” instead! Darn!

My corrected workflow is attached here

A fun little puzzle for the weekend.knwf (45.5 KB)

2 Likes

I re-did it with your corrected workflow, and now the poem make sense @takbb :slight_smile:

I’m not re-uploading the workflow, since the puzzle was to come up with that one node, and it’s the same node that I provided originally

3 Likes

Yes that’ll teach me… schoolboy error… to “fix” something before releasing…

Anyway @Bruno29a, since you saw through the (obviously intentional… :thinking: :rofl:) “red herring” of the Y and N columns, and found a shortcut, I hope this time, I have managed to make it slightly more challenging.

The same idea and challenge as before, and the same poem if you get it right, but no longer are the substitutions for the letters “z” and “q” which don’t appear anywhere else in the text. This time you have A,B,C,D as the values in the “selection” column… and they cause you to change letters “e”,“t”,“W” (yes, capital W) and “o” respectively into spaces, as it describes in the annotation.

It’ll be interesting to see if you, or anybody else finds another shortcut that I hadn’t considered. :wink:

A fun little puzzle for the weekend - made harder.knwf (48.4 KB)

2 Likes

Hi @takbb , here’s an attempt: A fun little puzzle for the weekend - made harder1 - Bruno.knwf (67.3 KB)

Technically, I am within the rule of one node :smiley:

4 Likes

Hi @takbb,

interessting idea -

->had to change the seq-nr to number (maybe because I am using version 4.3.1 or because there was additional undocumented behaviour :stuck_out_tongue: )
A fun little puzzle for the weekend.knwf (47.6 KB)

Same as version 1
A fun little puzzle for the weekend-1.knwf (47.5 KB)

Basically the same as 1 :laughing:
A fun little puzzle for the weekend - made harder-1.knwf (51.2 KB)

Not sure if there is a possible solution with any other KNIME default node :thinking:

3 Likes

@bruno29a… yes… technically… :wink: love it!

@AnotherFraudUser … I think the error with the sorting of numbers with with my installation …(or more specifically “error between keyboard and chair:joy: ). That was a good answer that I hadn’t considered and I wasn’t expecting it to work, so I need to think of a way of making it harder still, clearly… :wink:

3 Likes

Ok then… I had to really think about this. I’m hoping that I’ve found a way to make it tougher, but I also know you will probably still outwit me! :slight_smile:

I think I’ve come up with it. Almost the same workflow. Slightly modified data. Adjusted rules… where you now have to contend with ODD and EVEN values in the seq column…

A fun little puzzle for the weekend - ODDly made EVEN harder.knwf (48.4 KB)

But of course there are rules that remain… ONE NODE… (and no components, home-grown or otherwise, no metanodes, no Java/Python/R nodes. No Column Expression node. It will be ONE standard node… :wink:

2 Likes

Hi @takbb,

oddly still readable :laughing:
But would be interessted if anyone got a more performant solution (less copy&paste) :smiley:
But thanks @takbb that was a nice distraction for a bit on a boring train ride.

A fun little puzzle for the weekend - ODDly made EVEN harder.knwf (52.0 KB)

4 Likes

@AnotherFraudUser that’s brilliant, and I like how you matched seq to the rules.

I have a feeling that if I asked you to write a single node solution to having the workflow pour me a beer, it would still involve nested replace commands! :joy: I’m going to take a break now, while I consider how to make this sufficiently even more devious that this method won’t work! :wink:

The trouble is, I don’t want to be prescriptive in saying you can’t do (other than disallowing specific nodes), as the whole point is to see what imaginative ways people come up with. But I do have a solution that doesn’t directly use replace(replace(replace... )) , although it does still use the replace command a few times. I won’t post it though for the moment. I’ll just leave that thought out there.

On the <cough>Alteryx</cough> forum, they have (or had - I’m talking a couple of years ago) a weekly puzzle type question which was a nice way to get people thinking about unusual solutions. It got me thinking that maybe there ought to be an area here for such things.

(glad to hear it improved your train ride!) :slight_smile:

2 Likes

Brilliant @AnotherFraudUser .

@AnotherFraudUser @takbb , I was trying to find a way to “map” A=>e, B=>t, etc… just could not get to it. Even looking at what @AnotherFraudUser did, I could not see it, until I broke what @AnotherFraudUser into pieces to finally understand it. That’s brilliant and makes so much sense the way it was done. I just could not think that way - and yes the same would work for the first 2 cases.

@takbb , is your solution the same as @AnotherFraudUser , or is there yet another way to do this? :slight_smile:

2 Likes

Hi @AnotherFraudUser , just checked your solution for case 3 (ODDly made EVEN harder), again, brilliant!!

@takbb , brilliant from you too for coming up with such puzzle, and even more genius for coming up with the different versions/challenges of it. :+1: :+1: :+1: :+1:

2 Likes

Hi @bruno29a, no my solution takes a slightly different approach, but using the same node. It’s a technique I saw used on the forum, but I can’t find it in the documentation… Certainly its not mentioned in the node’s description as far as I can see. Which is actually why I came up with the idea of setting the puzzle… As I wanted to see how widely known it was.

… But I haven’t yet found a way of forcing the use of the technique I have… I’m determined to find a way before revealing it :slightly_smiling_face:

It’s great to see other inventive ways though. Always useful to have these ideas for future use.

1 Like

Hey @takbb , given the restrictions by the rules, I think it’s the only node we can use. I look forward to see how you did yours.

2 Likes

Only for @bruno29a a dictionary / mapping solution
and for @takbb a solution without replaces (okay regex replace…but only one :smiley: )

A fun little puzzle for the weekend - ODDly made EVEN harder (regex dictionary).knwf (52.9 KB)

Took quite a bit to figure out that KNIME needs an addtitional escape for the matching group backreference :sob:

Somewhat readable example how the regex is supposed to work:

But could not figure out how to call an external service from the string manipulation node - so pouring a beer failed :stuck_out_tongue:

2 Likes

I feel like I’m one of those clients, where every time you come up with a solution, the question gets changed…

@AnotherFraudUser … disappointed about the beer mate! :wink: Cool use of regex though - I’ll be studying that one for a while - and you found the mechanism for finding even numbers using Regex that I was thinking of.

@bruno29a , as far as I know you are correct about this being the only node available… and I will reveal my code at some point, but I’m interested to see if anybody comes up with the same technique… I only knew it existed from something somebody posted on the forum some time in the past month or so.

(and I might leave this for the coming week to give a chance for anybody else to have a go at coming up with it) - provided of course it doesn’t get in the way of work!

Before all that though… I give you the “Party Animals” version. So new rules (quelle surprise!)…

The data is essentially the same as before, but this time the letters A,B,C and D have been replaced by the name of something from the animal kingdom. This is hopefully going to test ingenuity once more, although I think @AnotherFraudUser will still manage to beat me!

I think it fair to say that everybody is free to build on any ideas/workflows submitted so far, if it helps. That’s not cheating/stealing… it’s knowledge-building… So don’t hold back!

I think I’ll make this my last version, as I’m running short of ideas to try, so if you beat me this time, you’ve won!


The ODD and EVEN rules still apply, but I have added the following rules, and modified the previous workflow and data accordingly:

In this version the “selected” column doesn’t contain A,B,C or D.
It contains a type of animal/creature. I use the term “animal” below which basically means any creature.

All begin with the letter A. All names are in “Title” case, so every word begins with a capital, and all other letters are lower case.

If the type of animal is (using string comparison rules) less than the string “African Grey”, then it equates to “A”

If the type of animal does not equate to A, but (using string comparison rules) is less than the string “American”, then it equates to “B”

If the type of animal does not equate to A or B, but (using string comparison rules) is less than the string “Archer”, then it equates to “C”

If the type of animal does not equate to A, B or C then it equates to “D”…

You may include the “cut off” strings “African Grey”, “American” and “Archer” in your solution, but you may not hardcode the full name of any creature!

(Assume you have no prior knowledge of the specific animals used)

It may still be possible using similar to something already posted, which is an acceptable solution, if it works. All I will say is that there is another way!

The list of creatures I’ve used come from the following set (I haven’t necessarily included every creature listed here), but you are not allowed to include the full name of any creature. You are alowed to use the three “cutoff” strings which are all partial creature names.

Aardvark
Aardwolf
Adelie Penguin
African Bush Elephant
African Grey Parrot
African Wild Dog
Albatross
Alligator Snapping Turtle
Alpaca
American Alligator
Amur Leopard
Angel Shark
Anglerfish
Anteater
Antelope
Archerfish
Arctic Fox
Arctic Hare
Armadillo
Axolotl

Good luck! :slight_smile:

A fun little puzzle for the weekend - Party Animals version.knwf (55.0 KB)

2 Likes

Hi @takbb,

I guess I could do it again with the dictionary logic - but to narrow your solution down - this time with a different way :slight_smile:

A fun little puzzle for the weekend - Party Animals version.knwf (58.5 KB)
(could be done cleaner but got a bit lazy :sleeping: )

Could be against the “Java of any sort” rule - but would match your hinted “undocumented behaviour”.
Does your solution go into the same direction? Maybe just with less java but more toInt/toBoolean / calculating with Ints/booleans?

2 Likes

Hi @AnotherFraudUser , congratulations… yes that’s the type of thing… And yes I know I said not “java of any sort” :thinking: but that was in reference to the specific language scripting nodes… but you are right it does come from Java , but it appears to be (from what I have found, but no doubt there is a page devoted to it somewhere) relatively undocumented.

For anybody else wishing to google it, it is properly called the “java ternary operator” and here it allows you to turn String Manipulation into a remarkably flexible Rule Engine…

As you have now beaten me yet again… I think I can now post my copy of the solution for this version.

A fun little puzzle for the weekend - Party Animals version-takbb.knwf (57.5 KB)

2 Likes

Hi @takbb,

great to hear! :partying_face:
Thanks again for the puzzle - your additions to the tasks were well done to lead to the solution!
Also your solution workflow is nicely done - cleanly and easy read :+1:

I think there is no documentation for this feature - at least I never saw any…without looking into the source code of the node - I would guess that the math formula, rule engine, string manipulation and column expression node (and maybe the java snippet nodes) share some of the backend logic/parser. I think these operators / as well as a few functions were never intended to work by the developer :stuck_out_tongue:
But like you said - quite handy to know for the next complex string maniplulation tasks :grin:

2 Likes