RE: [Challenge] Hello, Creativity! 08-27-2015, 11:05 AM
#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.














![[+]](https://sinister.ly/images/modern/collapse_collapsed.png)