Most Creative way to write a String!

Discussion in 'Off Topic' started by z0mghii, Apr 26, 2012.

Thread Status:
Not open for further replies.
  1. redrazor11

    redrazor11 Formerly waterwizard11

    Reputations:
    771
    Messages:
    1,315
    Likes Received:
    0
    Trophy Points:
    55
    The name of your class(or file) is "myString".

    Here you are calling a method to return the name of the class. Then you are taking the substring of that.

    get this class name ====> "myString" ==(chars 2-7)==> "String"
     
  2. z0mghii

    z0mghii Notebook Enthusiast

    Reputations:
    0
    Messages:
    38
    Likes Received:
    2
    Trophy Points:
    16
    Ok, I can see that but in your code you're using this.getClass() and "this" only works in non-static methods. I'm wondering if there's a way around this, perhaps creating a method that returns the class name?
     
  3. redrazor11

    redrazor11 Formerly waterwizard11

    Reputations:
    771
    Messages:
    1,315
    Likes Received:
    0
    Trophy Points:
    55
    Yea, just create a method thats not in the main static method. Like I said, here is the idea...not the word-for-word answer (or code-for-code in this case).
     
  4. masterchef341

    masterchef341 The guy from The Notebook

    Reputations:
    3,047
    Messages:
    8,657
    Likes Received:
    4
    Trophy Points:
    206
    (instantiate / declare) string variable str

    while (str != "String") { //wait a few hours

    str <- (random 6 characters)

    }

    print str

    14 billion iterations of the loop for 50% likelihood of completing.

    60 billion iterations of the loop for 95% likelihood of completing.

    100 billion for 99%.
     
  5. talin

    talin Notebook Prophet

    Reputations:
    4,694
    Messages:
    5,352
    Likes Received:
    2
    Trophy Points:
    205
    There goes your power bill, lol.
     
  6. Greg

    Greg Notebook Nobel Laureate

    Reputations:
    7,857
    Messages:
    16,218
    Likes Received:
    58
    Trophy Points:
    466
    Make an array of characters that consist of a heavily mixed-up string, then use a hash to iterate through 0 to N-1, hash the input index, use the output of the hash as an index to access the original character array, thus printing the string?

    OH YEAH!
     
  7. talin

    talin Notebook Prophet

    Reputations:
    4,694
    Messages:
    5,352
    Likes Received:
    2
    Trophy Points:
    205
    It sounds like a job for IBM Watson. :p
     
Loading...
Similar Threads - Creative write String
  1. mnd99
    Replies:
    11
    Views:
    924
Thread Status:
Not open for further replies.

Share This Page