Any Ruby devs here? Need a line of T-Shirt code translated

CodePoet

Fractal Fanatic
Was looking for the result of this code that's on a friend's T-Shirt. Can anyone assist? I think it's Ruby code, although I'm not sure about it.

Never_Underestimate_a_Girl_Who_Can_Code == ["\\\×D7\xAFz\xBDT\x9D\×D7\xABz\xCBb\x99\xAB^\×D5\xADF\x8A\xB9uZ\x1A5\t\×A9\xF5\n\x87^"].pack('m0')[1..].gsub(/\d/,'_')

Tried pasting into some online Ruby compilers and after a bit of tweaking (removing the "[1..]"), I'm getting the below, which is repeating most of the variable name back perhaps with some encoded characters, but it seems a bit strange. I see that the pack('m0') function is supposed to encode into Base-64 I believe but decoding that is odd as well. Thanks for any help!

XMOXRDever_UncOXRDerestimatew_dENa_Girl_Who_CcOXQTn_Code
 
I would guess the purpose of the range operator, which seems to be garbled, is to strip out all the extraneous characters from the base64 encoding. How sure are you that you transcribed it correctly?
 
  • Like
Reactions: rog
I would guess the purpose of the range operator, which seems to be garbled, is to strip out all the extraneous characters from the base64 encoding. How sure are you that you transcribed it correctly
I think it's right - I've checked it twice. Photo is below for reference.

Running it in Ruby compilers online, I get a syntax error on the [1..] piece, which looks suspicious to me as well. And unless someone is being deviously non-PC, I'm thinking that returning a syntax error can't be the intent, no matter how funny that could be. Removing that [1..] piece, I get the results mentioned above - it seems it's returning some version of "Never Underestimate a Girl Who Can Code". So is it just a complex way of building that string, or is there something else to it?

Beyond that, I'm wondering how they're returning that long string with what seems to be much fewer escaped characters specified.

Or that the person who made the t-shirt got it right.
That could be it as well...

Ruby Shirt.jpg
 
Not sure if it's Ruby as I have no practical experience but == is a comparison operator in Ruby, not an assignment operator.

Changing to = and then printing the result gets the same as what you were seeing:

Code:
Never_Underestimate_a_Girl_Who_Can_Code = ["\\\×D7\xAFz\xBDT\x9D\×D7\xABz\xCBb\x99\xAB^\×D5\xADF\x8A\xB9uZ\x1A5\t\×A9\xF5\n\x87^"].pack('m0')[1..].gsub(/\d/,'_')
puts Never_Underestimate_a_Girl_Who_Can_Code

That was using this link and selecting Ruby instead of python:

https://www.onlinegdb.com/online_python_compiler

I did try and run it under a different online Ruby compiler but it got a syntax error due to the missing range end, I assume.

It appears to be assigning a single element array consisting of a string of primarily HEX characters (there is a Tab and a Newline in there, too) which is base64 encoded (without a line terminator).

Of that array, it is taking a subset of elements globally changing digits to '_'.

I wasn't able to find any evidence that the range operator allows for the range end to be optional...

In any case, the range starts from the 2nd element since arrays are indexed from 0.

Anyway, it was an interesting challenge ;)
 
I wrote in Ruby for years and it’s definitely not syntactically correct.

[1..] isn’t valid when slicing a String, at least when I was writing in it, so I suspect whoever made the shirt was not serious at all.
 
Beyond that, I'm wondering how they're returning that long string with what seems to be much fewer escaped characters specified.
Because it's HEX not ASCII, I think.

This:

Code:
puts ["\\\×D7\xAFz\xBDT\x9D\×D7\xABz\xCBb\x99\xAB^\×D5\xADF\x8A\xB9uZ\x1A5\t\×A9\xF5\n\x87^"].pack('m0')

Returns this:


Code:
XMOXRDever1UncOXRDerestimatew5dENa1Girl1Who1CcOXQTn1Code
I think somebody's playing some games with translation.

It seems like a poor attempt to appear clever :D
 
