Sponsored Content
Top Forums Shell Programming and Scripting Generate a string of alphanumeric characters Post 303032701 by bakunin on Friday 22nd of March 2019 08:05:33 AM
Old 03-22-2019
May i add a few corrections to your estimations? Not, that these will affect the practicality of the outcome in any way, but....

Quote:
all possible combinations of alphanumberica characters of length 12 such that each string will contain numbers and either small or capital letters.
From the wording it follows that we work case-sensitive so that we have a base set of 62 characters and want to find the the 12-combinations.

It also follows that we have to subtract from this the number of all-digit 12-combinations (if basing on multisets, see below) and the number of all-character 12-combinations. It has to be clarified if we still talk combinations without duplicities (as i do assume), that is, 12-tuples of different elements of the base set, or combinations with duplicities.

Lets us for the moment neglect the restricting task and calculate what i'd call the number of the "base set":

If we use combinations without duplicities, that is 12-tuples of different elements of the 62-element set we get n! / ( (n-k)! k! ) or "n over k", the "binomial coefficient", combinations, which is (62! / ( 50! * 12! )) approximately 10^^85 / 10^^64 * 10^^9 ~ 10^^12.

If we use combinations with duplicities (or, basically, a "set of multisets") we need to take into account that an identical element in two different places can be exchanged without changing the combination and hence we get (n+k-1)! / ((n-1)! * k!). 73! / (61! * 12!) is approximately 10^^105 / 10^^83 * 10^^9 ~ 10^^13. The notation for this number is similar to the binomial coefficient ("n over k") but with double braces, i don't know its english name.

We need to reduce the first possible result now by the number of all-character permutations (50 over 12, ~10^^11) in the first case and the second result by this plus the number of all-digit combinations ( multiset 10 over 12, ~10^^7). Both operations won't change the order of magnitude of the results so we get ~10^^12 or ~10^^13 as the respective cardinality of the result sets.

(I do not have any hope this will really help anybody but it was fun nevertheless.)

bakunin

Last edited by bakunin; 03-22-2019 at 09:13 AM..
These 2 Users Gave Thanks to bakunin For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

matching alphanumeric string

how to match an alphanumeric string like the following. i have to do like the following. if the input line is the data is {clock_91b} i have to replace that with the string was ("clock_91b") i tried like $line =~ s/the data is\s+\{(+)\}/the string was \(\"$1\"\)/ which... (4 Replies)
Discussion started by: sskb
4 Replies

2. UNIX for Dummies Questions & Answers

AlphaNumeric String Operations

Hi :) I am writing a ksh I have a string of general format A12B3456CD78 the string is of variable length the string always ends with numbers (here it is 78.. it can be any number of digits may be 789 or just 7) before these ending numbers are alphabets (here it is CD can even be... (3 Replies)
Discussion started by: lakshmikanth
3 Replies

3. Shell Programming and Scripting

With Regex Spliting the string into Alphanumeric and Numeric part

Hi there With shell script I'm trying to split the string into two parts. One is alphanumeric part, the other one is a numeric part. dummy_postcode_1 = 'SL1' --> res_alpha = 'SL' and res_numeric = '1' dummy_postcode_2 = 'S053' --> res_alpha = 'S' and res_numeric = '053' ... (1 Reply)
Discussion started by: ozgurgul
1 Replies

4. Shell Programming and Scripting

ksh - test if string contains alphanumeric...

Okay I will let users input spaces as well :) I am having a mental block. I have done a couple of searches but havent found anything that I understand (the likes of :alpha: and awk). Basically I want to give the user an option to enter some text which will go down as a field within a flat... (3 Replies)
Discussion started by: tugger
3 Replies

5. Shell Programming and Scripting

Sorting with non- and alphanumeric characters

Hi guys, I'm new to this forum and I'm not a UNIX expert. I can't figure out this certain problem i'm having: I need to sort some words, some of the words are annotations (enclosed within < and >). I need to have them sorted alphabetically with all non-alphanumeric characters up front. For... (2 Replies)
Discussion started by: fed.m.ang
2 Replies

6. Shell Programming and Scripting

get rid of non-alphanumeric characters

Hi! Could anyone so kindly help me a code to eliminate from a txt file, obtained by collecting and merge several web-page, every word (string) containing non alphabetical, numeric and punctuation character (i.e NON a-zA-Z0-9, underscore and punctuation mark)? Thanks a lot for the help to... (5 Replies)
Discussion started by: mjomba
5 Replies

