|
本帖最后由 delete_007 于 2013-11-26 18:29 编辑
函数。好不容易凑的,可以计算256个字符的字符串。=MIN(MMULT(-(MID(A1&A1,ROW($1:$256),LEN(A1))>MID(A1&A1,COLUMN(1:1),LEN(A1))),-(ROW($2:$257)<LEN(A1)))/1%+ROW($1:$256))-1
VBA 时间不好控制
Function MinRot(ByVal sStr As String) As Long
Dim t#
t = Timer
'……
Dim x, y, z As String
MinRot = 0
x = sStr
z = sStr
Dim i As Integer
For i = 1 To Len(sStr)
y = Mid(x, 2, Len(x)) & Left(x, 1)
If y < z Then z = y: MinRot = i
x = y
Next
'……
t = Timer - t
Debug.Print "ID: " & "hellohaha"
Debug.Print "Answer is: " & MinRot
Debug.Print "Time used: " & Format(t, "0.000s")
End Function 公式稍有瑕疵,修改为适应小于100字符的公式:
=MIN(MMULT(-(MID(A2&A2,ROW($1:$99),LEN(A2))>MID(A2&A2,COLUMN(A:CU),LEN(A2))),-(ROW($1:$99)<LEN(A2)))/1%+ROW($1:$99))-1
118字符。
——delete_007
|
评分
-
1
查看全部评分
-
|