Produce random alphanumeric characters: dukes available

Time for another duke giveaway
On Saturday 6th March, approx 8.00PM (GMT) the following program will be run;-
CodeMaker.javapublic class CodeMaker{
   public static void main(String []params){
      StringBuffer  sb = new StringBuffer();
      java.util.Random r = new java.util.Random();
      for(char c='A'; c<='Z'; c++) sb.append(c);
      for(char c='a'; c<='z'; c++) sb.append(c);
      for(int i=0; i<=10; i++) sb.append(i);
      for(int i=0; i<8; i++) System.out.print(sb.charAt(r.nextInt(sb.length()) ) );
ALL ARE WELCOME TO GUESS THE OUTCOME OF THIS PROGRAM AND EARN FREE DUKES!
- simply add to this thread with your guess of the 8 alphanumeric characters.
- the more characters you guess right the more you earn.
- only one guess permitted per contestant (schizoids such as the Scarlet Pimpernel excl.)
- any other rules may or may not be made by me at any time (after all it is my game so ner-ner-nee-ner-ner)
- that's all I can think of for the moment, good luck t'y'all.
The points system awarded will be determined by the following program;-
CodeScorer.javapublic class CodeScorer{
   public static void main(String []params){
      String luckyDukeWinner = params[0];
      String codeToCrack = params[1];
      String luckyDukeWinnerGuess = params[2];
      new CodeScorer(luckyDukeWinner, codeToCrack, luckyDukeWinnerGuess);
   private CodeScorer(String name, String code, String guess){
      int same = calcSame(code, guess, 0);
      int correct = calcCorrect(code, guess, 0);
      System.out.println("Number of letters correct = "+same);
      System.out.println("Number of letters exactly correct = "+correct);
      System.out.println("Dukes earned by "+name+": "+calcScore(same, correct));
   private int calcCorrect(String code, String guess, int tally){
      for (int i=0; i< code.length(); i++)
         if(guess.charAt(i) == code.charAt(i)) tally++;
      return tally;
   private int calcSame(String code, String guess, int tally){
      StringBuffer buf = new StringBuffer(code);
      for (int i=0; i< buf.length(); i++){
         for (int j=0; j< buf.length(); j++)
            if (guess.charAt(i) == buf.charAt(j)){
               tally++;
               buf.replace(j, j+1,"~");
      return tally;
   private int calcScore(int same, int correct){
      return (same>1 && correct>1)? (int)((correct*4)*(Math.pow(same,2))):(int)((correct*4)+(Math.pow(same,2)));
}

I thought this
for(int i=0; i<=10; i++) sb.append(i);
would do this
for(int i=0; i<=10; i++) sb.append((char)i);
I'm so humilitated....All punters may assume henceforth that line 7 char 22 is herewith removed (I'm humiliated too)

Similar Messages

  • Non-alphanumeric characters in textarea causing 404 errors

    I'm only just becoming acquainted with Coldfusion, as I've been asked to fix a problem in an existing system. The system consists of a simple html form containing a text area, among other input fields. The form is submitted to a cfm script, which displays a confirmation page and sends a couple of emails. The problem is that whenever the user enters any (as far as I can tell) non-alphanumeric characters, e.g. quotes, commas or brackets, in the textarea field, they get a 404 response from the server.
    I tried a number of things to identify the problem, including escaping the text in javascript before submission, but didn't get anywhere. The last thing I tried was installing a local version of the CF on my workstation, hoping to reproduce the problem and thus debug it more easily. However, on my local CF setup the problem does not occur.
    Can anyone help me debug this please? Thanks,
    Marcin

    Thanks for your response. The form method is "post". The only thing that the CFM handler does with this field (gametestexperience) is include it at the bottom of an email message:
    <CFMAIL TO="[email protected]"
    FROM="#email#"
    SUBJECT="Tester Application"
    type="html"
    server = "Cluster9.us.messagelabs.com">
      Automatically logged from the internet form:<p><p>
    <table>
    <tr><td>EmailFrom</td><td>#email#</td>
    <tr><td>From</td><td>#firstName# #lastName#</td></tr>
    <tr><td>Sent</td><td>#DateFormat(Now())#</td></tr>
    <tr><td>Referrer</td><td>#referer#</td></tr>
    <tr><td>Confirmation</td><td>#agree1#, #agree2#, #agree3#, #agree4#, #agree5#</td></tr>
    <tr><td>FamilyCompetitor</td><td>#familycompetitor#</td></tr>
    <tr><td>FamilyWork</td><td>#familywork#</td></tr>
    <tr><td>ReferredBy</td><td>#referredBy#</td></tr>
    <tr><td>RefererDetails</td><td>#refererdetails#</td></tr>
    <tr><td>FirstName</td><td>#firstName#</td></tr>
    <tr><td>LastName</td><td>#lastName#</td></tr>
    <tr><td>Email</td><td>#email#</td></tr>
    <tr><td>TelephoneHome</td><td>#telephoneHome#</td></tr>
    <tr><td>TelephoneCell</td><td>#telephoneCell#</td></tr>
    <tr><td>TelephoneDay</td><td>#telephoneDay#</td></tr>
    <tr><td>City</td><td>#homeTown#</td></tr>
    <tr><td>Employment</td><td>#employment#</td></tr>
    <tr><td>GamerType</td><td>#gamerType#</td></tr>
    <tr><td>GamerStyle</td><td>#gamerStyle#</td></tr>
    <tr><td>HoursPerWeek</td><td>#hoursPerWeek#</td></tr>
    <tr><td>PreferredGenres</td><td>#preferredGenres#</td></tr>
    <tr><td>Consoles</td><td>#console#</td></tr>
    <tr><td>GamesPlayed</td><td>#gameplayed#</td></tr>
    <tr><td>Available</td><td>#available#</td></tr>
    <tr><td>TestedBefore</td><td>#testedBefore#</td></tr>
    <tr><td>TestingExperience</td><td>#gametestexperience#</td></tr>
    </table>
      Thanks,<P>
      Focus Test Team!<P>
    </CFMAIL>

  • Account Codes with non Alphanumeric characters

    I have a customer who has Business Partner Codes which contain non Alphanumeric characters :
    space
    full stop
    apostrophe
    forward slash
    hyphen
    Will this cause issues with the operation of any aspect of Webtools - what if anything should I watch out for since these cannot be changed?

    Thanks for your response. The form method is "post". The only thing that the CFM handler does with this field (gametestexperience) is include it at the bottom of an email message:
    <CFMAIL TO="[email protected]"
    FROM="#email#"
    SUBJECT="Tester Application"
    type="html"
    server = "Cluster9.us.messagelabs.com">
      Automatically logged from the internet form:<p><p>
    <table>
    <tr><td>EmailFrom</td><td>#email#</td>
    <tr><td>From</td><td>#firstName# #lastName#</td></tr>
    <tr><td>Sent</td><td>#DateFormat(Now())#</td></tr>
    <tr><td>Referrer</td><td>#referer#</td></tr>
    <tr><td>Confirmation</td><td>#agree1#, #agree2#, #agree3#, #agree4#, #agree5#</td></tr>
    <tr><td>FamilyCompetitor</td><td>#familycompetitor#</td></tr>
    <tr><td>FamilyWork</td><td>#familywork#</td></tr>
    <tr><td>ReferredBy</td><td>#referredBy#</td></tr>
    <tr><td>RefererDetails</td><td>#refererdetails#</td></tr>
    <tr><td>FirstName</td><td>#firstName#</td></tr>
    <tr><td>LastName</td><td>#lastName#</td></tr>
    <tr><td>Email</td><td>#email#</td></tr>
    <tr><td>TelephoneHome</td><td>#telephoneHome#</td></tr>
    <tr><td>TelephoneCell</td><td>#telephoneCell#</td></tr>
    <tr><td>TelephoneDay</td><td>#telephoneDay#</td></tr>
    <tr><td>City</td><td>#homeTown#</td></tr>
    <tr><td>Employment</td><td>#employment#</td></tr>
    <tr><td>GamerType</td><td>#gamerType#</td></tr>
    <tr><td>GamerStyle</td><td>#gamerStyle#</td></tr>
    <tr><td>HoursPerWeek</td><td>#hoursPerWeek#</td></tr>
    <tr><td>PreferredGenres</td><td>#preferredGenres#</td></tr>
    <tr><td>Consoles</td><td>#console#</td></tr>
    <tr><td>GamesPlayed</td><td>#gameplayed#</td></tr>
    <tr><td>Available</td><td>#available#</td></tr>
    <tr><td>TestedBefore</td><td>#testedBefore#</td></tr>
    <tr><td>TestingExperience</td><td>#gametestexperience#</td></tr>
    </table>
      Thanks,<P>
      Focus Test Team!<P>
    </CFMAIL>

  • Random alphanumeric string

    Hi,
    I need one function which generates a Random alphanumeric string which I want to use as a primary key value. So it must be unique too.
    Something similar to sys_guid in oracle, However I need length of the string fixed to be 6. sys_guid is not helpful as it generates 32 characters long string.
    Can somebody help please?
    Thanks in advance!
    RK

    You can find many examples by doing a search on this forum:
    Alphanumeric sequence number generator

  • Random alphanumeric anyone?

    Hi guys. I was wondering how i can generate random alphnumeric strings like for example: f81d4fae-7dec-11d0-a765-00a0c91e6bf6. Is there a random function ready in java and if es how can it be used with alphanumeric characters. Any opinions would be appriciated.

    There are 62 alphanumeric characters
    0 to 9 = ascii 48 to 57:
    65 to 90 = ascii A to Z:
    97 to 122 = ascii a to z:
    1. Generate (however many) random numbers from 0 to 61
    2. If the number generated ... thrfr <in psuedocode>
    if(num < 10) myStr +=(char)num + 48;
    else if(num > 35)myStr +=(char)num + 62;
    else myStr +=(char)num + 55;
    3. Sorted!

  • Array Of Random Alphabetic Characters?

    Hi,
    How would I populate an array with random alphabetic characters? Is there a java defined method for achieving this?
    The approach I was going to take was to use Math.random to create numbers between 1 - 26 and use a double scripted array to link the number to a letter.
    This is part of a program to test sorting efficiency.
    Any help would be appreciated
    NIALL

    import java.util.Random;
    class find {
         public static void main (String args[]) {
              find f = new find();
              System.out.println("The Random Character is "+ f.myRandom());
         char myRandom() {
              Random r = new Random();
              int i = r.nextInt(52);
              if (i<26) return ((char)(i+97));
              else if(i>=26) return ((char)(i+39));
              else return('0');
    }u can do this like this code specified above

  • [solved] Non-alphanumeric characters broken in TinyChat

    Hello, fellow archers.
    I've been having a bit of trouble with the TinyChat site. Most non-alphanumeric characters are being displayed as crossed-out boxes. This problem is exclusive to TinyChat and has not occured in any other Flash applications.
    An example of the broken characters:
    Note how the / and > characters are not broken.
    This is the second installation of ArchLinux on my computer, the problem occured on the current install only. I suspect the problem is caused by a missing package, though the only hint I was able to find was installing the ttf-ms-fonts package (https://wiki.archlinux.org/index.php/br … ash_Player). This did not resolve the issue.
    Package versions:
    firefox 34.0.5-1
    flashplugin 11.2.202.425-1
    I'll gladly provide any other information that could help resolve this issue.
    Last edited by skoftoby (2015-01-21 18:31:26)

    Head_on_a_Stick wrote:
    skoftoby wrote:I'd like to request this topic be marked as solved either way.
    As with most things Arch, you have to do this yourself -- edit the title of your first post & put "[SOLVED]" at the beginning.
    Whops. The subject length was exactly at the maximum length, and since I couldn't edit the title any further, I thought a moderator had to edit it. Apologies!

  • How to support non alphanumeric characters when using WORLD_LEXER?

    BASIC_LEXER has an attribute of printjoins which we can specify the non alphanumberic characters as normal alphanumberic in query and included with the token. However, WORLD_LEXER doesn't have this attribute. So in order to use some non alphanumberic characters and treat them as alphanumberic characters in Oracle Text Index, such as ><$, what should I can?
    Thanks in advance for any help.

    I use WORLD_LEXER to create Oracle Text Index to support UTF-8.
    Below is the script to create table and index:
    REM Create table
    CREATE TABLE my_test
    ( id VARCHAR2(32 BYTE) NOT NULL,
    code VARCHAR2(100 BYTE) NOT NULL,
         CONSTRAINT "my_test_pk" PRIMARY KEY ("id"));
    REM create index
    exec ctx_ddl.create_preference('stars_lexer','WORLD_LEXER');
    exec ctx_ddl.create_preference('stars_wordlist', 'BASIC_WORDLIST');
    exec ctx_ddl.set_attribute('stars_wordlist','substring_index','TRUE');
    exec ctx_ddl.set_attribute('stars_wordlist','PREFIX_INDEX','TRUE');
    -- create index for Table corrosion level
    CREATE INDEX my_test_index
    ON my_test(code)
    INDEXTYPE IS CTXSYS.CONTEXT
    PARAMETERS ('LEXER stars_lexer STOPLIST stars_stop WORDLIST stars_wordlist SYNC(EVERY "SYSDATE+5/1440") TRANSACTIONAL');
    INSERT INTO my_test('1', 'English word1');
    INSERT INTO my_test('2', '违违');
    INSERT INTO my_test('3', '违违&^|违违');
    When I query:
    select * from corrosion_levels r where contains(r.CORROSION_LEVEL, '{%违${|违%}') > 0
    ID CODE
    3 违违$(|违违
    2 违违
    Actually, the result what I want is: 3 违违$(|违违
    So the requirement is that all non-alphanumeric characters should be treated as normal alphanumeric charcters. Please tell me how to implement it.

  • SQL*Loader-350: Illegal combination of non-alphanumeric characters

    Hi all,
    how to skip a column in control file.
    i.e.
    I have a table with 10 columns and FAT file contains 11 columns.
    how to skip a last column ?
    and
    I added extra column to Table and I changed the control file too.
    but i am getting error.
    SQL*Loader-350: Syntax error at line 115.
    Illegal combination of non-alphanumeric characters
    thanks in Advance.

    Tom Kyte has an elaborate solution on his page:
    http://osi.oracle.com/~tkyte/SkipCols/index.html
    Or post the table description and the control file, so we can have a look at it.

  • Why does Acrobat allocate more width for spaces than for alphanumeric characters?

    When I convert a text file to PDF using Acrobat X Pro, I select a fixed-width font.  However, it appears that Acrobat allocates a greater width for space characters in the text file, than it does for alphanumeric characters in the text file.  How do I instruct Acrobat to use exactly the same width for all the characters, both spaces and visible characters?
    This question is actually a re-write of my previous post titled, ‘Bulk Convert Text to PDF with Acrobat’.  I know what the problem is now but do not how to fix it.
    Here's a mock example of the content of a text file.  In the resulting PDF, the H no longer lies directly under the G.  I chose Courier New 8 pt for the font.
        ABCDEFG    ABCDEFG    ABCDEFG    ABCDEFG    ABCDEFG    ABCDEFG
              H          H          H          H          H          H
    Any suggestion will be appreciated.  Thank you.

    If you are comfortable with the settings in the printing, then go back to the PDF Maker settings (create PDF preferences in WORD) and adjust the preferences for similar performance, at least in the job settings and such. The rest deals with how much you want the bookmarks and such.
    I am assuming that those PDF Maker preferences set in WORD are retained when you run the conversion from Acrobat that I have the impression you are doing. Other than that, check the conversion settings in Acrobat itself. They are in the preferences. If you the printer preferences are used when converting from Text (you will have to try to see what happens), it would use the default preferences of the printer, not those set in the print menu of an application. The latter only last as long as that application is open and only for that application. For your need, you may need to change them in either the printer (Start>Printers.. in windows) or Distiller, or both. The printer overrides the Distiller settings usually (another setting on this).

  • Validation for Unique Name and Non-AlphaNumeric Characters

    Hi All,
    How to do Unique name and Non-Alpha Numeric Characters Validation?
    Name should be unique and only allow alphanumeric characters.
    Where all validations must be done? In EOImpl or any other file?
    Plz help
    Thanks,
    Sk

    SK
    Here are the steps you need to perform to check duplicate Employee Names need not entered by user.
    First create a VVO in your schema.server package(that of EO) with the following query.Generate both VVOImpl and VVORowImpl file.
    select full_name
    from fwk_tbx_employees
    where full_name =:1Now add this VVO to your VAM means give instance to it.
    Now open the VVOImpl and write below code to execute query based on new name entered by user
        public void initQuery(String name)
          setWhereClauseParams(null); // Always reset
          setWhereClauseParam(0, name);
          executeQuery();
        }Now open Your Entity Expert class and add below method in it
       public boolean isEmployeeNameExists(String name)
         boolean isExists = false;
               // Note that we want to use a cached, declaratively defined VO instead of creating
               // one from a SQL statement which is far less performant.
         EmployeeNameVVOImpl employeeNameVVO =
           (EmployeeNameVVOImpl)findValidationViewObject("EmployeeNameVVO1");
         employeeNameVVO.initQuery(name);
         // We're just doing a simple existance check.  If we don't find a match, return false.
         if (employeeNameVVO.hasNext())
           isExists = true;
         return isExists;
       }Now you need to call this expert class method from setter method of EOImpl for name.so Open your EOImpl file and go to setter method of name
          if ((value != null) || (!("".equals(value.trim()))))
            EmployeeEntityExpert expert = getEmployeeEntityExpert(getOADBTransaction());
            if (!(expert.isEmployeeNameExists(value)))
                throw new OAException("Duplicate Employee Name", OAException.ERROR);
          }Remember to write code above setAttributeInternal.
    Hope it helps!!!!
    Let me know if you have queries in it.
    Thanks
    AJ

  • Hot to set the Non-alphanumeric characters attribute?

    Hello,
    I'm developing an asp.net application using the oracle membership provider. I have installed the databse objects in an Oracle 9i and when I try to create a new user, It always asks me to consider at least 1 Non-alphanumeric character in the password, even if I put in the web.config file the minRequiredNonalphanumericCharacters="0" attribute. Is there another way to set the Non-alphanumeric characters to "0".
    Thanks.

    Workaround: set 0 for minRequiredNonalphanumericCharacters attribute in your machine.config for OracleMembershipProvider. The defalt value is 1. The typical location of machine.config is in %windir%\Microsoft.NET\Framework\v2.0.50727\CONFIG.

  • RegEx in TSQL - replace non-alphanumeric characters etc

    Hi guys, I have this function in VB that I used in Access to replace all non-alphanumeric characters, including spaces and anything in brackets.
    Public Function charactersonly(inputString As String) As String
    Dim RE As Object
    Set RE = CreateObject("vbscript.regexp")
    RE.Pattern = "\([^)]+\)|[^\w]|_"
    RE.Global = True
    charactersonly = RE.Replace(inputString, "")
    Set RE = Nothing
    End Function
    Now, I moved to SQL server and I'm writing scripts to do same thing.
    How can I use RegEx in TSQL?
    Only thing I will do is that function.

    As alternative
    declare @string varchar(200)
    set @string = 'gg$%^^&is%^& s2342jjk23&&({}e c76l232e+_+a#n/ c][#o''y#e'
    select cast(cast((select substring(@string,n,1)
    from numbers
    where n <= len(@string)
    and substring(@string,n,1) like '[0-9 ]' for xml path('')) as xml)as varchar(max))
    Best Regards,Uri Dimant SQL Server MVP,
    http://sqlblog.com/blogs/uri_dimant/
    MS SQL optimization: MS SQL Development and Optimization
    MS SQL Consulting:
    Large scale of database and data cleansing
    Remote DBA Services:
    Improves MS SQL Database Performance
    SQL Server Integration Services:
    Business Intelligence

  • Non-alphanumeric characters part of a word?

    Hi,
    When searching using "23" the users have complained that it brings back terms like 23:00 and www.bob.....html?q=23. It's a bit of a long stretch but is there anyway to disregards those item.
    I expect I'll probably end up explaining to the users that non-alphanumeric characters are regarded in the same was as white spaces, but is this a general standard, and is there a link to more information anywhere?
    Cheers

    You could make your colon and equal sign printjoins or skipjoins.

  • Adobe PDF printer not printing past 180 pages   random garbage characters

    I am in IT and I have a user whose PDF printer will not convert docs to PDF past 180-182 pages. It gives her an error about that place in the doc that says there was nothing selected and that none of it was converted when in reality it converted it all (up to 180-182 pages). On top of this it will place random illegible characters throughout the PDF with no apparent order. We've re-installed Adobe multiple times and updated it.
    I've looked everywhere to find an answer so I'm now here.

    A print to PDF is an entirely different process than using the Save As Adobe PDF. If you use the Save As PDF or XPS, you are using the MS plugin, not the one from Adobe. The results can vary depending on the preferences selected and such. Usually when the print fails it is due to either AcroTray not running or an error from Distiller (and recorded in the log as long as the log is not turned off). If you have a lot of graphics, the print process can run into memory limitations (usually from the TEMP folder issue) due to the initial conversion to PS that can be huge. The graphics are generally not compressed much until they get into the PDF.
    If you are having problems with the print process, the first step is to try a print to file. This process creates a PS file (may have a prn extension). If that file is created, the next step is to open the file in Distiller to create the PDF. If there are errors from Distiller, you will see them at this step. Errors are often related to color settings or fonts that cannot be embedded. Maybe that will give you some things to consider.

Maybe you are looking for

  • Urgently Upgrade Stop In XPRAS_UPG Phase

    Hi all, This is our infrastructure: Windows 2000 Oracle 9.2.0.7 SAP 4.6B Kernel Release 46D We are upgrading our DEV System to R/3 Enterprise 4.7 Ext. 2 Sr1 <b>Our Upgrade Process Stop in the XPRAS_UPG Phase. Basically it gives this error:</b> WARNIN

  • IPhoto Library Manager won't open, what to do? .

    Pls HELP. I downloaded iPhoto 9.2.3, and when i tried to open it the app completely froze.  I was instructed to hold down command and option keys when clicking on iPhoto and use the resulting dialogue box to rebuild the library database.  I tried tha

  • I have just downloaded IOS 7

    I have just downloaded IOS 7 and need the new iTunes 11.1 to be able to use my iPhone on iTunes but I need the new mac software update OXS 10.6.8, but my mac doesn't need or have an update what should I do! I'm upset :'(

  • Flattening

    Can someone help explain the difference between Flattneing a PDF in Acrobat (Flatten Preview tool) verus opening a PDF file in Photoshop and re-saving as a PDF?

  • DIfference between BW and R/3 Security

    Hi Please tell me whats the difference between BW and R/3 Security Thanks