7. Shell Programming and Scripting

Sed or trim to remove non alphanumeric and alpha characters?

Hi All, I am new to Unix and trying to run some scripting on a linux box. I am trying to remove the non alphanumeric characters and alpha characters from the following line. <measResults>883250 869.898 86432.4 809875.22 804609 60023 59715 </measResults> Desired output is: 883250... (6 Replies)
Discussion started by: jackma
6 Replies

8. Shell Programming and Scripting

parse a mixed alphanumeric string from within a string

Hi, I would like to be able to parse out a substring matching a basic pattern, which is a character followed by 3 or 4 digits (for example S1234 out of a larger string). The main string would just be a filename, like Thisis__the FileName_S1234_ToParse.txt. The filename isn't fixed, but the... (2 Replies)
Discussion started by: keaneMB
2 Replies

9. Shell Programming and Scripting

how to insert space in alphanumeric string

Hi everyone, I want help to insert space between digits and letters in a alphanumeric string. INPUT TRY234TER PHY1TYR EXPECTED OUTPUT TRY 234 TER PHY 1 TYR The lines always begin with the letters and the alphabets will be a three letter combination before and after the number. The... (2 Replies)
Discussion started by: kaav06
2 Replies

10. UNIX for Beginners Questions & Answers

Need to compare numbers in alphanumeric string

Hi, I will be having file names like below, 1420SP1.01804 1420SP1.01805D 1420SP1.01805 1420SP1.01806D 1420SP1.01806 1420SP1.01901D 1420SP1.01901 1420SP1.01902D 1420SP1.01902 1420SP1.01903D 1420SP1.01903 1420SP1.01904 1420SP1.01905 From this, I need to list file names which is... (3 Replies)
Discussion started by: Sumanthsv
3 Replies
XIGRABBUTTON(3) 														   XIGRABBUTTON(3)

