June 2018 Update
This commit is contained in:
parent
ba8067c3b7
commit
22f33d4004
5278 changed files with 84726 additions and 14379 deletions
34
Task/ABC-Problem/VBA/abc-problem.vba
Normal file
34
Task/ABC-Problem/VBA/abc-problem.vba
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
Option Explicit
|
||||
|
||||
Sub Main_ABC()
|
||||
Dim Arr, i As Long
|
||||
|
||||
Arr = Array("A", "BARK", "BOOK", "TREAT", "COMMON", "SQUAD", "CONFUSE")
|
||||
For i = 0 To 6
|
||||
Debug.Print ">>> can_make_word " & Arr(i) & " => " & ABC(CStr(Arr(i)))
|
||||
Next i
|
||||
End Sub
|
||||
|
||||
Function ABC(myWord As String) As Boolean
|
||||
Dim myColl As New Collection
|
||||
Dim NbLoop As Long, NbInit As Long
|
||||
Dim b As Byte, i As Byte
|
||||
Const BLOCKS As String = "B,O;X,K;D,Q;C,P;N,A;G,T;R,E;T,G;Q,D;F,S;J,W;H,U;V,I;A,N;O,B;E,R;F,S;L,Y;P,C;Z,M"
|
||||
|
||||
For b = 0 To 19
|
||||
myColl.Add Split(BLOCKS, ";")(b), Split(BLOCKS, ";")(b) & b
|
||||
Next b
|
||||
NbInit = myColl.Count
|
||||
NbLoop = NbInit
|
||||
For b = 1 To Len(myWord)
|
||||
For i = 1 To NbLoop
|
||||
If i > NbLoop Then Exit For
|
||||
If InStr(myColl(i), Mid(myWord, b, 1)) <> 0 Then
|
||||
myColl.Remove (i)
|
||||
NbLoop = NbLoop - 1
|
||||
Exit For
|
||||
End If
|
||||
Next
|
||||
Next b
|
||||
ABC = (NbInit = (myColl.Count + Len(myWord)))
|
||||
End Function
|
||||
Loading…
Add table
Add a link
Reference in a new issue