"Could you repeat yourself?" aka Could a doubled character solution exist in JavaScript?

10

0

This thinking exercise is inspired from Super Chafouin's question "Just Repeat Yourself" in which the phrase "Do not repeat yourself!" had to be outputted using code that was basically a series of doubled characters, inclusive of newlines, so code like:

((zz==0011))&&((mm++&&mm++&&mm++&&mm++&&mm++&&nn--&&nn--&&nn--&&nn))

would be considered valid code.

It got me thinking, is a JavaScript solution possible? Now at this point in time, I'm no longer concerned with putting in a competing entry for Super Chafouin's question, there's a lot of entries in there far better than anything I could have come up with in that short a period of time. I'm looking at this from the perspective of a programmer who loves what he does and wants to see how far he can push the limits...

So that being said, JavaScript conforming to the rules makes for some rather difficult challenges... No modulo, no bitwise operations, standard concatenation and arithmetic functions are rendered useless save for ++ and --, and standard assignments as far as I know are thrown out the window.

Numbers and booleans are a little easier, I managed to work out the following using Chrome and ES7.

neg_two = --[[]][[00]]<<++[[]][[00]] // neg_one << one
neg_one = --[[]][[00]]
neg_half = ((--[[]][[00]]<<++[[]][[00]]))**((--[[]][[00]])) // neg_two ** neg_one
zero = 00 // octal representation
third = ((0011**((((++[[]][[00]]<<++[[]][[00]]))**((--[[]][[00]]))))))**--[[]][[00]] // (nine ** (two ** neg_one)) ** neg_one
half = ((++[[]][[00]]<<++[[]][[00]]))**((--[[]][[00]])) // (one << one) ** neg_one
one = ++[[]][[00]]
two = ++[[]][[00]]<<++[[]][[00]] // one << one
three = 0011**((((++[[]][[00]]<<++[[]][[00]]))**((--[[]][[00]])))) // (nine ** (two ** neg_one))
four = ++[[]][[00]]<<++[[]][[00]]<<++[[]][[00]] // one << one << one
five = 11>>++[[]][[00]] // eleven >> one
six = 0011**((((++[[]][[00]]<<++[[]][[00]]))**((--[[]][[00]]))))<<++[[]][[00]] // (nine ** (two ** neg_one)) << one
seven = ((99>>++[[]][[00]]))**((((++[[]][[00]]<<++[[]][[00]]))**((--[[]][[00]])))) // (99 >> one) ** (two ** neg_one))
eight = ++[[]][[00]]<<++[[]][[00]]<<++[[]][[00]]<<++[[]][[00]] // one << one << one << one
nine = 0011 // octal representation
ten = ~~((1100**((((0011**((((++[[]][[00]]<<++[[]][[00]]))**((--[[]][[00]]))))))**--[[]][[00]])))) // ~~(1100 ** ((nine ** (two ** neg_one)) ** neg_one))
eleven = 11 // decimal representation
twelve = 0011**((((++[[]][[00]]<<++[[]][[00]]))**((--[[]][[00]]))))<<++[[]][[00]]<<++[[]][[00]] // (nine ** (two ** neg_one)) << one << one
_false = !!00
_true = !!11

Beyond that I'm at a loss, because if I did want to output the target phrase, I would need some form of concatenating a string to another, and I would then be able to basically chain strings with array references to extract the individual characters and so on...

Bearing this in mind, strings are a bit of a loss (so I believe, I may be mistaken), ``, "" and '' won't really do much as you can imagine. I'm not sure about the validity of control characters, like \0 or literal \n, \t, \r for example...

So for the purposes of this thinking exercise... providing thoser control characters and escape sequences were okay, is there anything more that one could do to get closer to a solution of assigning values, concatenating strings, coercion, etc.?

Please note, as I said earlier in the post, this is not to finally put in an entry for the originating question... I just want to see how far one could take this rule with JavaScript and what you could potentially do...

WallyWest

Posted 2016-09-29T03:47:47.390

Reputation: 6 949

Question was closed 2016-09-29T14:30:02.120

7I think this really should of been posted as a bounty on the original question rather than a seperate language specific post – Downgoat – 2016-09-29T03:57:26.800

@Downgoat If I knew that was permitted, i probably would have. I'm going to be placing a bounty on this question nevertheless. – WallyWest – 2016-09-29T04:03:16.737

1The place for discussions is chat, not main. I suggest creating a chat room, linking it from the comments of the original question, and deleting this one. – Peter Taylor – 2016-09-29T07:41:04.583

1

@PeterTaylor If you look at the first two sentences of this similar question `This is not a challenge but a question, I figured it was on topic because of

Non-challenge questions that are related to solving programming puzzles or a particular type of challenge are also on topic.` I think this is a perfectly fine question, not a dupe.

– James – 2016-09-29T15:20:19.477

I'm going to try taking this to a chat room. Not sure if that functionality is available from the phone app... – WallyWest – 2016-09-29T19:32:12.500

1@WallyWest I don't think this is possible. You'll need to represent strings, but you can't cast to string with a regular ol' +. I've tried my hand at this for an hour, no luck. (My personal luck with numbers gave ~~"" for zero a la JSF.) – Conor O'Brien – 2016-09-30T13:09:22.893

@ConorO'Brien You've just earned that 150 point bounty i posted in the originating question. Do me a favor, post an answer response in the originating question with respect to JavaScript and how it won't be possible for the reasons you've mentioned. I'll award that bounty to you for trying to answer this question for me. Thanks! – WallyWest – 2016-09-30T13:16:42.333

@WallyWest I put the info in this answer.

– Conor O'Brien – 2016-09-30T13:46:18.103

No answers