Atom: The word removes the substrings of individual letters, for example, ac bc AB ABC in ABC. Note: Ca does not count.
Valid ATOM: an atom with a length greater than 60% of the word length. It can be used for Lenovo memory and similar words.
<Script language = "VBScript">
STR = "aaccb"
''Creates a global dictionary object to store all obtained atomic results.
Set dict = Createobject ("scripting. Dictionary ")
Dim A (100)
Strlength = Len (STR)
''Atomic
Atomylength = round (strlength * 0.6)
For x = atomylength to strlength
A (0) = x
''Calculate the combination of 5, 5, 4, 5, and 5.
Combine strlength, X
Next
Sub combine (M, K)
''Calculates all combinations of k elements selected in M and adds them to dictionary objects.
I = 0
J = 0
For I = m to k step-1
A (K) = I
If (k> 1) then
Combine I-1, K-1
Else
Tempstr = ""
For j = 1 to A (0)
Tempstr = tempstr & Mid (STR, A (J), 1)
Next
''To exclude duplicates and add them to the dictionary
If not dict. exists (tempstr) Then dict. Add tempstr, Len (tempstr)
End if
Next
End sub
Main ()
Sub main
''Output display result
For I = 0 to dict. Count-1
Document. Write dict. Keys () (I) & "& nbsp ;"
Next
End sub
</SCRIPT>
Using system;
Using system. Collections. Generic;
Using system. componentmodel;
Using system. Data;
Using system. drawing;
Using system. text;
Using system. Windows. forms;
Namespace windowsapplication3
{
Public partial class form1: Form
{
Public form1 ()
{
Initializecomponent ();
}
Private void button#click (Object sender, eventargs E)
{
String word = This. textbox1.text;
List <string> List = new list <string> ();
Char [] arr = word. tochararray ();
Int A = 0;
Int B = 0;
Picturebox1.show ();
Button1.enabled = false;
Datetime T = datetime. now;
String result = "";
Int strlength = word. length;
Int atomylength = convert. toint32 (math. Round (strlength * 0.6 ));
Datetime T1 = datetime. now;
// Start settlement
For (INT x = convert. toint32 (math. Pow (2, atomylength); x <convert. toint32 (math. Pow (2, strlength); X ++)
{
B = 0;
A = X;
While (! = 0)
{
If (a % 2! = 0)
{
Result + = arr [B];
}
B ++;
A> = 1;
Application. doevents ();
}
Application. doevents ();
If (! List. Contains (result) & result. length> = atomylength)
{
List. Add (result );
}
Result = "";
}
Picturebox1.hide ();
String time = (datetime. Now-t1). tostring ();
Textbox2.text = "Input/" "+ textbox1.text +"/"generate" + list. Count + "atoms. Time:" + time;
This. listbox1.datasource = List;
Button1.enabled = true;
}
}
}