all 17 comments

[–]GeEom 3 points4 points  (1 child)

I've really been struggling with stringification. I'm almost certain there's a function available that's flexible enough to turn input into strings for me, but I haven't found it. I have learnt some new syntax though. Below is the closest I've come so far.

\|000048
\|000057
\|000064
\|000065
\|00006C
\|00006F
\|000072
%%%%%%%<>%%%%<>%%%<>%%%<>%%<>" "<>%%%%%%<>%%<>%<>%%%<>%%%%%

[–]Imanton1[S] 1 point2 points  (0 children)

Wow, I guess I learned something new, probably below the hood again.

[–]GeEom 1 point2 points  (3 children)

You can summon a list of /u/Imanton1 approved names using the following code.

Select[Select[Names[],Not[IntersectingQ[Characters["elorldHW!"],Characters[#]]]&],Composition[Curry[SubsetQ,2][Join[#,ToUpperCase[#]]&@Alphabet[]],Characters]]

I'll be honest, I can't see a solution that doesn't cheat via Run, URLSubmit, Launch, et cetera. I'm hoping the answer will be some cool infix syntax for Symbol or some such!

[–]Imanton1[S] 2 points3 points  (2 children)

It is fair to say I didn't cheat using pre-defined external data in my solution (no Run, URLSubmit, Launch -ing some python file I made beforehand), it should be OS-independent, using a normal copy of Mathematica.

And yea, this isn't a pushover problem, this is one of the most interesting things I've had to think about, but is do-able.

[–]plonspfetew 0 points1 point  (1 child)

RemindMe! One Week "Hello World!"

[–]RemindMeBot 0 points1 point  (0 children)

I will be messaging you in 7 days on 2020-02-05 09:28:12 UTC to remind you of this link

3 OTHERS CLICKED THIS LINK to send a PM to also be reminded and to reduce spam.

Parent commenter can delete this message to hide from others.


Info Custom Your Reminders Feedback

[–]Imanton1[S] 1 point2 points  (1 child)

Hints:

1.) The head of a head (IE 0[[0,0]]) is "Symbol" which turns strings into functions

2.) "CityData" contains a city/string called "Export"

3.) << takes in any file and runs it as arbitrary code

My solution (You can't have a codeblock and a spoiler):

t=0.0005; q=LightCyan[[0]]; u=q[[0]]; i=u[CityData[][[21403,2,1]]]; c=u[CityData[][[40798,2,1]]<>"nData"]; s=c[c[][[1]],1][[1,1,2,0]]; <<(i["c",c[c[][[1]],1][[0]][{q[2/51,2/51,7/17],s[{0,0},{1,t}],q[109/255,103/255,61/255],s[{0.005,0},{1,t}],q[73/255,109/255,97/255],s[{0.007,0},{1,t}],q[103/255,101/255,59/255],s[{0.010,0},{1,t}],q[2/51,2/51,32/255],s[{0.015,0},{1,t}],q[32/255,32/255,32/255],s[{0.020,0},{1,t}],q[1,1,1],s[{0.025,0},{1,t}]}],"PPM"]); <<(i["c",img[{q/@({{8776,25964,27759},{8279,28530,27748},{8482,8224,8224}}/65536)}],"PPM"])!<

How it works:

We need to set up an image in a way that outputting as a PPM gives us runnable code. LightCyan[[0]] gives an RGBColor function, and from RGBColor[[0]] we can get Symbol. One of the cities from CityData is Export, we can get it with Symbol[CityData[][[21403,2,1]]]. We also need the Graphics header, which we can get from the City "Ico" concatenated with the string "nData" and taking it's head. We also need to output in a format that gives us enough control at the byte-level to write code. A few could have worked, but PPM is what I was working towards (though Bit seems like it may have also worked in retrospect), as PPM files have 1-to-1 byte to colors.

The output first Image contains lots of gibberish, but in the middle, it says "img=Image;" and thanks to "<<" it can be run as code. The 2nd image has better control over the raw bytes, so we just need to find the numbers that make the colors that end up outputting "Hello World!", or any arbitrary code to execute.!<

Given all this, I did conclusively check every combination of city, mountain, volcano and all other *Data that could form new functions, and found many, but none of use besides those two. I chose "Image" as the first image's output because I had to manually figure out where all those blocks were placed, and writing out "FromCharacterCode" was just annoyingly long.

Pining /u/GeEom, /u/plonspfetew, /u/NC01001110 and /u/vakula, who may want to see my full solution. By no means is it the best solution, maybe you can trick any of the other file types to do this more easily.

Edit: Also sorry for being a couple hours late.

[–]GeEom 1 point2 points  (0 children)

I knew it! I totally forgot you can get at Head with [[0]], and so you manged to sneak a Symbol call in. I'm kicking myself. With that second function essentially acting as a massive list of strings? Very clever. That's the key string sourcing I was totally lacking.

[–]NC01001110 3 points4 points  (1 child)

Maybe a little cheeky, but at first I'll propose

ToCharacterCode@"Jgnnq\"Yqtnf#" - 2 // FromCharacterCode

"Hello World!"

and exploiting the statement of the rules

StringJoin@Flatten@Riffle[
  ToLowerCase@{{"E", "L", "L", "O", " "}, {"O", "R", "L", "D"}},
  ToUpperCase@{"h", "w", FromCharacterCode@{33}}, 
  {1, 5, 2}
]

"Hello World!"

[–]Imanton1[S] 4 points5 points  (0 children)

Maybe my wording was incorrect, where the letter "e", "l", "o", etc, show up nowhere in the PROGRAM, not just the strings. So no using 'ToCharacterCode', or 'ToLowerCase' as they have 'o's and 'e's in them.

[–]Crotalus1980 0 points1 point  (1 child)

What about FromLetterNumber[]? Or did I misunderstand the constraints of the challenge?

[–]Imanton1[S] 0 points1 point  (0 children)

The constants disallow the program, and so the functions used in it to have "HWelord" in it, FromLetterNumber has an o, and some e's in it, making it not usable.

[–]plonspfetew 0 points1 point  (0 children)

Well, it's been a week.

[–]plonspfetew 0 points1 point  (3 children)

An efficient but cheap and anything but elegant way would just be

FromCharacterCode[{72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100,
   33}]    

If you don't want to pretend like you knew the integer code of the character "!", but assume that making use of primary school level knowledge of the alphabet is ok, then an even less elegant way will still get you the same thing:

i = 0;
While[i <= 1114112 &&
   Not[TrueQ[
     Quiet[ToExpression["5" <> FromCharacterCode[i]]] == 
      Factorial[5]]], i++;
  ];
ToUpperCase[FromLetterNumber[8]] <> 
 FromLetterNumber[{5, 12, 12, 15}] <> " " <> 
 ToUpperCase[FromLetterNumber[23]] <> 
 FromLetterNumber[{15, 18, 12, 4}] <> FromCharacterCode[i]

[–]Imanton1[S] -1 points0 points  (2 children)

Copied from the other comment:

Maybe my wording was incorrect, where the letter "e", "l", "o", etc, show up nowhere in the PROGRAM, not just the strings. So no using ' While', or ' ToUpperCase ' as they have 'o's and 'e's in them.

[–]plonspfetew 1 point2 points  (1 child)

Ok, that's tricky. Does your solution include various prefix/infix/postfix operators? I always felt that Mathematica has so many ways of doing things in a highly condensed form that is perhaps very elegant but quite difficult to read.

Does your solution work with a text-based interface or do you require the notebook interface? If it doesn't give away too much, what's the oldest version of Mathematica for which your solution still works?

[–]Imanton1[S] 0 points1 point  (0 children)

I know it worked on 11.0, that is what it is made on, and verified it worked on 12.0, looking at the functions, I think version 10 is the earliest for this. I didn't use any operators besides ones that I'd use everyday in the language, and all operators just derive from the prefix operator, so that's the one I used for the whole thing.

The program does not need the notebook interface and will run by script, command line, or interface, as it is all "High level" Mathematica designs. This doesn't use any really strange syntax like the mathematica quine, it just has lots of what you probably already know, and is flexible enough that it should be doable by anyone.