BACKGROUND
This is essentially a combination of two puzzles:
Longest *Sentence* With Only Repeating Character Pairs (which has been shown to be infinite)
Longest sentence with each letter repeated n times (which maxed out at $n=16$)
CHALLENGE
Form a grammatically correct sentence with $c$ alphabetic characters ([A-Za-z]
)in which every letter pair appears exactly $n$ times. Your score is $n\times c$. Maximize that score.
Clarifications: (The example below is invalid and is only intended to assist in clarification.)
- Words can not be repeated but variations of a word do not count as a repetition. This includes plurals, possessives, contractions, etc. so long as it does not violate other clarifications.
Uni the Unicorn's eating the unicorn!
andBob's bobbing bobbed the bobber.
are OK butUnicorns ate the unicorn's food.
is not OK as it violates the second clarification. - Words count as a repetition if they match when converted to all uppercase and any non-letters are removed. Different definitions, punctuation, or capitalization does not prevent it counting as a repetition.
Buffalo buffalos buffalo bison.
(Buffalo
"city" andbuffalo
"bully" are counted as a repitition.) - Any non-letter (spaces, hyphens, apostrophes, etc.) should be stripped prior to analysis. The result will be just a string of letters.
UnitheUnicornseatingtheunicorns
- Capitalization does not matter. Convert them all to uppercase if that helps.
UNITHEUNICORNSEATINGTHEUNICORNS
The "purest" answers will also meet these conditions: (not required to be valid but somewhat more impressive)
- Every word appears on Dictionary.com
- No proper nouns
- No acronyms or abbreviations
CHECKING
Here are some check methods. I've written a verbose one in VBA. Corrections and submissions in other languages are most welcome.
VBA
Outputs the most common, highest value for $n$ along with a score and a list of any that do not match. (It's not golfed at all because I preferred accuracy and readability over compression.)
Example 1) Input: Alfalfa
. Output: n = 2, c = 7, Score = 14
Example 2) Input: Alfalfac
. Output: n = 2: AC(1)
Example 3) Input: Uni Unicorns
. Output: n = 1: UN(2), NI(2)
Option Explicit
Function ValidateString(s As String) As String
Dim i As Long, j As Long, sTemp As String, v As String
Dim cValue As String, cCount As Long, cCountCount As Long
Dim nValue As Long, nCount As Long, nList As String
'Sanitize
s = UCase(s)
For i = 1 To Len(s)
Select Case Asc(Mid(s, i, 1))
Case 65 To 90: sTemp = sTemp & Mid(s, i, 1)
End Select
Next
s = sTemp
'Find all n values
For i = 1 To Len(s) - 1
cValue = Mid(s, i, 2)
cCount = 0
For j = 1 To Len(s) - 1
If Mid(s, j, 2) = cValue Then cCount = cCount + 1
Next j
nList = nList & "|" & cCount & "|"
Next
'Find largest, most common n value
For i = 1 To Len(s) - 1
cValue = Mid(s, i, 2)
cCount = 0
For j = 1 To Len(s) - 1
If Mid(s, j, 2) = cValue Then cCount = cCount + 1
Next j
cCountCount = (Len(nList) - Len(Replace(nList, "|" & cCount & "|", ""))) / (2 + Len(cCount))
If cCountCount > nCount Then nValue = cCount: nCount = cCountCount
If cCountCount = nCount And cCount > nValue Then nValue = cCount
Next
'List any that don't match
sTemp = ""
For i = 1 To Len(s) - 1
cValue = Mid(s, i, 2)
cCount = 0
For j = 1 To Len(s) - 1
If Mid(s, j, 2) = cValue Then cCount = cCount + 1
Next j
cCountCount = (Len(nList) - Len(Replace(nList, "|" & cCount & "|", ""))) / (2 + Len(cCount))
If cCountCount <> nCount And InStr(1, sTemp, cValue) = 0 Then sTemp = sTemp & cValue & " (" & cCount & "), "
Next
v = "n = " & nValue
If sTemp = "" Then v = v & ", c = " & Len(s) & ", Score = " & nValue * Len(s)
If sTemp <> "" Then v = v & ": " & Left(sTemp, Len(sTemp) - 2)
ValidateString = v
End Function
n = 1: TO(2)
. For "mad madam mimi" I getn = 2: DM(1), DA(1), AM(1), MM(1), IM(1)
. Curiouser and curiouser... $\endgroup$ – Engineer Toast Jul 8 '15 at 16:34ValidateString
has a value. I'll setup another temp value and we can see if that helps. $\endgroup$ – Engineer Toast Jul 8 '15 at 16:42