Receipt Bank Logo

2016 Printer

2016 Printer

A malevolent alien race wants to destroy humanity. As part of their plan, they will try to throw off the global terran federation calendar. Fortunatelly, our counter intelligence is one step ahead and you are tasked with making our callendar corruption proof.

Write a program that prints 2016. The catch is that you should be able to delete or replace any one non-whitespace character and it should still print 2016 if the syntax is valid. Valid syntax is defined as one passing ruby -c.

Some details:

AVAILABLE_REPLACEMENTS = [
  '', *'a'..'z', *'A'..'Z', *'0'..'9',
  '~', '!', '@', '$', '%', '^', '&', '*', '#', "'", '"',
  '_', '+', '`', '-', '=', ',', '.', '/', ';', ':', '?',
  '(', ')', '{', '}', '[', ']', '<', '>', '\\', '💎',
]

Note: Test your solution using this script. We will retest it when you come to claim your reward. Don’t rely on the form validation tests, use the script.


A correct solution (by RB team):

begin
STDOUT<< (Time.now.year);rescue=>_;p 2016;rescue;end

Leader board

The lower the score - the better. It is the shortest solution that wins.

If you're among the first 5 stop by out booth to claim your reward.
Winner!
Nickname: KamenH
   Score: 57 
begin
  $stdout << (
    Time.now.year)
rescue => e
  e && p(2016)
rescue
end
Failed tests :(
Nickname: shadow
   Score: 1 
p



# TEST STATUS: FAIL
# Original solution didn't print 2016: [ ]
Failed tests :(
Nickname: Joskov
   Score: 1 
p


# TEST STATUS: FAIL
# Original solution didn't print 2016: [ ]
Failed tests :(
Nickname: Ilia
   Score: 3 
p 


# TEST STATUS: FAIL
# Original solution didn't print 2016: ["ߠ"]
Failed tests :(
Nickname: Alex
   Score: 5 
p 2016



# TEST STATUS: FAIL
# Replacing [p] with [k] on [#0] caused a runtime error.
# Offeding code: [k 2016]
Failed tests :(
Nickname: yitsushi
   Score: 5 
p 2016


# TEST STATUS: FAIL
# Replacing [p] with [] on [#0] didn't print 2016.
# Offeding code: [2016]
Failed tests :(
Nickname: whaat?
   Score: 5 
p 2016
n

# TEST STATUS: FAIL
# Replacing [p] with [] on [#0] didn't print 2016.
# Offeding code: [2016]
Failed tests :(
Nickname: David
   Score: 7 
p .ord



# TEST STATUS: FAIL
# Replacing [p] with [b] on [#0] caused a runtime error.
# Offeding code: [b ?ߠ.ord]
Failed tests :(
Nickname: ewad
   Score: 8 
puts 2016



# TEST STATUS: FAIL
# Replacing [p] with [j] on [#0] caused a runtime error.
# Offeding code: [juts 2016]
Failed tests :(
Nickname: alexrodba
   Score: 8 
p 'ߠ'.ord


# TEST STATUS: FAIL
# Replacing [p] with [j] on [#0] caused a runtime error.
# Offeding code: [j 'ߠ'.ord]
Failed tests :(
Nickname: GJ
   Score: 31 
puts 2.to_s+0.to_s+1.to_s+6.to_s


# TEST STATUS: FAIL
# Replacing [p] with [] on [#0] caused a runtime error.
# Offeding code: [uts 2.to_s+0.to_s+1.to_s+6.to_s]
Failed tests :(
Nickname: feri
   Score: 39 
begin
  p Time  .now  .year 
rescue
  p 2016
rescue
end


# TEST STATUS: FAIL
# Replacing [p] with [] on [#9] didn't print 2016.
# Offeding code: [begin
   Time  .now  .year 
rescue
  p 2016
rescue
end]
Failed tests :(
Nickname: iJarvis
   Score: 44 
puts Time.now.year rescue p Time.now.year rescue 0


# TEST STATUS: FAIL
# Replacing [s] with [c] on [#3] caused a runtime error.
# Offeding code: [putc Time.now.year rescue p Time.now.year rescue 0]
Failed tests :(
Nickname: kambata
   Score: 55 
begin
  (a = 2016) == 2016 ? (puts(aa)) : puts(2016) rescue
  p 2016
end



# TEST STATUS: FAIL
# Replacing [p] with [h] on [#64] caused a runtime error.
# Offeding code: [begin
  (a = 2016) == 2016 ? (puts(aa)) : puts(2016) rescue
  h 2016
end]
Failed tests :(
Nickname: exeqte
   Score: 116 
begin
  Signal.trap("PIPE", "EXIT")
  at_exit do
    puts Time.new.year
    exit(0)
  end
rescue Exception, StandardError
  puts Time.new.year
end



# TEST STATUS: FAIL
# Replacing [b] with [b] on [#0] didn't print 2016.
# Offeding code: [begin
  Signal.trap("PIPE", "EXIT")
  at_exit do
    puts Time.new.year
    exit(0)
  end
rescue Exception, StandardError
  puts Time.new.year
end]
Failed tests :(
Nickname: withoutjoke
   Score: 451 
begin
  begin
    (vvv=(2016))
    (vvv = (2016) unless vvv.eql?(2016) rescue nil)
    (@vv=vvv)
    ($vv=vvv)

    (mmm=(:to_i))
    (mmm=(:to_i) unless mmm.eql?(:to_i) rescue nil)
    (@mm=mmm)
    ($mm=mmm)

    (print(vvv.public_send(
      mmm
    )) rescue print(2016))

    (vvv=('')) rescue vvv = ('')
    (vvv = ('') unless vvv.eql?('') rescue nil)
    (@vv=vvv)
    ($vv=vvv)
  rescue TypeError
  rescue RangeError
    $stdout.write 2016
  rescue ArgumentError
    $stdout.write 2016
  rescue NameError
    print(vvv || 2016)
  rescue NoMethodError
    print(vvv || 2016)
  rescue
  end rescue nil
end



# TEST STATUS: FAIL
# Replacing [t] with [=] on [#232] didn't print 2016.
# Offeding code: [begin
  begin
    (vvv=(2016))
    (vvv = (2016) unless vvv.eql?(2016) rescue nil)
    (@vv=vvv)
    ($vv=vvv)

    (mmm=(:to_i))
    (mmm=(:to_i) unless mmm.eql?(:to_i) rescue nil)
    (@mm=mmm)
    ($mm=mmm)

    (prin=(vvv.public_send(
      mmm
    )) rescue print(2016))

    (vvv=('')) rescue vvv = ('')
    (vvv = ('') unless vvv.eql?('') rescue nil)
    (@vv=vvv)
    ($vv=vvv)
  rescue TypeError
  rescue RangeError
    $stdout.write 2016
  rescue ArgumentError
    $stdout.write 2016
  rescue NameError
    print(vvv || 2016)
  rescue NoMethodError
    print(vvv || 2016)
  rescue
  end rescue nil
end]