You certainly could if you wanted, but remember that digital computers already do so natively.
This behavior, however, is not relevantly exposed in raw Excel 2003 (without use of VBA at least), but MS Windows' calc.exe could be a different story.
Still, you might want to continue with that line of thought.
Is CHTBI the only possible combination for LOSHAK & ESCAZU? Is it simply a constraint?
Using the Roman alphabet, one could conceivably argue that one other such combination (differing only in the addition of a single letter) would be valid.
The title lead me in the direction of converting each string to a binary. The use of & in the statement to me could be interpreted as applying the bitwise AND operator to both strings.
In addition, there is some sort of bit shifting / masking perhaps (which would be the anagrams part), which is I believe what Monkey alluded to. So we're supposed to mix up the 1's and 0's to create a new binary sequence (anagram step 1), which when converted, creates a scrambled phrase which will be re-arranged to create the single word insult (anagram step 2).
However, this extended beyond my experience after my first sentence.
This is out in left field, but both Escazu and Jersey are locations. Since binary seems to be important here they could be converted into coordinates and some numerical value. Though one would have to decide which "Jersey" was referred to.
I interpreted the locations to be almost like an analogy.
I also noticed that the 4 person / location strings are 6 letters, while the answer for both is most likely 5. So I assume we'll have to drop some bits.
I also noticed that the 4 person / location strings are 6 letters, while the answer for both is most likely 5. So I assume we'll have to drop some bits.
That's what I can't make sense of.
The title of the puzzle makes it sound like there's no anagram/bit-shifting shit involved and that one should investigate another solution. "11010" is 26 so I assumed one was to simply convert each letter to its rank in the alphabet, then that rank into a binary string. This is supported by Hint #2 in which both character strings add up to 42 (that is, if Data's native language is Russian - there are at least 4 other variants of the Cyrillic alphabet with those same letters adding up to different totals). Then I made the connection between 42 and Ganchrow's HHGTTG-themed avatar and I gave up before losing my mind.
Ganchrow you win again.
Last edited by Not Matt Rain; 07-07-10 at 09:35 AM.
Using the Roman alphabet, one could conceivably argue that one other such combination (differing only in the addition of a single letter) would be valid.
Personally, I'd beg to differ.
The aforementioned combination would be ACHTBI.
Anagrams play absolutely no role in the problem and are offered solely as a red herring.
The title of the puzzle makes it sound like there's no anagram/bit-shifting shit involved and that one should investigate another solution. "11010" is 26 so I assumed one was to simply convert each letter to its rank in the alphabet,
As far as the answer to the ultimate question of life, the Universe, and everything ... that was mere coincidence.
Originally Posted by Not Matt Rain
Ganchrow you win again.
I only "win" if I create an interesting puzzle that's readily solvable in a fair amount of time. It seems like I might have lost.
Using a scientific calculator (such as calc.exe in Win32) we see that 137,413,910 AND 55,786,894 = 1,049,862. One may verify that the base-26 representation of this number (with 0=A, 1=B, 2=C, ... 25=Z) is given by CHBTI, or possibly ACHBTI (which maintains the leading A=0 byte).
Performing the same transformations on both "JJGOLD" (J=9, J=9, G=6, O=14, L=11, D=3) and "JERSEY" (J=9, E=4, R=17, S=18, E=4, Y=24) yields base-10 values of 111,160,377 and 109,071,376, respectively. ANDing them together produces 109,054,992 or "JEQTYU" in base-26.
Hence "JEQTY" is the solution to the puzzle.
The following VBA code exposes the function PUZZLESOLVE(), which takes two string arguments, converts them to their base-26 numerical value and returns the string value of the two ANDed together:
Code:
Option Explicit
Public Function PuzzleSolve(ByVal sInput1 As String, ByVal sInput2 As String) As String
Dim vVal1 As Variant, vVal2 As Variant
Dim vAndValue As Variant
vVal1 = GetLongValFromString(sInput1)
If vVal1 < 0 Then
Exit Function
End If
vVal2 = GetLongValFromString(sInput2)
If vVal2 < 0 Then
Exit Function
End If
On Error GoTo OverflowCheck
vAndValue = (vVal1 And vVal2)
On Error GoTo 0
PuzzleSolve = Dec2BaseN_Modified(vAndValue, 26)
Exit Function
OverflowCheck:
If Err.Number = 6 Then
'overflow
On Error GoTo 0
vAndValue = FloatingAnd(vVal1, vVal2)
Resume Next
Else
On Error GoTo 0
Resume
End If
End Function
Private Function GetLongValFromString(ByVal sInput As String) As Variant
Dim i As Long
Dim lLength As Long, iVal As Integer, iRange As Integer
Dim iLowAscValue As Integer, iHighAscValue As Integer
Dim vTotalVal As Variant
iLowAscValue = Asc("A")
iHighAscValue = Asc("Z")
iRange = iHighAscValue - iLowAscValue + 1
sInput = UCase(sInput)
lLength = Len(sInput)
vTotalVal = 0
For i = 1 To lLength
iVal = Asc(Mid(sInput, i, 1)) - iLowAscValue
If iVal < 0 Or iVal > iRange + 1 Then
MsgBox "Charcter# " & i & " of string '" & sInput & "' invalid."
GetLongValFromString = -1
Exit Function
End If
vTotalVal = vTotalVal + iVal * iRange ^ (lLength - i)
Next i
GetLongValFromString = vTotalVal
End Function
Public Function Dec2BaseN_Modified(ByVal vDecimal As Variant, lBase As Long, Optional ByVal bytMinPlaces As Byte = 0, Optional ByVal bStartNumerically As Boolean = False) As String
' Function to convert integer decimal values to integer base-N values (2<=N<=64)
' Output digits start with 26 ;atin capital letters, followed by
' 26 latin lowercase letters, followed by digits 0-9
' then the undesrcore, and lastly the forward slash ("/")
' note that for base 64 this is NOT the equivalent as base64 encoding
' with bStartNumerically set to TRUE, numbering begins with digits 0 - 9
Dim bIsNegative As Boolean, lDecimal As Long
Dim Size As Long, i As Long, lRemainder As Long
Dim ExpandedDigitArray() As String
If lBase < 2 Or lBase > 64 Then
Exit Function
End If
ReDim ExpandedDigitArray(0 To lBase - 1)
If bStartNumerically Then
For i = 0 To lBase - 1
If i < 10 Then
' numeric digits
ExpandedDigitArray(i) = CStr(i)
ElseIf i < 36 Then
' Uppercase
ExpandedDigitArray(i) = Chr(i + 65 - 10)
ElseIf i < 62 Then
' Lowercase
ExpandedDigitArray(i) = Chr(i - 97 - 36)
ElseIf i < 63 Then
ExpandedDigitArray(i) = "_"
Else
ExpandedDigitArray(i) = "/"
End If
Next i
Else
For i = 0 To lBase - 1
If i < 26 Then
' Uppercase
ExpandedDigitArray(i) = Chr(i + 65)
ElseIf i < 52 Then
' Lowercase
ExpandedDigitArray(i) = Chr(i + 97 - 26)
ElseIf i < 62 Then
' numeric digits
ExpandedDigitArray(i) = CStr(i - 52)
ElseIf i < 63 Then
ExpandedDigitArray(i) = "_"
Else
ExpandedDigitArray(i) = "/"
End If
Next i
End If
If vDecimal < 0 Then
vDecimal = -vDecimal
bIsNegative = True
End If
Dec2BaseN_Modified = ""
Do While vDecimal > 2 ^ 31 - 1
' input data isn't of type long so use
' this slower method to reduce it
vDecimal = Int(vDecimal + 0.0001) / lBase
lRemainder = CLng(lBase * (vDecimal - Int(vDecimal)))
Dec2BaseN_Modified = ExpandedDigitArray(lRemainder) & Dec2BaseN_Modified
vDecimal = vDecimal - lRemainder / lBase
If bytMinPlaces > 0 Then bytMinPlaces = bytMinPlaces - 1
Loop
lDecimal = CLng(vDecimal)
' now that we hvae long-data remaining get size in N-BYTES
If lDecimal > 0 Then
Size = Size + CLng(Int(Log(lDecimal) / Log(lBase) + 1))
Else
Size = 1
End If
For i = 0 To Size - 1
lRemainder = lDecimal Mod lBase
lDecimal = lDecimal \ lBase
Dec2BaseN_Modified = ExpandedDigitArray(lRemainder) & Dec2BaseN_Modified
Next i
If (Size < bytMinPlaces) Then
' now left pad with A's (asc("A") = 65)
' to reach minimum size
Dec2BaseN_Modified = String(bytMinPlaces - Size, 65) & Dec2BaseN_Modified
End If
If bIsNegative Then
Dec2BaseN_Modified = "-" & Dec2BaseN_Modified
End If
End Function
Function FloatingAnd(ByVal vVal1 As Variant, ByVal vVal2 As Variant) As Variant
' built-in VBA bitwise AND only wokrs on long values
' this much slower function will work on any values
' up to 10^16 in Excel 2003
Dim sBinVal1 As String, sBinVal2 As String
Dim lLen As Long, lLen1 As Long, lLen2 As Long
Dim i As Long, vAndVal As Variant
sBinVal1 = Dec2BaseN_Modified(vVal1, 2, 0, True)
sBinVal2 = Dec2BaseN_Modified(vVal2, 2, 0, True)
lLen1 = Len(sBinVal1)
lLen2 = Len(sBinVal2)
If lLen1 <= lLen2 Then
lLen = lLen1
Else
lLen = lLen2
End If
For i = 0 To lLen - 1
If Mid(sBinVal1, lLen1 - i, 1) = "1" Then
If Mid(sBinVal2, lLen2 - i, 1) = "1" Then
vAndVal = vAndVal + 2 ^ i
End If
End If
Next i
FloatingAnd = vAndVal
End Function
A good deal of the code would actually be superfluous in a "real" language and is only in place because VBA is unable to perform AND operations on data types other than LONG (positive values < 231-1) on my 32-but machine). Hence I extended the AND operation for floating point values. This actually wasn't strictly necessary for string of this length, but add on another character or t2o and it would be (plus I already had the code written).
Adding the above code to an Excel VBA module, and typing =PUZZLESOLVE("LOSHAK", "ESCAZU") into a cell yields the promised value of 'CHTBI', while =PUZZLESOLVE("JJGOLD", "JERSEY") yields 'JEQTYU'.
Please note that no form of programming was in any way necessary to solve the problem ... I just happened to have to have 3 of the 4 required functions already written in VBA, and when I mixed them together yesterday I found myself decidedly pleased that the answers came out as I had initially calculated (whew).
Anyway, good job once again to Megaman. Well done.