Login Register


[Challenge] Hello, Creativity! filter_list
Author
Message
RE: [Challenge] Hello, Creativity! #5
(08-27-2015, 07:37 AM)null Wrote: damn it. I had pretty much the same idea.
http://pastebin.com/z6sTZkpe
Code:
#!/bin/ruby # Setting up variables string = "" # The string we want to be the same as target target = "Hello, Creativity!" # The target string attempt = 0 # Attempt number until string == target do # Until our string is the same as the target do this targetChar = target[string.length] # Getting the target character by checking the index of the # Target with the length of string ascii = rand(1..127) # Random string between 1 @ 127 if ascii.chr == targetChar then # If the character converted from ascii is the same as the target character string << ascii.chr # Append the char to our string # Stupid art shit p "--------------------------------------" p "MATCH FOUND!" p "Current progress: #{string}" p "Target: #{target}" p "Attempt: #{attempt }" p "--------------------------------------" # /stupid art shit end p "#{ascii}:#{ascii.chr}" # Print the ascii value and char attempt +=1 # increase attempts by 1 end

Not quite as extreme as yours. It just generates a random number and converts it to a chr. If the string is a match to the target string it appends it.

Example output:
http://pastebin.com/Pa4CxdDY

That would execute much faster if you didn't print each attempt. Instead, print each successful attempt and the final string.

Reply





Messages In This Thread
[Challenge] Hello, Creativity! - by Equinox - 08-23-2015, 10:09 PM
RE: [Challenge] Hello, Creativity! - by Eclipse - 08-23-2015, 10:10 PM
RE: [Challenge] Hello, Creativity! - by Eclipse - 08-25-2015, 10:25 PM
RE: [Challenge] Hello, Creativity! - by null - 08-27-2015, 07:37 AM
RE: [Challenge] Hello, Creativity! - by Eclipse - 08-27-2015, 11:05 AM
RE: [Challenge] Hello, Creativity! - by null - 08-27-2015, 11:07 AM
RE: [Challenge] Hello, Creativity! - by Eclipse - 08-27-2015, 11:10 AM
RE: [Challenge] Hello, Creativity! - by null - 08-27-2015, 11:13 AM
RE: [Challenge] Hello, Creativity! - by Eclipse - 08-27-2015, 11:36 AM
RE: [Challenge] Hello, Creativity! - by null - 08-27-2015, 12:04 PM



Users browsing this thread: 1 Guest(s)