NAME
XIGrabButton, XIUngrabButton, XIGrabKeycode, XIUngrabKeycode - grab/ungrab buttons or keys SYNOPSIS
#include <X11/extensions/XInput2.h> int XIGrabButton( Display *display, int deviceid, int button, Window grab_window, Cursor cursor, int grab_mode, int paired_device_mode, Bool owner_events, XIEventMask *mask, int num_modifiers, XIGrabModifiers *modifiers_inout); int XIUngrabButton( Display *display, int deviceid, int button, Window grab_window, int num_modifiers, XIGrabModifiers *modifiers); int XIGrabKeycode( Display *display, int deviceid, int keycode, Window grab_window, int grab_mode, int paired_device_mode, Bool owner_events, XIEventMask *mask, int num_modifiers, XIGrabModifiers *modifiers_inout); int XIUngrabKeycode( Display *display, int deviceid, int keycode, Window grab_window, int num_modifiers, XIGrabModifiers *modifiers); int XIGrabTouchBegin( Display *display, int deviceid, Window grab_window, Bool owner_events, XIEventMask *mask, int num_modifiers, XIGrabModifiers *modifiers_inout); int XIUngrabTouchBegin( Display *display, int deviceid, Window grab_window, int num_modifiers, XIGrabModifiers *modifiers); display Specifies the connection to the X server. device Specifies the device that is to be grabbed or released button Specifies the device button that is to be grabbed or released or XIAnyButton. keycode Specifies the keycode that is to be grabbed or released or XIAnyKeycode. num_modifiers Number of elements in modifiers or modifiers_inout. modifiers Specifies the set of latched and base modifiers or XIAnyModifier to ungrab. The data type is for consistency with the respective grab request and the status code of the XIGrabModifiers struct is ignored. modifiers_inout Specifies the set of latched and base modifiers or XIAnyModifier to grab. Returns the modifiers that could not be grabbed and their error code. grab_window Specifies the grab window. owner_events Specifies a Boolean value that indicates whether the are to be reported as usual or reported with respect to the grab window. mask Specifies the event mask. grab_mode Specifies further processing of events from this device. You can pass XIGrabModeSync or XIGrabModeAsync. paired_device_mode Specifies further processing of events from the paired master device. You can pass XIGrabModeSync or XIGrabModeAsync. If deviceid specifies a floating slave device, this parameter is ignored. DESCRIPTION
XIGrabButton, XIGrabKeycode and XIGrabTouchBegin establish a passive grab. The modifier device for a button grab is the paired master device if deviceid specifies a master pointer. Otherwise, the modifier device is the device specified with deviceid. In the future, the device is actively grabbed (as for XIGrabDevice, the last-grab time is set to the time at which the button or keycode was pressed and the XI_ButtonPress or XI_KeyPress event is reported if all of the following conditions are true: * The device is not grabbed, and the specified button or keycode is logically pressed or a touch event occurs when the specified modifier keys are logically down on the modifier device and no other buttons or modifier keys are logically down. * Either the grab window is an ancestor of (or is) the focus window, OR the grab window is a descendent of the focus window and contains the device. * A passive grab on the same button/modifier combination does not exist on any ancestor of grab_window. The interpretation of the remaining arguments is as for XIGrabDevice. The active grab is terminated automatically when the logical state of the device has all buttons or keys released (independent of the logical state of the modifier keys). If the device is an attached slave device, the device is automatically detached from the master device when the grab activates and reattached to the same master device when the grab deactivates. If the master device is removed while the device is floating as a result of a grab, the device remains floating once the grab deactivates. Note that the logical state of a device (as seen by client applications) may lag the physical state if device event processing is frozen. This request overrides all previous grabs by the same client on the same button/modifier or keycode/modifier combinations on the same window. A modifiers of XIAnyModifier is equivalent to issuing the grab request for all possible modifier combinations (including the combination of no modifiers). It is not required that all modifiers specified have currently assigned KeyCodes. A button of XIAnyButton is equivalent to issuing the request for all possible buttons. Otherwise, it is not required that the specified button currently be assigned to a physical button. If some other client has already issued a XIGrabButton or XIGrabKeycode with the same button/modifier or keycode/modifier combination on the same window, a BadAccess error results. When using XIAnyModifier or XIAnyButton , the request fails completely, and a XIBadAccess error results (no grabs are established) if there is a conflicting grab for any combination. XIGrabButton and XIGrabKeycode have no effect on an active grab. On success, XIGrabButton, XIGrabKeycode and XIGrabTouchBegin return 0; If one or more modifier combinations could not be grabbed, XIGrabButton, XIGrabKeycode and XIGrabTouchBegin return the number of failed combinations and modifiers_inout contains the failed combinations and their respective error codes. XIGrabButton, XIGrabKeycode and XIGrabTouchBegin can generate BadClass, BadDevice, BadMatch, BadValue, and BadWindow errors. XIUngrabButton, XIUngrabKeycode and XIUngrabTouchBegin release the passive grab for a button/modifier, keycode/modifier or touch/modifier combination on the specified window if it was grabbed by this client. A modifier of XIAnyModifier is equivalent to issuing the ungrab request for all possible modifier combinations, including the combination of no modifiers. A button of XIAnyButton is equivalent to issuing the request for all possible buttons. XIUngrabButton and XIUngrabKeycode have no effect on an active grab. XIUngrabButton, XIUngrabKeycode and XIUngrabTouchBegin can generate BadDevice, BadMatch, BadValue and BadWindow errors. RETURN VALUE
XIGrabButton, XIGrabKeycode and XIGrabTouchBegin return the number of modifier combination that could not establish a passive grab. The modifiers are returned in modifiers_inout, along with the respective error for this modifier combination. If XIGrabButton, XIGrabKeycode or XIGrabTouchBegin return zero, passive grabs with all requested modifier combinations were established successfully. DIAGNOSTICS
BadDevice An invalid deviceid was specified. BadMatch This error may occur if XIGrabButton specified a device that has no buttons, or XIGrabKeycode specified a device that has no keys, or XIGrabTouchBegin specified a device that is not touch-capable. BadValue Some numeric value falls outside the range of values accepted by the request. Unless a specific range is specified for an argument, the full range defined by the argument's type is accepted. Any argument defined as a set of alternatives can generate this error. BadWindow A value for a Window argument does not name a defined Window. BUGS
The protocol headers for XI 2.0 did not provide XIGrabModeAsync or XIGrabModeSync. Use GrabModeSync and GrabModeAsync instead, respectively. SEE ALSO
XIAllowEvents(3) 05/15/2013 XIGRABBUTTON(3)
All times are GMT -4. The time now is 06:41 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy