Last active
August 29, 2015 14:10
-
-
Save shinkbr/d4cbff47c335f10c7768 to your computer and use it in GitHub Desktop.
SECCON 2014 online qualifiers: Numbers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# coding: utf-8 | |
require 'socket' | |
s = TCPSocket.open('number.quals.seccon.jp', 31337) | |
count = 1 | |
while line = s.readline('?') | |
puts line | |
minmax = line[/(min|max)/] | |
numbers = line.gsub(/\n.*/, '').gsub(' ', '').split(',') | |
numbers.map! {|i| i = i.to_i} | |
case minmax | |
when 'min' | |
n = numbers.min | |
when 'max' | |
n = numbers.max | |
end | |
puts n | |
puts "count: #{count}\n====" | |
count += 1 | |
s.write(n) | |
end | |
s.close |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment