Advertisement
Guest User

Untitled

a guest
Mar 12th, 2018
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 2.11 KB | None | 0 0
  1. # coding: utf-8
  2.  
  3. require_relative 'interpreter'
  4. require 'stringio'
  5.  
  6. (3..6).each do |max_output|
  7.     [*1...max_output].each do |end_pos|
  8.         ([*1...max_output]-[end_pos]).each do |out_pos|
  9.             code = '`'*max_output
  10.             code[end_pos] = '@'
  11.             code[out_pos] = 'O'
  12.  
  13.             puts code
  14.             ("\n !\"#$%&'()*+,-./0123456789:;<=>?@ABCFGILOPQRSTVWXYZ[\\]^_abdegilnopqrsvx{|}~".chars).repeated_permutation(max_output-2) do |pos|
  15.                 this_code = code.clone
  16.                 pos.each do |c| this_code.sub!('`',c) end
  17.                
  18.                 in_stream = StringIO.new('')
  19.                 out_stream = StringIO.new
  20.                 errored = false
  21.                 begin
  22.                     aborted = Interpreter.run(this_code, 0, in_stream, out_stream, 30)
  23.                 rescue
  24.                     errored = true
  25.                 end
  26.  
  27.                 if aborted || out_stream.string.rstrip[/\D/]
  28.                     next
  29.                 end
  30.  
  31.                 single = out_stream.string.to_i
  32.  
  33.                 next if single < 1
  34.  
  35.                 in_stream = StringIO.new('')
  36.                 out_stream = StringIO.new
  37.                 errored = false
  38.                 begin
  39.                     aborted = Interpreter.run(this_code*2, 0, in_stream, out_stream, 30)
  40.                 rescue
  41.                     errored = true
  42.                 end
  43.  
  44.                 next if aborted || out_stream.string.rstrip[/\D/] || out_stream.string.to_i != single
  45.                
  46.                 in_stream = StringIO.new('')
  47.                 out_stream = StringIO.new
  48.                 errored = false
  49.                 begin
  50.                     aborted = Interpreter.run(this_code*3, 0, in_stream, out_stream, 30)
  51.                 rescue
  52.                     errored = true
  53.                 end
  54.  
  55.  
  56.                 if !aborted && !out_stream.string.rstrip[/\D/] && single*3 == out_stream.string.to_i
  57.                     $stderr << single.to_s << ': '
  58.                     puts this_code
  59.                     $stderr.puts this_code
  60.                 end
  61.             end
  62.         end
  63.     end
  64. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement