Search found 7 matches

by wynk
Wed Feb 01, 2012 9:57 pm
Forum: Challenges Solved
Topic: Ave
Replies: 17
Views: 1781

My ruby solution: input = "cqrb lryqna rb fjh, fjh qjamna cqjw axc cqracnnw. qnan, hxd wnena twxf qxf oja cx bqroc! xq kh cqn fjh, cqn jwbfna rb mnjmvjwblqnbc." for i in 1..25 do input.each_byte { |c| if (97..122).member?(c) print (97 + (c - 97 + i) % 26).chr else print c.chr end } puts ''...
by wynk
Mon Jan 23, 2012 11:52 pm
Forum: Challenges Solved
Topic: 3280
Replies: 20
Views: 1779

My solution in ruby:

Code: Select all

file = File.new("rfc3280.txt", "r")
dict = Hash.new(0)
while (line = file.gets)
	line.scan(/[^\w]([\w]{9})[^\w]/) { |match|
		dict.store(match, dict[match].succ)
	}
end
puts dict.index(dict.values.max)
file.close
by wynk
Sun Jan 08, 2012 5:42 pm
Forum: Challenges Solved
Topic: NEWSGROUP Cipher
Replies: 9
Views: 1531

My solution in ruby by doing some math with the ASCII table: input = "Guvf zrffntr vf rapelcgrq va ebg 13. Lbhe nafjre vf svfupnxr." input.each_byte { |x| # lower case letters if (65..90) === x print (65 + (x - 52) % 26).chr # capital letters elsif (97..122) === x print (97 + (x - 84) % 26...
by wynk
Thu Jan 05, 2012 12:49 am
Forum: Challenges Solved
Topic: didactic green
Replies: 12
Views: 1213

Four lines in Ruby:

Code: Select all

image = ChunkyPNG::Image.from_file('greenline.png')
for i in 0..image.width-1
	print ChunkyPNG::Color.g(image[i,0]).chr
end
by wynk
Thu Jan 05, 2012 12:30 am
Forum: Challenges Solved
Topic: Didactic RGB
Replies: 17
Views: 1610

My tiny ruby solution:

Code: Select all

require 'rubygems'
require 'chunky_png'
image = ChunkyPNG::Image.from_file('didactrgb.png')
color = ChunkyPNG::Color.to_truecolor_bytes(image[0,0])
color.map! { |x| x.to_s(2).rjust(8, '0') }
puts color.join.to_i(2)
by wynk
Wed Jan 04, 2012 3:33 pm
Forum: Challenges Solved
Topic: A Few Percent
Replies: 8
Views: 872

My tiny ruby solution:

Code: Select all

input = "%66%75%67%6C%79"
extension = input.scan(/[0-9A-Z]{2,2}/)
extension.map! { |x| x.hex.chr }
output = extension.join
puts output
by wynk
Wed Jan 04, 2012 2:15 pm
Forum: Challenges Solved
Topic: Didactic XOR
Replies: 7
Views: 1179

My solution in ruby:

Code: Select all

input = ["9f", "c7"]
input.map! {
	|x| x.to_i(16)
}
output = input.first ^ input.last
puts output.chr