go to post Paul Waterman · Feb 19 There is only one person who can answer what the expected result should be. I think Eduard made it clear by providing the tests that should pass. TestStartMiddleRight - this is the same as the my test starting at DTestStartBottomLeft - this is the same as my test starting at G My other tests were based on simply rotating the matrix - I was not happy that my code was passing those two tests but could still be wrong, in my opinion, starting at the bottom middle of the grid. My last go at this is 212. I hope the next hole is not as controversial.
go to post Paul Waterman · Feb 18 Stuart, neat but not complete. The initial tests say bottom left start goes up. On the following test: Set matrix($INCREMENT(matrix)) = "A,B,C" Set matrix($INCREMENT(matrix)) = "H,I,D" Set matrix($INCREMENT(matrix)) = "G,F,E" d $$$AssertEquals(..Solution(.matrix, 1, 1), "ABCDEFGHI") d $$$AssertEquals(..Solution(.matrix, 1, 2), "BCDEFGHI") d $$$AssertEquals(..Solution(.matrix, 1, 3), "CDEFGHABI") d $$$AssertEquals(..Solution(.matrix, 2, 3), "DEFGHABI") d $$$AssertEquals(..Solution(.matrix, 3, 3), "EFGHABCDI") d $$$AssertEquals(..Solution(.matrix, 3, 2), "FGHABCDI") d $$$AssertEquals(..Solution(.matrix, 3, 1), "GHABCDEFI") d $$$AssertEquals(..Solution(.matrix, 2, 1), "HABCDEFI") Yours fails when starting on E,F,G,H. I have tidied up mine and got rid of the mess of gotos at the top and assumes the matrix is not empty, current score 214.
go to post Paul Waterman · Feb 18 Hi Stuart, I did not publish my solution because I thought 231 sounded a bit embarrassing for this game. 227 sounds in the same league so I am happier now. I also applied the "what would Stuart do?" theory to my shot, and what do you know: 227. ClassMethod Solution(ByRef n, r, c) As %String { s (a,p)=$g(n),b=1,q=1,o="" g:c=1 4:r>1 g:c=a 3:r=p,2 g 3:r=p 1 s e=0 F c=c:1:a{d m} S q=$i(r) 2 F r=r:1:p{d m} S c=c-1,a=c 3 F c=c:-1:b{d m} S r=r-1,p=r 4 F r=r:-1:q{d m} S b=$i(c) g:e 1 q o m S o=o_$P(n(r),",",c),e=1 }
go to post Paul Waterman · Feb 18 Hi Julius, This interpretation makes things easier to understand - I am not sure how it impacts the program. However it does not match the test cases. In the test TestStartMiddleRight all letters are used apart from C. In your example above, starting at (3,4), I think this means use all letters except d and e. TestStartBottomLeft also uses all of the grid, which I think your interpretation does not. Although you do not show what you expect when your starting point is in a corner. These two tests are, I think, making up most of my program: working out which direction you are facing at the start and then making sure you go to the edges you have not covered yet. But its also what makes starting in the middle so hard: what direction to start walking? I think this interpretation would require a different program to mine.
go to post Paul Waterman · Feb 17 I am finding this quite a challenge. I have made the following assumptions, based on comments from others: The array will always have N at the top. The data will always be square. The bottom left test is corrected to Solution(.matrix,3,1) You can only start on the edge of the square (first or last row/column). I am not sure what starting in the middle of a 5x5 grid would mean.. My program misses/re-uses some data. Starting in the middle of an edge will miss any bits that are anti-clockwise (this is covered in the test: Solution(.matrix, 2, 3)="DEFGHABI" which misses the C) An empty/N=0 array returns "", although the initial requirement says n>=1, so could save a few chars there. My solution is 231.
go to post Paul Waterman · Oct 31, 2023 The way I would gather the globals the process looks at would be to slip something into the logon code that traced all the $zr changes to a trace file. Its not exactly what you asked for as it wouldn't be on a different process. s %oldzr="" zbreak /trace:all:"/durable/trace.log" zbreak $:"T":"%oldzr'=$zr":"s %oldzr=$zr w $zr" d ..yourthing() You could try to %Studio.Debugger Attach to the user's process and do a similar thing.
go to post Paul Waterman · Oct 23, 2020 But will it use a name or age index? Age index bad example but hey. Sqlquery is a class so you can extend/replace it. We came up with a syntax where the sql would generate based on the parameters. So you could do SELECT TOP 5 ID, Name, Age, SSN FROM Sample.Person WHERE 1=1 --If Name'="" And Name %STARTSWITH :Name --endif --if Age'="" AND Age >= :Age --endif
go to post Paul Waterman · Mar 14, 2018 There is a directory somewhere in windows that stores temporary files for studio.Could be this has old versions of some classes.I had a similar problem when doing bulk code changes on xml files.Shut down studio. Delete the dir. I can' remember where it is. It's 3am. When I really wake up I will find it.
go to post Paul Waterman · Nov 12, 2017 You should be able to get the trigger to work with object %Save:Trigger OnUpdate [ Event = UPDATE/DELETE, Time = BEFORE ,Foreach = row/object ]
go to post Paul Waterman · Nov 9, 2017 Could you pretend to be the compiler and run the generator method? Might be a problem if the method does anything other than generate code.Class temp.proc{ClassMethod showcode(classname, methodname){ n %class,%code,%method,%compiledclass,%compiledmethod,%parameter s %compiledclass=##class(%Dictionary.CompiledClass).%OpenId(classname) s %compiledmethod=##class(%Dictionary.CompiledMethod).%OpenId(classname_"||"_methodname) s generatorclassname=%compiledmethod.Origin s %class=##class(%Dictionary.ClassDefinition).%OpenId(classname) s %method=##class(%Dictionary.MethodDefinition).%OpenId(generatorclassname_"||"_methodname) s key="" f { s param=%compiledclass.Parameters.GetNext(.key) q:key="" s %parameter(param.Name)=param.Default } s %code=##class(%Stream.MethodGenerator).%New() s exec=" d "_methodname_"^"_generatorclassname_".G1(%class,%code,%method,%compiledclass,%compiledmethod,.%parameter)" x exec d %code.Rewind() w %code.Read()} I am not sure if all the variables here are set correctly, or if the generator code always ends up in a G1 or even if this is a good idea, was just thinking.This is not code I have used before.