Can you crack the Black Box?
Hi, Community!
And so I continue with publishing of the tasks for the Final round of InterSystems Contest on InterSystems Caché and DeepSee as a part of IT Planet Student Championship in Sochi. This year we had about 2 000 participants in InterSystems Contest.
One of the tasks for the finals was to crack the black box!
Problem description
First of all, download and import the black box:
write ##class(%Studio.Project).InstallFromFile("BlackBox.xml")
Black Box has only one class - ITPlanet.BlackBox and one method - Main. If you call it from a terminal:
write #class(ITPlanet.BlackBox).Main()
it would throw an exception. However, if you call it just right, it would return something slightly more meaningful.
But what? And how do you need to call it?
Not the most creative output:
@Eduard, I'm assuming you don't want spoilers here beyond that?
One non-spoiler: there are actually two valid options for the first argument that will produce this output.
That was fast.
Yes, for now.
I don't know how close my version of this method to the original, but it should be something like this. But I think, your version a bit bigger.
ClassMethod Main(cfg As %SystemBase, mode As %String) As %String { set trantabla=cfg.trantable set str="" set list=$listbuild(72,101,108,108,111,32,87,111,114,108,100,33) for i=1:1:$listlength(list) { set n=$listget(list, i) set hex = $zhex(n) set str = str _ "\u" _ $extract("000" _ hex, *-3, *) } set str=$zconvert(str, mode, trantable) set:$length(str)'=12 str="????? ??????" quit str }
How do you propose to store static strings?
Btw, it was a good idea, to deploy code. But I think bad idea to hide original string in $ListBuild
Because, such static variables, stored as is in OBJ code, and could be easily recognized.
maybe something like this
or another way a bit easier to decode, I think
The solution:
USER>w ##class(ITPlanet.BlackBox).Main({"trantable":"JSON"},"I") Hello World! USER>w ##class(ITPlanet.BlackBox).Main({"trantable":"JS"},"I") Hello World!
Social networks
InterSystems resources
Log in or sign up
Log in or create a new account to continue
Log in or sign up
Log in or create a new account to continue
Log in or sign up
Log in or create a new account to continue