This site uses different types of cookies, including analytics and functional cookies (its own and from other sites). To change your cookie settings or find out more, click here. If you continue browsing our website, you accept these cookies.
inner iterative. The workflow works with all the example inputs. With the actual input, it fails. Somewhere. But gets close enough -- after some fruitless debugging I thought there were just one or two packets missing, and luckily it was true as the output was just 7 points shorter (some faith and some trial and error proved that 😅).
The hierarchy is all messed up (stored in recordID), so no way I can tackle part 2 as it stands... number_dec 8 RecordID 188.8.131.52.184.108.40.206.220.127.116.11.18.104.22.168.22.214.171.124.126.96.36.199.188.8.131.52.184.108.40.206.220.127.116.11.18.104.22.168.22.214.171.124.126.96.36.199.188.8.131.52.184.108.40.206.1 version 0 type 4 children
WOW - that took a day to figure out an approach and to execute. To be fair to the problem, I'm not a speed-developer like @NicoleJohnson . This is another one of these problems that would be much easier to solve in a single pass using recursion, but Alteryx doesn't have this yet.
Fun part of this was that I got to use something I learned a while ago from @patrick_digan - the Dynamic Replace, and it's ability to create code that can be created & executed dynamically.
OK - here's the recipe I followed: Step 1: Hex to Bin - did this in a separate macro Step 2: Lex out the operators into a list - i.e. convert the binary stream into a list of operators and literal values Step 3: iteratively process this list of operators, working from the bottom of the tree upwards (sorta like working from the inner-most brackets outwards) - The way I did this was to start at the bottom of the tree - for example look for things like Greater Than followed by 2 literals) - Work out the result of this leaf - Replace all the rows that were part of this calculation into just 1 row which is a literal - Repeat Step 3a: - to do the "work out the result" piece - dynamically created a quick formula - and then used Dynamic Replace to execute it.
For example: Operator Sum Operator Literal 3 Operator GreaterThan Operator Literal 15 Operator Literal 3 Operator Literal 2
The italic bits now resolve down to a single line which is a literal Operator Sum Operator Literal 3 Operator Literal 1 Operator Literal 2
Then you do Sum and this collapses to Operator Literal 6
which is the answer.
Then the lexer
Then the part that iteratively solves the tree
And finally the piece that executes the calculations
Part 1 is completed accidently...i just try and error.
but to complete part two, take of 90% of time to built the nice Tree for numbering, operator and Len. look good but quite useless 😅
luckily the length set is exactly same without any dispose digit, if not it will take 2 more week.
with this nice tree, I can do part 2 easily.
thank @SeanAdams for the workflow. so that i can realise i very close to the correct answer. thank @patrick_digan for mention the sign issue in BintoInt conversion, just a steps to the correct answer. i was thought a ABS function will solve the issue.