I think it's right - I've checked it twice. Photo is below for reference.

Running it in Ruby compilers online, I get a syntax error on the [1..] piece, which looks suspicious to me as well. And unless someone is being deviously non-PC, I'm thinking that returning a syntax error can't be the intent, no matter how funny that could be. Removing that [1..] piece, I get the results mentioned above - it seems it's returning some version of "Never Underestimate a Girl Who Can Code". So is it just a complex way of building that string, or is there something else to it?

Beyond that, I'm wondering how they're returning that long string with what seems to be much fewer escaped characters specified.

The purpose of the range operator is to remove the extraneous characters, and the gsub will put in the underscores. However, much of the range operator is missing in your photo. I would guess there probably was a working original version, but the version in your photo is missing most of the range operator. The person who made the shirt probably doesn’t know ruby :).
 
Appreciate the insight here guys! Just curiously, how are they seeming to build the string of "Never_Underestimate_a_Girl_Who_Can_Code" when there don't seem to be enough characters specified? i.e. \×D7 refers to just one escaped character, yes?
 
Appreciate the insight here guys! Just curiously, how are they seeming to build the string of "Never_Underestimate_a_Girl_Who_Can_Code" when there don't seem to be enough characters specified? i.e. \×D7 refers to just one escaped character, yes?
See my last post...

The string is
Code:
\D7AFzBDT9DD7ABzCBb99AB^D5ADF8AB9uZ1A5\tA9F5\n87
and converted to HEX results in this
Code:
5c 44 37 41 46 7a 42 44 54 39 44 44 37 41 42 7a 43 42 62 39 39 41 42 5e 44 35 41 44 46 38 41 42 39 75 5a 31 41 35 5c 74 41 39 46 35 5c 6e 38 37
.

The initial string has more characters than "Never_Underestimate_a_Girl_Who_Can_Code"
 
Appreciate it guys - we probably spent more time than its worth. I thought perhaps they were creating a decoded base-64 version of the string and then when encoded it made the string they were building, but putting those things into a base-64 encoder didn't yield the right results either. I think that's what they must be going after. Oh well. Perhaps the shirt just isn't quite correct or some different character set is being used.
 
Appreciate it guys - we probably spent more time than its worth. I thought perhaps they were creating a decoded base-64 version of the string and then when encoded it made the string they were building, but putting those things into a base-64 encoder didn't yield the right results either. I think that's what they must be going after. Oh well. Perhaps the shirt just isn't quite correct or some different character set is being used.
It is correct in base64. I think you're missing the essential point about the range operator. The person who made the shirt didn't understand this important point either :).
 
It is correct in base64. I think you're missing the essential point about the range operator. The person who made the shirt didn't understand this important point either :).
That compiler used by @unix-guy accepts the [1..] nomenclature, so perhaps it's valid in some flavors of Ruby? I have no idea.

So we're all agreeing that their code should be returning "Never_Underestimate_a_Girl_Who_Can_Code" but something is a bit off that's making it not quite right?
 
I respectfully disagree. I think the extraneous characters are intended to be there. And the range operator is intended to remove them. The problem is the range operator is garbled. That's just a guess though.
 
Last edited:
I'm thinking there's perhaps a typo(s) in their encoded string that's therefore generating a wrong thing once decoded.

Regardless, whoever put this shirt together to encourage female coders has failed to help them out in this case.

Thanks for the help everyone!
 
I don't think so, no. I think the extraneous characters are intended to be there. And the range operator is intended to remove them. The problem is the range operator is garbled. That's just a guess though.
I don't think so... The range only specifies the start and end characters from the string but there's "junk" in the middle of the string, too.

The current result is this:

MOXRDever_UncOXRDerestimatew_dENa_Girl_Who_CcOXQTn_Code

If we take each "piece of junk" out we see a single missing letter for each:

Xever_UnXerestimateXa_Girl_Who_CXn_Code

I think it's just a botched "conversion"...

Of course, that's also just a guess ;)
 
Back
Top Bottom