Login Register


[Challenge] Hello, Creativity! filter_list
Author
Message
RE: [Challenge] Hello, Creativity! #4
(08-25-2015, 10:25 PM)eclipse Wrote:
Code:
import requests as r import random pi = r.get('http://newton.ex.ac.uk/research/qsystems/collabs/pi/pi6.txt').text pi = str("".join(pi.split())) splitted = [] prev = 0 while True: n = random.randint(1,3) splitted.append(pi[prev:prev+n]) prev = prev + n if prev >= len(pi)-1: break splitted = splitted[2:] completed = [] #Hello, Creativity! for dec in splitted: dec = int(dec) if dec < 256: if chr(dec) == "H": completed.append(chr(dec)) break for dec in splitted: dec = int(dec) if dec < 256: if chr(dec) == "e": completed.append(chr(dec)) break for dec in splitted: dec = int(dec) if dec < 256: if chr(dec) == "l": completed.append(chr(dec)) break for dec in splitted: dec = int(dec) if dec < 256: if chr(dec) == "l": completed.append(chr(dec)) break for dec in splitted: dec = int(dec) if dec < 256: if chr(dec) == "o": completed.append(chr(dec)) break for dec in splitted: dec = int(dec) if dec < 256: if chr(dec) == ",": completed.append(chr(dec)) break for dec in splitted: dec = int(dec) if dec < 256: if chr(dec) == " ": completed.append(chr(dec)) break for dec in splitted: dec = int(dec) if dec < 256: if chr(dec) == "C": completed.append(chr(dec)) break for dec in splitted: dec = int(dec) if dec < 256: if chr(dec) == "r": completed.append(chr(dec)) break for dec in splitted: dec = int(dec) if dec < 256: if chr(dec) == "e": completed.append(chr(dec)) break for dec in splitted: dec = int(dec) if dec < 256: if chr(dec) == "a": completed.append(chr(dec)) break for dec in splitted: dec = int(dec) if dec < 256: if chr(dec) == "t": completed.append(chr(dec)) break for dec in splitted: dec = int(dec) if dec < 256: if chr(dec) == "i": completed.append(chr(dec)) break for dec in splitted: dec = int(dec) if dec < 256: if chr(dec) == "v": completed.append(chr(dec)) break for dec in splitted: dec = int(dec) if dec < 256: if chr(dec) == "i": completed.append(chr(dec)) break for dec in splitted: dec = int(dec) if dec < 256: if chr(dec) == "t": completed.append(chr(dec)) break for dec in splitted: dec = int(dec) if dec < 256: if chr(dec) == "y": completed.append(chr(dec)) break for dec in splitted: dec = int(dec) if dec < 256: if chr(dec) == "!": completed.append(chr(dec)) break strcompleted = '' for char in completed: strcompleted += char print strcompleted

3,030 bytes

1) Retrieve Pi to a million digits and convert to string
2) Split string every n characters where n is a random integer between 1 and 3
3) Iterate through split string for each character of target string, convert the integer to its ascii chr()
4) Check if result is same as target character
5) If yes, append the chr() of the integer to a list.
6) print

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

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)