Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # coding: utf-8
- require_relative 'interpreter'
- require 'stringio'
- (3..6).each do |max_output|
- [*1...max_output].each do |end_pos|
- ([*1...max_output]-[end_pos]).each do |out_pos|
- code = '`'*max_output
- code[end_pos] = '@'
- code[out_pos] = 'O'
- puts code
- ("\n !\"#$%&'()*+,-./0123456789:;<=>?@ABCFGILOPQRSTVWXYZ[\\]^_abdegilnopqrsvx{|}~".chars).repeated_permutation(max_output-2) do |pos|
- this_code = code.clone
- pos.each do |c| this_code.sub!('`',c) end
- in_stream = StringIO.new('')
- out_stream = StringIO.new
- errored = false
- begin
- aborted = Interpreter.run(this_code, 0, in_stream, out_stream, 30)
- rescue
- errored = true
- end
- if aborted || out_stream.string.rstrip[/\D/]
- next
- end
- single = out_stream.string.to_i
- next if single < 1
- in_stream = StringIO.new('')
- out_stream = StringIO.new
- errored = false
- begin
- aborted = Interpreter.run(this_code*2, 0, in_stream, out_stream, 30)
- rescue
- errored = true
- end
- next if aborted || out_stream.string.rstrip[/\D/] || out_stream.string.to_i != single
- in_stream = StringIO.new('')
- out_stream = StringIO.new
- errored = false
- begin
- aborted = Interpreter.run(this_code*3, 0, in_stream, out_stream, 30)
- rescue
- errored = true
- end
- if !aborted && !out_stream.string.rstrip[/\D/] && single*3 == out_stream.string.to_i
- $stderr << single.to_s << ': '
- puts this_code
- $stderr.puts this_code
- end
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement