Bitmap

Краен срок
09.11.2013 12:00

Срокът за предаване на решения е отминал

Bitmap

Нека упражним малко елементарна битова аритметика.

Можем да представяме изображения като линеен масив от байтове (тъй като в Ruby няма тип „байт“ мислете си за масив от цели числа между 0 и 255). Всеки от тези байтове съдържа информация за определен брой „пиксели“. В един байт можем да съберем информация за 8 двуцветни пиксела (0 за първия цвят, 1 за втория цвят), 4 четирицветни пиксела (по два бита за цвят, 00 за първи, 01 за втори, 10 за трети и 11 за четвърти), или 2 шестнадесетцветни пиксела (0000, 0001 и така нататък до 1111).

„Палитрата“ ни с цветове е просто един масив от ASCII символи, в който нулевият елемент представлява първия „цвят“, първият елемент – вторият цвят и така нататък. Например монохромен (а.к.а. „черно-бял“) bitmap можем да представим в текстов вид, като на всеки „пиксел“ със стойност 0 съпоставим символа ., а на всеки „пиксел“ със стойност 1 съпоставим символа #. Така от байт със стойност 41 и палитра ['.', '#'] получаваме следната „картинка“:

41 -> 00101001 -> "..#.#..#"

Напишете клас Bitmap, чийто конструктор приема един задължителен аргумент — списъка с байтове и един опционален аргумент — броя байтове на ред. Ако опционалният аргумент не бъде подаден, ще се подразбира, че матрицата е едноредова, тоест, че на един ред имаме толкова байта, колкото са подадени в списъка.

Класът Bitmap трябва да има един метод render, който приема като опционален аргумент масив, който да представя „палитрата“ (по подразбиране имаме двуцветна палитра със символи . и #, т.е. масив ['.', '#']) и връща текстуалното представяне на въпросната матрица. "Квадратчетата" са залепени едно за друго, както в примерите, а редовете са съединени със символ за нов ред ("\n"). След последния ред няма символ за нов ред.

Пример:

bitmap = Bitmap.new [1, 10, 100]
bitmap.render # => ".......#....#.#..##..#.."

Или, с друга палитра:

bitmap = Bitmap.new [1, 10, 100]
bitmap.render ['+', '@'] # => "+++++++@++++@+@++@@++@++"

Палитрата може да има и повече от два цвята:

bitmap = Bitmap.new [1, 11], 1
bitmap.render ['.', '_', '+', '@'] # => "..._\n..+@"

Считайте, че в списъка с числа ще са ви подадени винаги валидни байтове (между 0 и 255) и че броят елементи в него ще е винаги кратен на опционалния аргумент, когато такъв е подаден. Тоест, няма да ви подадем списък с три елемента и да искаме да рендерирате битова карта с по два байта на ред.

Решения

Пламен Стоев
  • Коректно
  • 5 успешни тест(а)
  • 0 неуспешни тест(а)
Пламен Стоев
class Bitmap
def initialize(bytes, row_count = bytes.length)
@bytes = bytes
@row_count = row_count
end
def render(palette = ['.', '#'])
@bytes.each_slice(@row_count).map do |row|
row.map { |byte| render_byte(byte, palette) }.join('')
end.join("\n")
end
private
def render_byte(byte, palette)
mask = palette.size - 1
(0..7).step(Math.log2(palette.size)).map do |part|
palette[((byte & (mask << part)) >> part)]
end.reverse
end
end
.....

Finished in 0.0514 seconds
5 examples, 0 failures
Георги Гърдев
  • Некоректно
  • 4 успешни тест(а)
  • 1 неуспешни тест(а)
Георги Гърдев
class Bitmap
def initialize(bytes, per_line = nil)
@bytes = bytes
@per_line = per_line || @bytes.size
end
def render(palette = ['.', '#'])
to_pixels(palette).each_slice(@per_line).map(&:join).join("\n")
end
private
def to_pixels(palette)
@bytes.map do |byte|
base = palette.size
pixels_in_byte = 8 / (base - 1).to_s(2).size
byte = byte.to_s(base)
# make all bytes of even length
byte.prepend '0' * (pixels_in_byte - byte.size)
# colorize
byte.chars.map { |pixel| palette[pixel.to_i] }.join
end
end
end
....F

Failures:

  1) Bitmap renders La Gioconda
     Failure/Error: Bitmap.new(the_bitmap, 37).render(["!", "\n", ">", "'", "<", "`", " ", ".", ";", ",", "c", "d", "-", "\"", "?", "$"]).should eq expectation
       
       expected: "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!>''''''<!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!'''''`             ``'!!!!!!!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!!!!!!''`          .....         `'!!!!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!!!'`      .      ;;;;;'            `'!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!'     .   '     .;;;;'                `!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!'      ;          `````                   `!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!        .,ccdcccccc,,.                       `!!!!!!!!!!!!\n!!!!!!!!!!!!!!!     .-\"?$$$$$$$$$$$$$$c,                      `!!!!!!!!!!!\n!!!!!!!!!!!!!!    ,ccc$$$$$$$$$$$$$$$$$$$,                     `!!!!!!!!!!\n!!!!!!!!!!!!!    d$$$$$$$$$$$$$$$$$$$$$$$$;.                    `!!!!!!!!!\n!!!!!!!!!!!!    <$$$$$$$$$$$$$$$$$$$$$$$$$$;.                    `!!!!!!!!\n!!!!!!!!!!!     $$$$$$$$$$$$$$$$$$$$$$$$$$$d;;.                   !!!!!!!!\n!!!!!!!!!!'     $$$$$$$$$$$$$$$$$$$$$$$$$$$$$d;.                   !!!!!!!\n!!!!!!!!!'     <$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$                   !!!!!!!\n!!!!!!!!'      `$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$                   `!!!!!!\n!!!!!!!!        c$$$$???$$$$$$$d\"\"  \"\"\"??????\"                      !!!!!!\n!!!!!!!         `\"\" .,.. \"$$$$$    .,dcd                            !!!!!!\n!!!!!!!         .  d!    .?$$$   .,cc,      .,d$d.                  !!!!!!\n!!!!!!!!        <. $$c- <$d$$$   <$$$$---$\"$$$$$$$                  !!!!!!\n!!!!!!!         d$$$dcccd$$$$$   d$$$dcccd$$$$$$$$                  `!!!!!\n!!!!!!         ,$$$$$$$$$$$$$$d d$$$$$$$$$$$$$$$$                   `!!!!!\n!!!!!          `$$$$$$$$$$$$$$$<$$$$$$$$$$$$$$$$'                    !!!!!\n!!!!!          `$$$$$$$$$$$$$$$$\"$$$$$$$$$$$$$d>                     !!!!!\n!!!!!           ?$$$$$$$$$$$$??$c`$$$$$$$$$$$?>'                     `!!!!\n!!!!!           `?$$$$$$!>?\"\"    ,$$$$$$$$$?>>'                       !!!!\n!!!!!.           <<?$$$$$$c.    ,d$$?$$$$$$>>''                       `!!!\n!!!!!!            <!?$d\"??$$d--\"?\"\"  ,$$$$d;>''                       `!!!\n!!!!!!             $$$dccccccccc- cc$$$$$$$>>'                         !!!\n!!!!!              `?$$$$$$$\"\"\"\"  `\"$$$$$>>>''                         `!!\n!!!!!                \"?$$$$$cccccc$$$$??>>>>'                           !!\n!!!!>                  \"$$$$$$$$$$$$$$>>>>''                            `!\n!!!!!                    \"$$$$$$$$???>'''                                !\n!!!!!>                     `\"\"\"\"\"                                        `\n!!!!!!;                       .                                          `\n!!!!!!!                       ?d.                                         \n!!!!!!!!                       $$c,                                       \n!!!!!!!!>                      ?$$$d.              .,c                    \n!!!!!!!!!                       $$$$$$$$$dc,.,,cc$$$$$                    \n!!!!!!!!!                  .,dcc$$$$$$$$$$$$$$$$$$$$$$                    \n!!!!!!!!!               .d$$$$$$$$$$$$$$$$$$$$$$$$$$$$                    \n!!!!!!!!!             ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$          .         \n!!!!!!!!!           ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$         !!         \n!!!!!!!!!         ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$        ,!'         \n!!!!!!!!>        c$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$.       !'          \n!!!!!!''       ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$>       '           \n!!!''         d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$>                   \n!'           ,$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$>             ..    \n            d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$'           ;!!!!''`\n            $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$       ,;;!'`'  .'' \n           <$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$>    ,;'`'  ,;       \n           `$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$   -'   ,;!!'        \n            \"?$$$$$$$$$$?$$$$$$$$$$$$$$$$$$$$$$$$$$$     .<!!!'''       <!\n         !>    \"\"??$$$?<?$$$$$$$$$$$$$$$$$$$$$$$$\"\"     ;!'''          !!!\n       ;!!!!;,      `\"''\"\"????$$$$$$$$$$$$$$$$\"\"   ,;-''               ',!\n      ;!!!!<!!!; .                `\"\"\"\"\"\"\"\"\"\"\"    `'                  ' ' \n      !!!! ;!!! ;!!!!>;,;, ..                  ' .                   '  ' \n     !!' ,;!!! ;'`!!!!!!!!;!!!!!;  .        >' .''                 ;      \n    !!' ;!!'!';! !! !!!!!!!!!!!!!  '         -'                           \n   <!!  !! `!;! `!' !!!!!!!!!!<!       .                                  \n   `!  ;!  ;!!! <' <!!!! `!!! <       !                                   \n  `;   !>  <!! ;'  !!!!'  !!';!     ;'                                    \n   !   !   !!! !   `!!!  ;!! !      '  '                                  \n  ;   `!  `!! ,'    !'   ;!'                                              \n      '   !`! !    <     !! <      '                                      \n           ! ;!        >;! ;>                                             \n             !'       ; !! '                                              \n          ' ;!        > ! '                                               \n            '                                                             "
            got: "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!>''''''<!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!'''''`             ``'!!!!!!!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!!!!!!''`          .....         `'!!!!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!!!'`      .      ;;;;;'            `'!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!'     .   '     .;;;;'                `!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!'      ;          `````                   `!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!        .,!!!!!!!!!,,.                       `!!!!!!!!!!!!\n!!!!!!!!!!!!!!!     .!!!!!!!!!!!!!!!!!!,                      `!!!!!!!!!!!\n!!!!!!!!!!!!!!    ,!!!!!!!!!!!!!!!!!!!!!!,                     `!!!!!!!!!!\n!!!!!!!!!!!!!    !!!!!!!!!!!!!!!!!!!!!!!!!;.                    `!!!!!!!!!\n!!!!!!!!!!!!    <!!!!!!!!!!!!!!!!!!!!!!!!!!;.                    `!!!!!!!!\n!!!!!!!!!!!     !!!!!!!!!!!!!!!!!!!!!!!!!!!!;;.                   !!!!!!!!\n!!!!!!!!!!'     !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!;.                   !!!!!!!\n!!!!!!!!!'     <!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!                   !!!!!!!\n!!!!!!!!'      `!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!                   `!!!!!!\n!!!!!!!!        !!!!!!!!!!!!!!!!!!  !!!!!!!!!!                      !!!!!!\n!!!!!!!         `!! .,.. !!!!!!    .,!!!                            !!!!!!\n!!!!!!!         .  !!    .!!!!   .,!!,      .,!!!.                  !!!!!!\n!!!!!!!!        <. !!!! <!!!!!   <!!!!!!!!!!!!!!!!                  !!!!!!\n!!!!!!!         !!!!!!!!!!!!!!   !!!!!!!!!!!!!!!!!                  `!!!!!\n!!!!!!         ,!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!                   `!!!!!\n!!!!!          `!!!!!!!!!!!!!!!<!!!!!!!!!!!!!!!!'                    !!!!!\n!!!!!          `!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!>                     !!!!!\n!!!!!           !!!!!!!!!!!!!!!!!`!!!!!!!!!!!!>'                     `!!!!\n!!!!!           `!!!!!!!!>!!!    ,!!!!!!!!!!>>'                       !!!!\n!!!!!.           <<!!!!!!!!.    ,!!!!!!!!!!>>''                       `!!!\n!!!!!!            <!!!!!!!!!!!!!!!!  ,!!!!!;>''                       `!!!\n!!!!!!             !!!!!!!!!!!!!! !!!!!!!!!>>'                         !!!\n!!!!!              `!!!!!!!!!!!!  `!!!!!!>>>''                         `!!\n!!!!!                !!!!!!!!!!!!!!!!!!!>>>>'                           !!\n!!!!>                  !!!!!!!!!!!!!!!>>>>''                            `!\n!!!!!                    !!!!!!!!!!!!>'''                                !\n!!!!!>                     `!!!!!                                        `\n!!!!!!;                       .                                          `\n!!!!!!!                       !!.                                         \n!!!!!!!!                       !!!,                                       \n!!!!!!!!>                      !!!!!.              .,!                    \n!!!!!!!!!                       !!!!!!!!!!!,.,,!!!!!!!                    \n!!!!!!!!!                  .,!!!!!!!!!!!!!!!!!!!!!!!!!                    \n!!!!!!!!!               .!!!!!!!!!!!!!!!!!!!!!!!!!!!!!                    \n!!!!!!!!!             ,!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!          .         \n!!!!!!!!!           ,!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!         !!         \n!!!!!!!!!         ,!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!        ,!'         \n!!!!!!!!>        !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!.       !'          \n!!!!!!''       ,!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!>       '           \n!!!''         !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!>                   \n!'           ,!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!>             ..    \n            !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'           ;!!!!''`\n            !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!       ,;;!'`'  .'' \n           <!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!>    ,;'`'  ,;       \n           `!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!   !'   ,;!!'        \n            !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!     .<!!!'''       <!\n         !>    !!!!!!!!<!!!!!!!!!!!!!!!!!!!!!!!!!!!     ;!'''          !!!\n       ;!!!!;,      `!''!!!!!!!!!!!!!!!!!!!!!!!!   ,;!''               ',!\n      ;!!!!<!!!; .                `!!!!!!!!!!!    `'                  ' ' \n      !!!! ;!!! ;!!!!>;,;, ..                  ' .                   '  ' \n     !!' ,;!!! ;'`!!!!!!!!;!!!!!;  .        >' .''                 ;      \n    !!' ;!!'!';! !! !!!!!!!!!!!!!  '         !'                           \n   <!!  !! `!;! `!' !!!!!!!!!!<!       .                                  \n   `!  ;!  ;!!! <' <!!!! `!!! <       !                                   \n  `;   !>  <!! ;'  !!!!'  !!';!     ;'                                    \n   !   !   !!! !   `!!!  ;!! !      '  '                                  \n  ;   `!  `!! ,'    !'   ;!'                                              \n      '   !`! !    <     !! <      '                                      \n           ! ;!        >;! ;>                                             \n             !'       ; !! '                                              \n          ' ;!        > ! '                                               \n            '                                                             "
       
       (compared using ==)
       
       Diff:
       
       
       @@ -6,58 +6,58 @@
        !!!!!!!!!!!!!!!!!!!!!'`      .      ;;;;;'            `'!!!!!!!!!!!!!!!!!!
        !!!!!!!!!!!!!!!!!!!'     .   '     .;;;;'                `!!!!!!!!!!!!!!!!
        !!!!!!!!!!!!!!!!!'      ;          `````                   `!!!!!!!!!!!!!!
       -!!!!!!!!!!!!!!!!        .,ccdcccccc,,.                       `!!!!!!!!!!!!
       -!!!!!!!!!!!!!!!     .-"?$$$$$$$$$$$$$$c,                      `!!!!!!!!!!!
       -!!!!!!!!!!!!!!    ,ccc$$$$$$$$$$$$$$$$$$$,                     `!!!!!!!!!!
       -!!!!!!!!!!!!!    d$$$$$$$$$$$$$$$$$$$$$$$$;.                    `!!!!!!!!!
       -!!!!!!!!!!!!    <$$$$$$$$$$$$$$$$$$$$$$$$$$;.                    `!!!!!!!!
       -!!!!!!!!!!!     $$$$$$$$$$$$$$$$$$$$$$$$$$$d;;.                   !!!!!!!!
       -!!!!!!!!!!'     $$$$$$$$$$$$$$$$$$$$$$$$$$$$$d;.                   !!!!!!!
       -!!!!!!!!!'     <$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$                   !!!!!!!
       -!!!!!!!!'      `$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$                   `!!!!!!
       -!!!!!!!!        c$$$$???$$$$$$$d""  """??????"                      !!!!!!
       -!!!!!!!         `"" .,.. "$$$$$    .,dcd                            !!!!!!
       -!!!!!!!         .  d!    .?$$$   .,cc,      .,d$d.                  !!!!!!
       -!!!!!!!!        <. $$c- <$d$$$   <$$$$---$"$$$$$$$                  !!!!!!
       -!!!!!!!         d$$$dcccd$$$$$   d$$$dcccd$$$$$$$$                  `!!!!!
       -!!!!!!         ,$$$$$$$$$$$$$$d d$$$$$$$$$$$$$$$$                   `!!!!!
       -!!!!!          `$$$$$$$$$$$$$$$<$$$$$$$$$$$$$$$$'                    !!!!!
       -!!!!!          `$$$$$$$$$$$$$$$$"$$$$$$$$$$$$$d>                     !!!!!
       -!!!!!           ?$$$$$$$$$$$$??$c`$$$$$$$$$$$?>'                     `!!!!
       -!!!!!           `?$$$$$$!>?""    ,$$$$$$$$$?>>'                       !!!!
       -!!!!!.           <<?$$$$$$c.    ,d$$?$$$$$$>>''                       `!!!
       -!!!!!!            <!?$d"??$$d--"?""  ,$$$$d;>''                       `!!!
       -!!!!!!             $$$dccccccccc- cc$$$$$$$>>'                         !!!
       -!!!!!              `?$$$$$$$""""  `"$$$$$>>>''                         `!!
       -!!!!!                "?$$$$$cccccc$$$$??>>>>'                           !!
       -!!!!>                  "$$$$$$$$$$$$$$>>>>''                            `!
       -!!!!!                    "$$$$$$$$???>'''                                !
       -!!!!!>                     `"""""                                        `
       +!!!!!!!!!!!!!!!!        .,!!!!!!!!!,,.                       `!!!!!!!!!!!!
       +!!!!!!!!!!!!!!!     .!!!!!!!!!!!!!!!!!!,                      `!!!!!!!!!!!
       +!!!!!!!!!!!!!!    ,!!!!!!!!!!!!!!!!!!!!!!,                     `!!!!!!!!!!
       +!!!!!!!!!!!!!    !!!!!!!!!!!!!!!!!!!!!!!!!;.                    `!!!!!!!!!
       +!!!!!!!!!!!!    <!!!!!!!!!!!!!!!!!!!!!!!!!!;.                    `!!!!!!!!
       +!!!!!!!!!!!     !!!!!!!!!!!!!!!!!!!!!!!!!!!!;;.                   !!!!!!!!
       +!!!!!!!!!!'     !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!;.                   !!!!!!!
       +!!!!!!!!!'     <!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!                   !!!!!!!
       +!!!!!!!!'      `!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!                   `!!!!!!
       +!!!!!!!!        !!!!!!!!!!!!!!!!!!  !!!!!!!!!!                      !!!!!!
       +!!!!!!!         `!! .,.. !!!!!!    .,!!!                            !!!!!!
       +!!!!!!!         .  !!    .!!!!   .,!!,      .,!!!.                  !!!!!!
       +!!!!!!!!        <. !!!! <!!!!!   <!!!!!!!!!!!!!!!!                  !!!!!!
       +!!!!!!!         !!!!!!!!!!!!!!   !!!!!!!!!!!!!!!!!                  `!!!!!
       +!!!!!!         ,!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!                   `!!!!!
       +!!!!!          `!!!!!!!!!!!!!!!<!!!!!!!!!!!!!!!!'                    !!!!!
       +!!!!!          `!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!>                     !!!!!
       +!!!!!           !!!!!!!!!!!!!!!!!`!!!!!!!!!!!!>'                     `!!!!
       +!!!!!           `!!!!!!!!>!!!    ,!!!!!!!!!!>>'                       !!!!
       +!!!!!.           <<!!!!!!!!.    ,!!!!!!!!!!>>''                       `!!!
       +!!!!!!            <!!!!!!!!!!!!!!!!  ,!!!!!;>''                       `!!!
       +!!!!!!             !!!!!!!!!!!!!! !!!!!!!!!>>'                         !!!
       +!!!!!              `!!!!!!!!!!!!  `!!!!!!>>>''                         `!!
       +!!!!!                !!!!!!!!!!!!!!!!!!!>>>>'                           !!
       +!!!!>                  !!!!!!!!!!!!!!!>>>>''                            `!
       +!!!!!                    !!!!!!!!!!!!>'''                                !
       +!!!!!>                     `!!!!!                                        `
        !!!!!!;                       .                                          `
       -!!!!!!!                       ?d.                                         
       -!!!!!!!!                       $$c,                                       
       -!!!!!!!!>                      ?$$$d.              .,c                    
       -!!!!!!!!!                       $$$$$$$$$dc,.,,cc$$$$$                    
       -!!!!!!!!!                  .,dcc$$$$$$$$$$$$$$$$$$$$$$                    
       -!!!!!!!!!               .d$$$$$$$$$$$$$$$$$$$$$$$$$$$$                    
       -!!!!!!!!!             ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$          .         
       -!!!!!!!!!           ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$         !!         
       -!!!!!!!!!         ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$        ,!'         
       -!!!!!!!!>        c$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$.       !'          
       -!!!!!!''       ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$>       '           
       -!!!''         d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$>                   
       -!'           ,$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$>             ..    
       -            d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$'           ;!!!!''`
       -            $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$       ,;;!'`'  .'' 
       -           <$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$>    ,;'`'  ,;       
       -           `$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$   -'   ,;!!'        
       -            "?$$$$$$$$$$?$$$$$$$$$$$$$$$$$$$$$$$$$$$     .<!!!'''       <!
       -         !>    ""??$$$?<?$$$$$$$$$$$$$$$$$$$$$$$$""     ;!'''          !!!
       -       ;!!!!;,      `"''""????$$$$$$$$$$$$$$$$""   ,;-''               ',!
       -      ;!!!!<!!!; .                `"""""""""""    `'                  ' ' 
       +!!!!!!!                       !!.                                         
       +!!!!!!!!                       !!!,                                       
       +!!!!!!!!>                      !!!!!.              .,!                    
       +!!!!!!!!!                       !!!!!!!!!!!,.,,!!!!!!!                    
       +!!!!!!!!!                  .,!!!!!!!!!!!!!!!!!!!!!!!!!                    
       +!!!!!!!!!               .!!!!!!!!!!!!!!!!!!!!!!!!!!!!!                    
       +!!!!!!!!!             ,!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!          .         
       +!!!!!!!!!           ,!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!         !!         
       +!!!!!!!!!         ,!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!        ,!'         
       +!!!!!!!!>        !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!.       !'          
       +!!!!!!''       ,!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!>       '           
       +!!!''         !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!>                   
       +!'           ,!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!>             ..    
       +            !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'           ;!!!!''`
       +            !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!       ,;;!'`'  .'' 
       +           <!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!>    ,;'`'  ,;       
       +           `!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!   !'   ,;!!'        
       +            !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!     .<!!!'''       <!
       +         !>    !!!!!!!!<!!!!!!!!!!!!!!!!!!!!!!!!!!!     ;!'''          !!!
       +       ;!!!!;,      `!''!!!!!!!!!!!!!!!!!!!!!!!!   ,;!''               ',!
       +      ;!!!!<!!!; .                `!!!!!!!!!!!    `'                  ' ' 
              !!!! ;!!! ;!!!!>;,;, ..                  ' .                   '  ' 
             !!' ,;!!! ;'`!!!!!!!!;!!!!!;  .        >' .''                 ;      
       -    !!' ;!!'!';! !! !!!!!!!!!!!!!  '         -'                           
       +    !!' ;!!'!';! !! !!!!!!!!!!!!!  '         !'                           
           <!!  !! `!;! `!' !!!!!!!!!!<!       .                                  
           `!  ;!  ;!!! <' <!!!! `!!! <       !                                   
          `;   !>  <!! ;'  !!!!'  !!';!     ;'                                    
     # /tmp/d20131110-20795-e7u5v7/spec.rb:105:in `block (2 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

Finished in 0.03848 seconds
5 examples, 1 failure

Failed examples:

rspec /tmp/d20131110-20795-e7u5v7/spec.rb:31 # Bitmap renders La Gioconda
Стефан Василев
  • Коректно
  • 5 успешни тест(а)
  • 0 неуспешни тест(а)
Стефан Василев
class Bitmap
def initialize(array, lines = 0)
@sequence = array
@lines = lines
end
def render(symbols = ['.', '#'])
result, palette = "", generate_array_with_combinations(symbols.size)
slice_size = symbols.size == 256 ? 8 : (symbols.size ** 0.5).to_i
@sequence.each_index do |index|
number_to_push = "00000000".slice(1 , 8 - convert(@sequence[index]).to_s.size) + convert(@sequence[index]).to_s
number_to_push.chars.each_slice(slice_size) do |slice|
current_slice = slice.reduce { |result, item| result << item }
result << symbols[palette.index(current_slice)]
end
result << "\n" if @lines != 0 and (index + 1) % @lines == 0 and index != @sequence.size - 1
end
result
end
def convert(number)
return 0 if number.zero?
return number % 2 + convert(number / 2) * 10
end
def generate_array_with_combinations(size)
result = []
case size
when 2
result = ["0", "1"]
when 4
["0", "1"].each { |i| ["0", "1"].each { |j| result << i + j } }
when 16
["0", "1"].each { |i| ["0", "1"].each { |j| ["0", "1"].each { |k| ["0", "1"].each { |l| result << i + j + k + l } } } }
when 256
["0", "1"].each { |i| ["0", "1"].each { |j| ["0", "1"].each { |k| ["0", "1"].each { |l| ["0", "1"].each { |m| ["0", "1"].each { |n| ["0", "1"].each { |o| ["0", "1"].each { |p| result << i + j + k + l + m + n + o + p } } } } } } } }
end
result
end
end
.....

Finished in 0.07579 seconds
5 examples, 0 failures
Мария Митева
  • Коректно
  • 5 успешни тест(а)
  • 0 неуспешни тест(а)
Мария Митева
class Bitmap
def initialize(numbers, bytes_per_line=numbers.length)
@bytes = numbers
@bytes_per_line = bytes_per_line
end
def render(palette=['.', '#'])
get_numbers_as_bytes(palette.length)
palette_hash = {}
palette.each_with_index { |sym, index| palette_hash[index.to_s(palette.length)] = sym }
@bytes.map do |byte|
hash_byte = ""
byte.each_char { |c| hash_byte << palette_hash[c] }
hash_byte
end.each_slice(@bytes_per_line).map { |line| line.reduce { |a, b| a + b } }.reduce { |a, b| a + "\n" + b }
end
private
def get_numbers_as_bytes(length)
pixel_length = 8/Math.log2(length).to_i
@bytes = @bytes.map { |byte| ('0'*pixel_length + byte.to_s(length))[-pixel_length..-1] }
end
end
.....

Finished in 0.03051 seconds
5 examples, 0 failures
Слав Керемидчиев
  • Некоректно
  • 4 успешни тест(а)
  • 1 неуспешни тест(а)
Слав Керемидчиев
class Bitmap
attr_accessor :pixels, :bytes_per_line
def initialize(pixels, bytes_per_line = 0)
@pixels = pixels
@bytes_per_line = bytes_per_line
end
def render(palette = ['.', '#'])
to_numeral_system = @pixels.map { |pixel| pixel.to_s(palette.size) }
case palette.size
when 2
pixel_size = 8
when 4
pixel_size = 4
when 16
pixel_size = 2
when 32
pixel_size = 1
end
to_numeral_system = to_numeral_system.map do |element|
"0" * (pixel_size - element.size) + element
end
range = 0.upto(palette.size-1).map { |element| element.to_s(palette.size) }
alphabet = Hash[*palette.zip(range).flatten]
rended = ""
slices = bytes_per_line == 0 ? pixels.size : bytes_per_line
to_numeral_system.each_slice(slices) do |element|
element.join("").each_char { |symbol| rended += alphabet.key(symbol) }
rended += "\n"
end
rended.strip
end
end
....F

Failures:

  1) Bitmap renders La Gioconda
     Failure/Error: Bitmap.new(the_bitmap, 37).render(["!", "\n", ">", "'", "<", "`", " ", ".", ";", ",", "c", "d", "-", "\"", "?", "$"]).should eq expectation
       
       expected: "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!>''''''<!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!'''''`             ``'!!!!!!!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!!!!!!''`          .....         `'!!!!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!!!'`      .      ;;;;;'            `'!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!'     .   '     .;;;;'                `!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!'      ;          `````                   `!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!        .,ccdcccccc,,.                       `!!!!!!!!!!!!\n!!!!!!!!!!!!!!!     .-\"?$$$$$$$$$$$$$$c,                      `!!!!!!!!!!!\n!!!!!!!!!!!!!!    ,ccc$$$$$$$$$$$$$$$$$$$,                     `!!!!!!!!!!\n!!!!!!!!!!!!!    d$$$$$$$$$$$$$$$$$$$$$$$$;.                    `!!!!!!!!!\n!!!!!!!!!!!!    <$$$$$$$$$$$$$$$$$$$$$$$$$$;.                    `!!!!!!!!\n!!!!!!!!!!!     $$$$$$$$$$$$$$$$$$$$$$$$$$$d;;.                   !!!!!!!!\n!!!!!!!!!!'     $$$$$$$$$$$$$$$$$$$$$$$$$$$$$d;.                   !!!!!!!\n!!!!!!!!!'     <$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$                   !!!!!!!\n!!!!!!!!'      `$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$                   `!!!!!!\n!!!!!!!!        c$$$$???$$$$$$$d\"\"  \"\"\"??????\"                      !!!!!!\n!!!!!!!         `\"\" .,.. \"$$$$$    .,dcd                            !!!!!!\n!!!!!!!         .  d!    .?$$$   .,cc,      .,d$d.                  !!!!!!\n!!!!!!!!        <. $$c- <$d$$$   <$$$$---$\"$$$$$$$                  !!!!!!\n!!!!!!!         d$$$dcccd$$$$$   d$$$dcccd$$$$$$$$                  `!!!!!\n!!!!!!         ,$$$$$$$$$$$$$$d d$$$$$$$$$$$$$$$$                   `!!!!!\n!!!!!          `$$$$$$$$$$$$$$$<$$$$$$$$$$$$$$$$'                    !!!!!\n!!!!!          `$$$$$$$$$$$$$$$$\"$$$$$$$$$$$$$d>                     !!!!!\n!!!!!           ?$$$$$$$$$$$$??$c`$$$$$$$$$$$?>'                     `!!!!\n!!!!!           `?$$$$$$!>?\"\"    ,$$$$$$$$$?>>'                       !!!!\n!!!!!.           <<?$$$$$$c.    ,d$$?$$$$$$>>''                       `!!!\n!!!!!!            <!?$d\"??$$d--\"?\"\"  ,$$$$d;>''                       `!!!\n!!!!!!             $$$dccccccccc- cc$$$$$$$>>'                         !!!\n!!!!!              `?$$$$$$$\"\"\"\"  `\"$$$$$>>>''                         `!!\n!!!!!                \"?$$$$$cccccc$$$$??>>>>'                           !!\n!!!!>                  \"$$$$$$$$$$$$$$>>>>''                            `!\n!!!!!                    \"$$$$$$$$???>'''                                !\n!!!!!>                     `\"\"\"\"\"                                        `\n!!!!!!;                       .                                          `\n!!!!!!!                       ?d.                                         \n!!!!!!!!                       $$c,                                       \n!!!!!!!!>                      ?$$$d.              .,c                    \n!!!!!!!!!                       $$$$$$$$$dc,.,,cc$$$$$                    \n!!!!!!!!!                  .,dcc$$$$$$$$$$$$$$$$$$$$$$                    \n!!!!!!!!!               .d$$$$$$$$$$$$$$$$$$$$$$$$$$$$                    \n!!!!!!!!!             ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$          .         \n!!!!!!!!!           ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$         !!         \n!!!!!!!!!         ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$        ,!'         \n!!!!!!!!>        c$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$.       !'          \n!!!!!!''       ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$>       '           \n!!!''         d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$>                   \n!'           ,$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$>             ..    \n            d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$'           ;!!!!''`\n            $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$       ,;;!'`'  .'' \n           <$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$>    ,;'`'  ,;       \n           `$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$   -'   ,;!!'        \n            \"?$$$$$$$$$$?$$$$$$$$$$$$$$$$$$$$$$$$$$$     .<!!!'''       <!\n         !>    \"\"??$$$?<?$$$$$$$$$$$$$$$$$$$$$$$$\"\"     ;!'''          !!!\n       ;!!!!;,      `\"''\"\"????$$$$$$$$$$$$$$$$\"\"   ,;-''               ',!\n      ;!!!!<!!!; .                `\"\"\"\"\"\"\"\"\"\"\"    `'                  ' ' \n      !!!! ;!!! ;!!!!>;,;, ..                  ' .                   '  ' \n     !!' ,;!!! ;'`!!!!!!!!;!!!!!;  .        >' .''                 ;      \n    !!' ;!!'!';! !! !!!!!!!!!!!!!  '         -'                           \n   <!!  !! `!;! `!' !!!!!!!!!!<!       .                                  \n   `!  ;!  ;!!! <' <!!!! `!!! <       !                                   \n  `;   !>  <!! ;'  !!!!'  !!';!     ;'                                    \n   !   !   !!! !   `!!!  ;!! !      '  '                                  \n  ;   `!  `!! ,'    !'   ;!'                                              \n      '   !`! !    <     !! <      '                                      \n           ! ;!        >;! ;>                                             \n             !'       ; !! '                                              \n          ' ;!        > ! '                                               \n            '                                                             "
            got: "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!>''''''<!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!'''''`             ``'!!!!!!!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!!!!!!''`          .....         `'!!!!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!!!'`      .      ;;;;;'            `'!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!'     .   '     .;;;;'                `!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!'      ;          `````                   `!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!        .,ccdcccccc,,.                       `!!!!!!!!!!!!\n!!!!!!!!!!!!!!!     .-\"?$$$$$$$$$$$$$$c,                      `!!!!!!!!!!!\n!!!!!!!!!!!!!!    ,ccc$$$$$$$$$$$$$$$$$$$,                     `!!!!!!!!!!\n!!!!!!!!!!!!!    d$$$$$$$$$$$$$$$$$$$$$$$$;.                    `!!!!!!!!!\n!!!!!!!!!!!!    <$$$$$$$$$$$$$$$$$$$$$$$$$$;.                    `!!!!!!!!\n!!!!!!!!!!!     $$$$$$$$$$$$$$$$$$$$$$$$$$$d;;.                   !!!!!!!!\n!!!!!!!!!!'     $$$$$$$$$$$$$$$$$$$$$$$$$$$$$d;.                   !!!!!!!\n!!!!!!!!!'     <$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$                   !!!!!!!\n!!!!!!!!'      `$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$                   `!!!!!!\n!!!!!!!!        c$$$$???$$$$$$$d\"\"  \"\"\"??????\"                      !!!!!!\n!!!!!!!         `\"\" .,.. \"$$$$$    .,dcd                            !!!!!!\n!!!!!!!         .  d!    .?$$$   .,cc,      .,d$d.                  !!!!!!\n!!!!!!!!        <. $$c- <$d$$$   <$$$$---$\"$$$$$$$                  !!!!!!\n!!!!!!!         d$$$dcccd$$$$$   d$$$dcccd$$$$$$$$                  `!!!!!\n!!!!!!         ,$$$$$$$$$$$$$$d d$$$$$$$$$$$$$$$$                   `!!!!!\n!!!!!          `$$$$$$$$$$$$$$$<$$$$$$$$$$$$$$$$'                    !!!!!\n!!!!!          `$$$$$$$$$$$$$$$$\"$$$$$$$$$$$$$d>                     !!!!!\n!!!!!           ?$$$$$$$$$$$$??$c`$$$$$$$$$$$?>'                     `!!!!\n!!!!!           `?$$$$$$!>?\"\"    ,$$$$$$$$$?>>'                       !!!!\n!!!!!.           <<?$$$$$$c.    ,d$$?$$$$$$>>''                       `!!!\n!!!!!!            <!?$d\"??$$d--\"?\"\"  ,$$$$d;>''                       `!!!\n!!!!!!             $$$dccccccccc- cc$$$$$$$>>'                         !!!\n!!!!!              `?$$$$$$$\"\"\"\"  `\"$$$$$>>>''                         `!!\n!!!!!                \"?$$$$$cccccc$$$$??>>>>'                           !!\n!!!!>                  \"$$$$$$$$$$$$$$>>>>''                            `!\n!!!!!                    \"$$$$$$$$???>'''                                !\n!!!!!>                     `\"\"\"\"\"                                        `\n!!!!!!;                       .                                          `\n!!!!!!!                       ?d.                                         \n!!!!!!!!                       $$c,                                       \n!!!!!!!!>                      ?$$$d.              .,c                    \n!!!!!!!!!                       $$$$$$$$$dc,.,,cc$$$$$                    \n!!!!!!!!!                  .,dcc$$$$$$$$$$$$$$$$$$$$$$                    \n!!!!!!!!!               .d$$$$$$$$$$$$$$$$$$$$$$$$$$$$                    \n!!!!!!!!!             ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$          .         \n!!!!!!!!!           ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$         !!         \n!!!!!!!!!         ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$        ,!'         \n!!!!!!!!>        c$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$.       !'          \n!!!!!!''       ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$>       '           \n!!!''         d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$>                   \n!'           ,$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$>             ..    \n            d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$'           ;!!!!''`\n            $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$       ,;;!'`'  .'' \n           <$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$>    ,;'`'  ,;       \n           `$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$   -'   ,;!!'        \n            \"?$$$$$$$$$$?$$$$$$$$$$$$$$$$$$$$$$$$$$$     .<!!!'''       <!\n         !>    \"\"??$$$?<?$$$$$$$$$$$$$$$$$$$$$$$$\"\"     ;!'''          !!!\n       ;!!!!;,      `\"''\"\"????$$$$$$$$$$$$$$$$\"\"   ,;-''               ',!\n      ;!!!!<!!!; .                `\"\"\"\"\"\"\"\"\"\"\"    `'                  ' ' \n      !!!! ;!!! ;!!!!>;,;, ..                  ' .                   '  ' \n     !!' ,;!!! ;'`!!!!!!!!;!!!!!;  .        >' .''                 ;      \n    !!' ;!!'!';! !! !!!!!!!!!!!!!  '         -'                           \n   <!!  !! `!;! `!' !!!!!!!!!!<!       .                                  \n   `!  ;!  ;!!! <' <!!!! `!!! <       !                                   \n  `;   !>  <!! ;'  !!!!'  !!';!     ;'                                    \n   !   !   !!! !   `!!!  ;!! !      '  '                                  \n  ;   `!  `!! ,'    !'   ;!'                                              \n      '   !`! !    <     !! <      '                                      \n           ! ;!        >;! ;>                                             \n             !'       ; !! '                                              \n          ' ;!        > ! '                                               \n            '"
       
       (compared using ==)
       
       Diff:
       @@ -67,5 +67,5 @@
                   ! ;!        >;! ;>                                             
                     !'       ; !! '                                              
                  ' ;!        > ! '                                               
       -            '                                                             
       +            '
     # /tmp/d20131110-20795-hxwrj8/spec.rb:105:in `block (2 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

Finished in 0.07343 seconds
5 examples, 1 failure

Failed examples:

rspec /tmp/d20131110-20795-hxwrj8/spec.rb:31 # Bitmap renders La Gioconda
Петър Добрев
  • Коректно
  • 5 успешни тест(а)
  • 0 неуспешни тест(а)
Петър Добрев
class Bitmap
def initialize(bytes, byte_on_row = nil)
@bytes = bytes
@palette = ['.', '#']
@bytes_per_row = byte_on_row
end
def render(palette = nil)
@palette = palette unless palette == nil
color_size = Math.sqrt(@palette.size).to_i
bytes_to_str = @bytes.map { |x| x.to_s(2).rjust(8,'0')} .reduce(:+)
bytes_to_str = bytes_to_str.scan(/.{#{color_size}}/)
bytes_to_str.map! { |x| @palette[x.to_i(2)] }. reduce(:+)
if @bytes_per_row == nil then
bytes_to_str.reduce(:+)
else
colors_on_row = 8 / color_size * @bytes_per_row
bytes_to_str.reduce(:+).scan(/.{#{colors_on_row}}|.+/).join("\n")[0..-1]
end
end
end
.....

Finished in 0.11798 seconds
5 examples, 0 failures
Иван Латунов
  • Некоректно
  • 4 успешни тест(а)
  • 1 неуспешни тест(а)
Иван Латунов
class Bitmap
@@DEFAULT_PALETTE = ['.','#']
def initialize(data, bytes_per_line=8)
@pixels = [data].flatten # just in case ( >___>)
@bytes_per_line = bytes_per_line
end
def render (palette=nil)
current_map = palette || @@DEFAULT_PALETTE
rendered_bytes = []
slice_size = current_map.length.to_s(2).count('0') # Huehuehue
@pixels.each_with_index do |pixel, index|
pixel_to_bin = '0' * (8 - pixel.to_s(2).length) + pixel.to_s(2)
pixel_to_bin = pixel_to_bin.chars.each_slice(slice_size).map(&:join)
pixel_to_bin.each {|number| rendered_bytes << current_map[number.to_i(2)]}
rendered_bytes << "\n" if (index + 1) % @bytes_per_line == 0
end
rendered_bytes.pop
rendered_bytes.join
end
end
F....

Failures:

  1) Bitmap renders bytes
     Failure/Error: expect(Bitmap.new([9, 32, 7]).render).to eq <<-ASCII.strip
       
       expected: "....#..#..#..........###"
            got: "....#..#..#..........##"
       
       (compared using ==)
     # /tmp/d20131110-20795-cx0yg8/spec.rb:3:in `block (2 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

Finished in 0.06866 seconds
5 examples, 1 failure

Failed examples:

rspec /tmp/d20131110-20795-cx0yg8/spec.rb:2 # Bitmap renders bytes
Десислав Илиев
  • Коректно
  • 5 успешни тест(а)
  • 0 неуспешни тест(а)
Десислав Илиев
class Bitmap
def initialize(numbers, length = numbers.size)
@length = length
@binaries = numbers.map! {|n| sprintf("%08b", n)}
end
def number_of_matches(length)
case length
when 2
['0','1']
when 4
['00', '01', '10', '11']
when 16
['0000', '0001', '0010', '0011', '0100', '0101', '0110', '0111', '1000', '1001', '1010', '1011', '1100', '1101', '1110', '1111']
end
end
def render(colors = ['.', '#'])
number_bineries_per_line = @length
final_render = ''
start = 0
available_matches = number_of_matches colors.size
iterator = 1
iterator = Math.sqrt(colors.size) if colors.size > 2
@binaries.each do |binarie|
while start < binarie.size
if number_bineries_per_line == 0
final_render += "\n"
number_bineries_per_line = @length
end
final_render += colors[available_matches.index(binarie[start, iterator])]
start += iterator
end
number_bineries_per_line -= 1
start = 0
end
final_render
end
attr_reader :binaries
attr_reader :length
end
.....

Finished in 0.06061 seconds
5 examples, 0 failures
Никола Ненков
  • Коректно
  • 5 успешни тест(а)
  • 0 неуспешни тест(а)
Никола Ненков
class Bitmap
@@bitmasks = [nil, 0b1, 0b11, nil, 0b1111]
def initialize(bytes, bytes_per_line = bytes.count)
@bytes = bytes
@bytes_per_line = bytes_per_line
end
def render(palette = ['.', '#'])
bits_per_pixel = Math.log2(palette.count).to_i
pixels_per_byte = 8 / bits_per_pixel
mask = @@bitmasks[bits_per_pixel]
reversed_pixelated_bytes = @bytes.map do |byte|
0.upto(pixels_per_byte.pred).map do |pixel_index|
palette[(byte >> bits_per_pixel * pixel_index) & mask]
end
end
pixelated_bytes = reversed_pixelated_bytes.map(&:reverse)
add_new_lines(pixelated_bytes).flatten.reduce(:+)
end
def add_new_lines(pixelated_bytes)
pixelated_bytes.each_with_index do |pixelated_byte, index|
pixelated_bytes[index] << "\n" if (index.next % @bytes_per_line).zero?
end
pixelated_bytes.last.delete("\n")
pixelated_bytes
end
end
.....

Finished in 0.05482 seconds
5 examples, 0 failures
Емануела Моллова
  • Некоректно
  • 4 успешни тест(а)
  • 1 неуспешни тест(а)
Емануела Моллова
class Bitmap
attr_accessor :bytes, :bytes_for_row
def initialize(bytes, bytes_for_row = 0)
@bytes, @bytes_for_row = bytes, bytes_for_row
end
def render(palette = ['.', '#'])
colors = palette.size
keys = (0..colors - 1).map do |number|
number.to_s(2).rjust(colors / 2, '0')
end
dictionary = Hash[keys.zip palette]
string = @bytes.map do |byte|
byte.to_s(2).rjust(8, '0')
end.join.gsub!(/[01]{#{colors / 2}}/, dictionary)
symbols_for_row = bytes_for_row.zero? ? string.size : bytes_for_row * 8 / (colors / 2)
string.chars.each_slice(symbols_for_row).to_a.map(&:join).join("\n")
end
end
....F

Failures:

  1) Bitmap renders La Gioconda
     Failure/Error: Bitmap.new(the_bitmap, 37).render(["!", "\n", ">", "'", "<", "`", " ", ".", ";", ",", "c", "d", "-", "\"", "?", "$"]).should eq expectation
       
       expected: "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!>''''''<!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!'''''`             ``'!!!!!!!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!!!!!!''`          .....         `'!!!!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!!!'`      .      ;;;;;'            `'!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!'     .   '     .;;;;'                `!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!'      ;          `````                   `!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!        .,ccdcccccc,,.                       `!!!!!!!!!!!!\n!!!!!!!!!!!!!!!     .-\"?$$$$$$$$$$$$$$c,                      `!!!!!!!!!!!\n!!!!!!!!!!!!!!    ,ccc$$$$$$$$$$$$$$$$$$$,                     `!!!!!!!!!!\n!!!!!!!!!!!!!    d$$$$$$$$$$$$$$$$$$$$$$$$;.                    `!!!!!!!!!\n!!!!!!!!!!!!    <$$$$$$$$$$$$$$$$$$$$$$$$$$;.                    `!!!!!!!!\n!!!!!!!!!!!     $$$$$$$$$$$$$$$$$$$$$$$$$$$d;;.                   !!!!!!!!\n!!!!!!!!!!'     $$$$$$$$$$$$$$$$$$$$$$$$$$$$$d;.                   !!!!!!!\n!!!!!!!!!'     <$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$                   !!!!!!!\n!!!!!!!!'      `$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$                   `!!!!!!\n!!!!!!!!        c$$$$???$$$$$$$d\"\"  \"\"\"??????\"                      !!!!!!\n!!!!!!!         `\"\" .,.. \"$$$$$    .,dcd                            !!!!!!\n!!!!!!!         .  d!    .?$$$   .,cc,      .,d$d.                  !!!!!!\n!!!!!!!!        <. $$c- <$d$$$   <$$$$---$\"$$$$$$$                  !!!!!!\n!!!!!!!         d$$$dcccd$$$$$   d$$$dcccd$$$$$$$$                  `!!!!!\n!!!!!!         ,$$$$$$$$$$$$$$d d$$$$$$$$$$$$$$$$                   `!!!!!\n!!!!!          `$$$$$$$$$$$$$$$<$$$$$$$$$$$$$$$$'                    !!!!!\n!!!!!          `$$$$$$$$$$$$$$$$\"$$$$$$$$$$$$$d>                     !!!!!\n!!!!!           ?$$$$$$$$$$$$??$c`$$$$$$$$$$$?>'                     `!!!!\n!!!!!           `?$$$$$$!>?\"\"    ,$$$$$$$$$?>>'                       !!!!\n!!!!!.           <<?$$$$$$c.    ,d$$?$$$$$$>>''                       `!!!\n!!!!!!            <!?$d\"??$$d--\"?\"\"  ,$$$$d;>''                       `!!!\n!!!!!!             $$$dccccccccc- cc$$$$$$$>>'                         !!!\n!!!!!              `?$$$$$$$\"\"\"\"  `\"$$$$$>>>''                         `!!\n!!!!!                \"?$$$$$cccccc$$$$??>>>>'                           !!\n!!!!>                  \"$$$$$$$$$$$$$$>>>>''                            `!\n!!!!!                    \"$$$$$$$$???>'''                                !\n!!!!!>                     `\"\"\"\"\"                                        `\n!!!!!!;                       .                                          `\n!!!!!!!                       ?d.                                         \n!!!!!!!!                       $$c,                                       \n!!!!!!!!>                      ?$$$d.              .,c                    \n!!!!!!!!!                       $$$$$$$$$dc,.,,cc$$$$$                    \n!!!!!!!!!                  .,dcc$$$$$$$$$$$$$$$$$$$$$$                    \n!!!!!!!!!               .d$$$$$$$$$$$$$$$$$$$$$$$$$$$$                    \n!!!!!!!!!             ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$          .         \n!!!!!!!!!           ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$         !!         \n!!!!!!!!!         ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$        ,!'         \n!!!!!!!!>        c$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$.       !'          \n!!!!!!''       ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$>       '           \n!!!''         d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$>                   \n!'           ,$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$>             ..    \n            d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$'           ;!!!!''`\n            $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$       ,;;!'`'  .'' \n           <$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$>    ,;'`'  ,;       \n           `$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$   -'   ,;!!'        \n            \"?$$$$$$$$$$?$$$$$$$$$$$$$$$$$$$$$$$$$$$     .<!!!'''       <!\n         !>    \"\"??$$$?<?$$$$$$$$$$$$$$$$$$$$$$$$\"\"     ;!'''          !!!\n       ;!!!!;,      `\"''\"\"????$$$$$$$$$$$$$$$$\"\"   ,;-''               ',!\n      ;!!!!<!!!; .                `\"\"\"\"\"\"\"\"\"\"\"    `'                  ' ' \n      !!!! ;!!! ;!!!!>;,;, ..                  ' .                   '  ' \n     !!' ,;!!! ;'`!!!!!!!!;!!!!!;  .        >' .''                 ;      \n    !!' ;!!'!';! !! !!!!!!!!!!!!!  '         -'                           \n   <!!  !! `!;! `!' !!!!!!!!!!<!       .                                  \n   `!  ;!  ;!!! <' <!!!! `!!! <       !                                   \n  `;   !>  <!! ;'  !!!!'  !!';!     ;'                                    \n   !   !   !!! !   `!!!  ;!! !      '  '                                  \n  ;   `!  `!! ,'    !'   ;!'                                              \n      '   !`! !    <     !! <      '                                      \n           ! ;!        >;! ;>                                             \n             !'       ; !! '                                              \n          ' ;!        > ! '                                               \n            '                                                             "
            got: "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!'!!!!!!!!!!!!!!!!!!'\n!!!!!!!!!!!!!!!!'!!!!!!!!!!!!!!!!!!!!\n!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!! !!!!\n!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!'!!!!\n!!!!!!!!!!!!!!!! !!!!!!  !!!!!!!!!!!!\n! !!!!!!!!! !!!! !!!! !!!! >!!!!.!!!!\n!!!!!!! !!! !!!!! !!>!!!!!! !!!!!!!!!\n!!! !!!! !!!! !!!! !!!!  !!!! !!!!'!!\n!!''!'''!!!!!<!;!!! !>'!!!!!!!!'' !!!\n!!! !!; !!!!!  ! !!!  !!'! !! ! ''`  \n  ! "
       
       (compared using ==)
       
       Diff:
       @@ -1,71 +1,16 @@
       -!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
       -!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
       -!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!>''''''<!!!!!!!!!!!!!!!!!!!!!!!!!!!!
       -!!!!!!!!!!!!!!!!!!!!!!!!!!!!'''''`             ``'!!!!!!!!!!!!!!!!!!!!!!!!
       -!!!!!!!!!!!!!!!!!!!!!!!!''`          .....         `'!!!!!!!!!!!!!!!!!!!!!
       -!!!!!!!!!!!!!!!!!!!!!'`      .      ;;;;;'            `'!!!!!!!!!!!!!!!!!!
       -!!!!!!!!!!!!!!!!!!!'     .   '     .;;;;'                `!!!!!!!!!!!!!!!!
       -!!!!!!!!!!!!!!!!!'      ;          `````                   `!!!!!!!!!!!!!!
       -!!!!!!!!!!!!!!!!        .,ccdcccccc,,.                       `!!!!!!!!!!!!
       -!!!!!!!!!!!!!!!     .-"?$$$$$$$$$$$$$$c,                      `!!!!!!!!!!!
       -!!!!!!!!!!!!!!    ,ccc$$$$$$$$$$$$$$$$$$$,                     `!!!!!!!!!!
       -!!!!!!!!!!!!!    d$$$$$$$$$$$$$$$$$$$$$$$$;.                    `!!!!!!!!!
       -!!!!!!!!!!!!    <$$$$$$$$$$$$$$$$$$$$$$$$$$;.                    `!!!!!!!!
       -!!!!!!!!!!!     $$$$$$$$$$$$$$$$$$$$$$$$$$$d;;.                   !!!!!!!!
       -!!!!!!!!!!'     $$$$$$$$$$$$$$$$$$$$$$$$$$$$$d;.                   !!!!!!!
       -!!!!!!!!!'     <$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$                   !!!!!!!
       -!!!!!!!!'      `$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$                   `!!!!!!
       -!!!!!!!!        c$$$$???$$$$$$$d""  """??????"                      !!!!!!
       -!!!!!!!         `"" .,.. "$$$$$    .,dcd                            !!!!!!
       -!!!!!!!         .  d!    .?$$$   .,cc,      .,d$d.                  !!!!!!
       -!!!!!!!!        <. $$c- <$d$$$   <$$$$---$"$$$$$$$                  !!!!!!
       -!!!!!!!         d$$$dcccd$$$$$   d$$$dcccd$$$$$$$$                  `!!!!!
       -!!!!!!         ,$$$$$$$$$$$$$$d d$$$$$$$$$$$$$$$$                   `!!!!!
       -!!!!!          `$$$$$$$$$$$$$$$<$$$$$$$$$$$$$$$$'                    !!!!!
       -!!!!!          `$$$$$$$$$$$$$$$$"$$$$$$$$$$$$$d>                     !!!!!
       -!!!!!           ?$$$$$$$$$$$$??$c`$$$$$$$$$$$?>'                     `!!!!
       -!!!!!           `?$$$$$$!>?""    ,$$$$$$$$$?>>'                       !!!!
       -!!!!!.           <<?$$$$$$c.    ,d$$?$$$$$$>>''                       `!!!
       -!!!!!!            <!?$d"??$$d--"?""  ,$$$$d;>''                       `!!!
       -!!!!!!             $$$dccccccccc- cc$$$$$$$>>'                         !!!
       -!!!!!              `?$$$$$$$""""  `"$$$$$>>>''                         `!!
       -!!!!!                "?$$$$$cccccc$$$$??>>>>'                           !!
       -!!!!>                  "$$$$$$$$$$$$$$>>>>''                            `!
       -!!!!!                    "$$$$$$$$???>'''                                !
       -!!!!!>                     `"""""                                        `
       -!!!!!!;                       .                                          `
       -!!!!!!!                       ?d.                                         
       -!!!!!!!!                       $$c,                                       
       -!!!!!!!!>                      ?$$$d.              .,c                    
       -!!!!!!!!!                       $$$$$$$$$dc,.,,cc$$$$$                    
       -!!!!!!!!!                  .,dcc$$$$$$$$$$$$$$$$$$$$$$                    
       -!!!!!!!!!               .d$$$$$$$$$$$$$$$$$$$$$$$$$$$$                    
       -!!!!!!!!!             ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$          .         
       -!!!!!!!!!           ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$         !!         
       -!!!!!!!!!         ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$        ,!'         
       -!!!!!!!!>        c$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$.       !'          
       -!!!!!!''       ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$>       '           
       -!!!''         d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$>                   
       -!'           ,$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$>             ..    
       -            d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$'           ;!!!!''`
       -            $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$       ,;;!'`'  .'' 
       -           <$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$>    ,;'`'  ,;       
       -           `$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$   -'   ,;!!'        
       -            "?$$$$$$$$$$?$$$$$$$$$$$$$$$$$$$$$$$$$$$     .<!!!'''       <!
       -         !>    ""??$$$?<?$$$$$$$$$$$$$$$$$$$$$$$$""     ;!'''          !!!
       -       ;!!!!;,      `"''""????$$$$$$$$$$$$$$$$""   ,;-''               ',!
       -      ;!!!!<!!!; .                `"""""""""""    `'                  ' ' 
       -      !!!! ;!!! ;!!!!>;,;, ..                  ' .                   '  ' 
       -     !!' ,;!!! ;'`!!!!!!!!;!!!!!;  .        >' .''                 ;      
       -    !!' ;!!'!';! !! !!!!!!!!!!!!!  '         -'                           
       -   <!!  !! `!;! `!' !!!!!!!!!!<!       .                                  
       -   `!  ;!  ;!!! <' <!!!! `!!! <       !                                   
       -  `;   !>  <!! ;'  !!!!'  !!';!     ;'                                    
       -   !   !   !!! !   `!!!  ;!! !      '  '                                  
       -  ;   `!  `!! ,'    !'   ;!'                                              
       -      '   !`! !    <     !! <      '                                      
       -           ! ;!        >;! ;>                                             
       -             !'       ; !! '                                              
       -          ' ;!        > ! '                                               
       -            '                                                             
       +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
       +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
       +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
       +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
       +!!!!!!!!!!!!!!!!!'!!!!!!!!!!!!!!!!!!'
       +!!!!!!!!!!!!!!!!'!!!!!!!!!!!!!!!!!!!!
       +!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!! !!!!
       +!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!'!!!!
       +!!!!!!!!!!!!!!!! !!!!!!  !!!!!!!!!!!!
       +! !!!!!!!!! !!!! !!!! !!!! >!!!!.!!!!
       +!!!!!!! !!! !!!!! !!>!!!!!! !!!!!!!!!
       +!!! !!!! !!!! !!!! !!!!  !!!! !!!!'!!
       +!!''!'''!!!!!<!;!!! !>'!!!!!!!!'' !!!
       +!!! !!; !!!!!  ! !!!  !!'! !! ! ''`  
       +  ! 
     # /tmp/d20131110-20795-1vciugm/spec.rb:105:in `block (2 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

Finished in 0.02553 seconds
5 examples, 1 failure

Failed examples:

rspec /tmp/d20131110-20795-1vciugm/spec.rb:31 # Bitmap renders La Gioconda
Георги Кръстев
  • Коректно
  • 5 успешни тест(а)
  • 0 неуспешни тест(а)
Георги Кръстев
class Bitmap
def initialize(bytes, width = bytes.length)
@bytes = bytes
@width = width
end
def render(palette = ['.', '#'])
bits = @bytes.flat_map { |byte| ("%08b" % byte).chars }
depth = Math.log2(palette.length)
samples = bits.each_slice(depth).map { |slice| palette[slice.join.to_i 2] }
samples.each_slice(@width * 8 / depth).map(&:join).join("\n")
end
end
.....

Finished in 0.05504 seconds
5 examples, 0 failures
Георги Ангелов
  • Некоректно
  • 4 успешни тест(а)
  • 1 неуспешни тест(а)
Георги Ангелов
class Bitmap
def initialize(bitmap_data, bytes_on_line=bitmap_data.size)
@bitmap = bitmap_data
@bytes_on_line = bytes_on_line
end
def render(palette=['.', '#'])
bits_per_pixel = Math.log(palette.size, 2).to_i
pixels = enum_for(:each_pixel, bits_per_pixel)
.map { |pixel| palette[pixel] }
.each_slice(@bytes_on_line * 8 / bits_per_pixel)
.map { |slice| slice + ["\n"] }
.join
.strip
end
def each_pixel(bits_per_pixel)
bit_mask = ~(255 >> bits_per_pixel) & 255
pixels_per_byte = 8 / bits_per_pixel
@bitmap.each do |byte|
pixels_per_byte.times do
yield (byte & bit_mask) >> (8 - bits_per_pixel)
byte <<= bits_per_pixel
end
end
end
end
....F

Failures:

  1) Bitmap renders La Gioconda
     Failure/Error: Bitmap.new(the_bitmap, 37).render(["!", "\n", ">", "'", "<", "`", " ", ".", ";", ",", "c", "d", "-", "\"", "?", "$"]).should eq expectation
       
       expected: "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!>''''''<!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!'''''`             ``'!!!!!!!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!!!!!!''`          .....         `'!!!!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!!!'`      .      ;;;;;'            `'!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!'     .   '     .;;;;'                `!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!'      ;          `````                   `!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!        .,ccdcccccc,,.                       `!!!!!!!!!!!!\n!!!!!!!!!!!!!!!     .-\"?$$$$$$$$$$$$$$c,                      `!!!!!!!!!!!\n!!!!!!!!!!!!!!    ,ccc$$$$$$$$$$$$$$$$$$$,                     `!!!!!!!!!!\n!!!!!!!!!!!!!    d$$$$$$$$$$$$$$$$$$$$$$$$;.                    `!!!!!!!!!\n!!!!!!!!!!!!    <$$$$$$$$$$$$$$$$$$$$$$$$$$;.                    `!!!!!!!!\n!!!!!!!!!!!     $$$$$$$$$$$$$$$$$$$$$$$$$$$d;;.                   !!!!!!!!\n!!!!!!!!!!'     $$$$$$$$$$$$$$$$$$$$$$$$$$$$$d;.                   !!!!!!!\n!!!!!!!!!'     <$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$                   !!!!!!!\n!!!!!!!!'      `$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$                   `!!!!!!\n!!!!!!!!        c$$$$???$$$$$$$d\"\"  \"\"\"??????\"                      !!!!!!\n!!!!!!!         `\"\" .,.. \"$$$$$    .,dcd                            !!!!!!\n!!!!!!!         .  d!    .?$$$   .,cc,      .,d$d.                  !!!!!!\n!!!!!!!!        <. $$c- <$d$$$   <$$$$---$\"$$$$$$$                  !!!!!!\n!!!!!!!         d$$$dcccd$$$$$   d$$$dcccd$$$$$$$$                  `!!!!!\n!!!!!!         ,$$$$$$$$$$$$$$d d$$$$$$$$$$$$$$$$                   `!!!!!\n!!!!!          `$$$$$$$$$$$$$$$<$$$$$$$$$$$$$$$$'                    !!!!!\n!!!!!          `$$$$$$$$$$$$$$$$\"$$$$$$$$$$$$$d>                     !!!!!\n!!!!!           ?$$$$$$$$$$$$??$c`$$$$$$$$$$$?>'                     `!!!!\n!!!!!           `?$$$$$$!>?\"\"    ,$$$$$$$$$?>>'                       !!!!\n!!!!!.           <<?$$$$$$c.    ,d$$?$$$$$$>>''                       `!!!\n!!!!!!            <!?$d\"??$$d--\"?\"\"  ,$$$$d;>''                       `!!!\n!!!!!!             $$$dccccccccc- cc$$$$$$$>>'                         !!!\n!!!!!              `?$$$$$$$\"\"\"\"  `\"$$$$$>>>''                         `!!\n!!!!!                \"?$$$$$cccccc$$$$??>>>>'                           !!\n!!!!>                  \"$$$$$$$$$$$$$$>>>>''                            `!\n!!!!!                    \"$$$$$$$$???>'''                                !\n!!!!!>                     `\"\"\"\"\"                                        `\n!!!!!!;                       .                                          `\n!!!!!!!                       ?d.                                         \n!!!!!!!!                       $$c,                                       \n!!!!!!!!>                      ?$$$d.              .,c                    \n!!!!!!!!!                       $$$$$$$$$dc,.,,cc$$$$$                    \n!!!!!!!!!                  .,dcc$$$$$$$$$$$$$$$$$$$$$$                    \n!!!!!!!!!               .d$$$$$$$$$$$$$$$$$$$$$$$$$$$$                    \n!!!!!!!!!             ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$          .         \n!!!!!!!!!           ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$         !!         \n!!!!!!!!!         ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$        ,!'         \n!!!!!!!!>        c$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$.       !'          \n!!!!!!''       ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$>       '           \n!!!''         d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$>                   \n!'           ,$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$>             ..    \n            d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$'           ;!!!!''`\n            $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$       ,;;!'`'  .'' \n           <$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$>    ,;'`'  ,;       \n           `$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$   -'   ,;!!'        \n            \"?$$$$$$$$$$?$$$$$$$$$$$$$$$$$$$$$$$$$$$     .<!!!'''       <!\n         !>    \"\"??$$$?<?$$$$$$$$$$$$$$$$$$$$$$$$\"\"     ;!'''          !!!\n       ;!!!!;,      `\"''\"\"????$$$$$$$$$$$$$$$$\"\"   ,;-''               ',!\n      ;!!!!<!!!; .                `\"\"\"\"\"\"\"\"\"\"\"    `'                  ' ' \n      !!!! ;!!! ;!!!!>;,;, ..                  ' .                   '  ' \n     !!' ,;!!! ;'`!!!!!!!!;!!!!!;  .        >' .''                 ;      \n    !!' ;!!'!';! !! !!!!!!!!!!!!!  '         -'                           \n   <!!  !! `!;! `!' !!!!!!!!!!<!       .                                  \n   `!  ;!  ;!!! <' <!!!! `!!! <       !                                   \n  `;   !>  <!! ;'  !!!!'  !!';!     ;'                                    \n   !   !   !!! !   `!!!  ;!! !      '  '                                  \n  ;   `!  `!! ,'    !'   ;!'                                              \n      '   !`! !    <     !! <      '                                      \n           ! ;!        >;! ;>                                             \n             !'       ; !! '                                              \n          ' ;!        > ! '                                               \n            '                                                             "
            got: "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!>''''''<!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!'''''`             ``'!!!!!!!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!!!!!!''`          .....         `'!!!!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!!!'`      .      ;;;;;'            `'!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!'     .   '     .;;;;'                `!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!'      ;          `````                   `!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!        .,ccdcccccc,,.                       `!!!!!!!!!!!!\n!!!!!!!!!!!!!!!     .-\"?$$$$$$$$$$$$$$c,                      `!!!!!!!!!!!\n!!!!!!!!!!!!!!    ,ccc$$$$$$$$$$$$$$$$$$$,                     `!!!!!!!!!!\n!!!!!!!!!!!!!    d$$$$$$$$$$$$$$$$$$$$$$$$;.                    `!!!!!!!!!\n!!!!!!!!!!!!    <$$$$$$$$$$$$$$$$$$$$$$$$$$;.                    `!!!!!!!!\n!!!!!!!!!!!     $$$$$$$$$$$$$$$$$$$$$$$$$$$d;;.                   !!!!!!!!\n!!!!!!!!!!'     $$$$$$$$$$$$$$$$$$$$$$$$$$$$$d;.                   !!!!!!!\n!!!!!!!!!'     <$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$                   !!!!!!!\n!!!!!!!!'      `$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$                   `!!!!!!\n!!!!!!!!        c$$$$???$$$$$$$d\"\"  \"\"\"??????\"                      !!!!!!\n!!!!!!!         `\"\" .,.. \"$$$$$    .,dcd                            !!!!!!\n!!!!!!!         .  d!    .?$$$   .,cc,      .,d$d.                  !!!!!!\n!!!!!!!!        <. $$c- <$d$$$   <$$$$---$\"$$$$$$$                  !!!!!!\n!!!!!!!         d$$$dcccd$$$$$   d$$$dcccd$$$$$$$$                  `!!!!!\n!!!!!!         ,$$$$$$$$$$$$$$d d$$$$$$$$$$$$$$$$                   `!!!!!\n!!!!!          `$$$$$$$$$$$$$$$<$$$$$$$$$$$$$$$$'                    !!!!!\n!!!!!          `$$$$$$$$$$$$$$$$\"$$$$$$$$$$$$$d>                     !!!!!\n!!!!!           ?$$$$$$$$$$$$??$c`$$$$$$$$$$$?>'                     `!!!!\n!!!!!           `?$$$$$$!>?\"\"    ,$$$$$$$$$?>>'                       !!!!\n!!!!!.           <<?$$$$$$c.    ,d$$?$$$$$$>>''                       `!!!\n!!!!!!            <!?$d\"??$$d--\"?\"\"  ,$$$$d;>''                       `!!!\n!!!!!!             $$$dccccccccc- cc$$$$$$$>>'                         !!!\n!!!!!              `?$$$$$$$\"\"\"\"  `\"$$$$$>>>''                         `!!\n!!!!!                \"?$$$$$cccccc$$$$??>>>>'                           !!\n!!!!>                  \"$$$$$$$$$$$$$$>>>>''                            `!\n!!!!!                    \"$$$$$$$$???>'''                                !\n!!!!!>                     `\"\"\"\"\"                                        `\n!!!!!!;                       .                                          `\n!!!!!!!                       ?d.                                         \n!!!!!!!!                       $$c,                                       \n!!!!!!!!>                      ?$$$d.              .,c                    \n!!!!!!!!!                       $$$$$$$$$dc,.,,cc$$$$$                    \n!!!!!!!!!                  .,dcc$$$$$$$$$$$$$$$$$$$$$$                    \n!!!!!!!!!               .d$$$$$$$$$$$$$$$$$$$$$$$$$$$$                    \n!!!!!!!!!             ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$          .         \n!!!!!!!!!           ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$         !!         \n!!!!!!!!!         ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$        ,!'         \n!!!!!!!!>        c$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$.       !'          \n!!!!!!''       ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$>       '           \n!!!''         d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$>                   \n!'           ,$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$>             ..    \n            d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$'           ;!!!!''`\n            $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$       ,;;!'`'  .'' \n           <$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$>    ,;'`'  ,;       \n           `$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$   -'   ,;!!'        \n            \"?$$$$$$$$$$?$$$$$$$$$$$$$$$$$$$$$$$$$$$     .<!!!'''       <!\n         !>    \"\"??$$$?<?$$$$$$$$$$$$$$$$$$$$$$$$\"\"     ;!'''          !!!\n       ;!!!!;,      `\"''\"\"????$$$$$$$$$$$$$$$$\"\"   ,;-''               ',!\n      ;!!!!<!!!; .                `\"\"\"\"\"\"\"\"\"\"\"    `'                  ' ' \n      !!!! ;!!! ;!!!!>;,;, ..                  ' .                   '  ' \n     !!' ,;!!! ;'`!!!!!!!!;!!!!!;  .        >' .''                 ;      \n    !!' ;!!'!';! !! !!!!!!!!!!!!!  '         -'                           \n   <!!  !! `!;! `!' !!!!!!!!!!<!       .                                  \n   `!  ;!  ;!!! <' <!!!! `!!! <       !                                   \n  `;   !>  <!! ;'  !!!!'  !!';!     ;'                                    \n   !   !   !!! !   `!!!  ;!! !      '  '                                  \n  ;   `!  `!! ,'    !'   ;!'                                              \n      '   !`! !    <     !! <      '                                      \n           ! ;!        >;! ;>                                             \n             !'       ; !! '                                              \n          ' ;!        > ! '                                               \n            '"
       
       (compared using ==)
       
       Diff:
       @@ -67,5 +67,5 @@
                   ! ;!        >;! ;>                                             
                     !'       ; !! '                                              
                  ' ;!        > ! '                                               
       -            '                                                             
       +            '
     # /tmp/d20131110-20795-l0hnyb/spec.rb:105:in `block (2 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

Finished in 0.01489 seconds
5 examples, 1 failure

Failed examples:

rspec /tmp/d20131110-20795-l0hnyb/spec.rb:31 # Bitmap renders La Gioconda
Георги Урумов
  • Некоректно
  • 4 успешни тест(а)
  • 1 неуспешни тест(а)
Георги Урумов
class Bitmap
def initialize(bitmap, per_line=bitmap.size)
@bitmap = bitmap.each.map { |number| "%08b" % number }
@per_line = per_line
end
def render(colours=['.', '#'])
colour_bits = Math.log(colours.size, 2)
image = @bitmap.each.map { |number| picture(number, colour_bits, colours) }
image.each_slice(@per_line).map { |slice| slice.join + "\n" }.join.strip
end
private
def picture(number, colour_bits, colours)
pic = number.chars.each_slice(colour_bits).map(&:join)
pic.map { |bits| colours[bits.to_i(2)] }.join
end
end
....F

Failures:

  1) Bitmap renders La Gioconda
     Failure/Error: Bitmap.new(the_bitmap, 37).render(["!", "\n", ">", "'", "<", "`", " ", ".", ";", ",", "c", "d", "-", "\"", "?", "$"]).should eq expectation
       
       expected: "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!>''''''<!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!'''''`             ``'!!!!!!!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!!!!!!''`          .....         `'!!!!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!!!'`      .      ;;;;;'            `'!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!'     .   '     .;;;;'                `!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!'      ;          `````                   `!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!        .,ccdcccccc,,.                       `!!!!!!!!!!!!\n!!!!!!!!!!!!!!!     .-\"?$$$$$$$$$$$$$$c,                      `!!!!!!!!!!!\n!!!!!!!!!!!!!!    ,ccc$$$$$$$$$$$$$$$$$$$,                     `!!!!!!!!!!\n!!!!!!!!!!!!!    d$$$$$$$$$$$$$$$$$$$$$$$$;.                    `!!!!!!!!!\n!!!!!!!!!!!!    <$$$$$$$$$$$$$$$$$$$$$$$$$$;.                    `!!!!!!!!\n!!!!!!!!!!!     $$$$$$$$$$$$$$$$$$$$$$$$$$$d;;.                   !!!!!!!!\n!!!!!!!!!!'     $$$$$$$$$$$$$$$$$$$$$$$$$$$$$d;.                   !!!!!!!\n!!!!!!!!!'     <$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$                   !!!!!!!\n!!!!!!!!'      `$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$                   `!!!!!!\n!!!!!!!!        c$$$$???$$$$$$$d\"\"  \"\"\"??????\"                      !!!!!!\n!!!!!!!         `\"\" .,.. \"$$$$$    .,dcd                            !!!!!!\n!!!!!!!         .  d!    .?$$$   .,cc,      .,d$d.                  !!!!!!\n!!!!!!!!        <. $$c- <$d$$$   <$$$$---$\"$$$$$$$                  !!!!!!\n!!!!!!!         d$$$dcccd$$$$$   d$$$dcccd$$$$$$$$                  `!!!!!\n!!!!!!         ,$$$$$$$$$$$$$$d d$$$$$$$$$$$$$$$$                   `!!!!!\n!!!!!          `$$$$$$$$$$$$$$$<$$$$$$$$$$$$$$$$'                    !!!!!\n!!!!!          `$$$$$$$$$$$$$$$$\"$$$$$$$$$$$$$d>                     !!!!!\n!!!!!           ?$$$$$$$$$$$$??$c`$$$$$$$$$$$?>'                     `!!!!\n!!!!!           `?$$$$$$!>?\"\"    ,$$$$$$$$$?>>'                       !!!!\n!!!!!.           <<?$$$$$$c.    ,d$$?$$$$$$>>''                       `!!!\n!!!!!!            <!?$d\"??$$d--\"?\"\"  ,$$$$d;>''                       `!!!\n!!!!!!             $$$dccccccccc- cc$$$$$$$>>'                         !!!\n!!!!!              `?$$$$$$$\"\"\"\"  `\"$$$$$>>>''                         `!!\n!!!!!                \"?$$$$$cccccc$$$$??>>>>'                           !!\n!!!!>                  \"$$$$$$$$$$$$$$>>>>''                            `!\n!!!!!                    \"$$$$$$$$???>'''                                !\n!!!!!>                     `\"\"\"\"\"                                        `\n!!!!!!;                       .                                          `\n!!!!!!!                       ?d.                                         \n!!!!!!!!                       $$c,                                       \n!!!!!!!!>                      ?$$$d.              .,c                    \n!!!!!!!!!                       $$$$$$$$$dc,.,,cc$$$$$                    \n!!!!!!!!!                  .,dcc$$$$$$$$$$$$$$$$$$$$$$                    \n!!!!!!!!!               .d$$$$$$$$$$$$$$$$$$$$$$$$$$$$                    \n!!!!!!!!!             ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$          .         \n!!!!!!!!!           ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$         !!         \n!!!!!!!!!         ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$        ,!'         \n!!!!!!!!>        c$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$.       !'          \n!!!!!!''       ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$>       '           \n!!!''         d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$>                   \n!'           ,$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$>             ..    \n            d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$'           ;!!!!''`\n            $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$       ,;;!'`'  .'' \n           <$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$>    ,;'`'  ,;       \n           `$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$   -'   ,;!!'        \n            \"?$$$$$$$$$$?$$$$$$$$$$$$$$$$$$$$$$$$$$$     .<!!!'''       <!\n         !>    \"\"??$$$?<?$$$$$$$$$$$$$$$$$$$$$$$$\"\"     ;!'''          !!!\n       ;!!!!;,      `\"''\"\"????$$$$$$$$$$$$$$$$\"\"   ,;-''               ',!\n      ;!!!!<!!!; .                `\"\"\"\"\"\"\"\"\"\"\"    `'                  ' ' \n      !!!! ;!!! ;!!!!>;,;, ..                  ' .                   '  ' \n     !!' ,;!!! ;'`!!!!!!!!;!!!!!;  .        >' .''                 ;      \n    !!' ;!!'!';! !! !!!!!!!!!!!!!  '         -'                           \n   <!!  !! `!;! `!' !!!!!!!!!!<!       .                                  \n   `!  ;!  ;!!! <' <!!!! `!!! <       !                                   \n  `;   !>  <!! ;'  !!!!'  !!';!     ;'                                    \n   !   !   !!! !   `!!!  ;!! !      '  '                                  \n  ;   `!  `!! ,'    !'   ;!'                                              \n      '   !`! !    <     !! <      '                                      \n           ! ;!        >;! ;>                                             \n             !'       ; !! '                                              \n          ' ;!        > ! '                                               \n            '                                                             "
            got: "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!>''''''<!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!'''''`             ``'!!!!!!!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!!!!!!''`          .....         `'!!!!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!!!'`      .      ;;;;;'            `'!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!'     .   '     .;;;;'                `!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!'      ;          `````                   `!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!        .,ccdcccccc,,.                       `!!!!!!!!!!!!\n!!!!!!!!!!!!!!!     .-\"?$$$$$$$$$$$$$$c,                      `!!!!!!!!!!!\n!!!!!!!!!!!!!!    ,ccc$$$$$$$$$$$$$$$$$$$,                     `!!!!!!!!!!\n!!!!!!!!!!!!!    d$$$$$$$$$$$$$$$$$$$$$$$$;.                    `!!!!!!!!!\n!!!!!!!!!!!!    <$$$$$$$$$$$$$$$$$$$$$$$$$$;.                    `!!!!!!!!\n!!!!!!!!!!!     $$$$$$$$$$$$$$$$$$$$$$$$$$$d;;.                   !!!!!!!!\n!!!!!!!!!!'     $$$$$$$$$$$$$$$$$$$$$$$$$$$$$d;.                   !!!!!!!\n!!!!!!!!!'     <$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$                   !!!!!!!\n!!!!!!!!'      `$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$                   `!!!!!!\n!!!!!!!!        c$$$$???$$$$$$$d\"\"  \"\"\"??????\"                      !!!!!!\n!!!!!!!         `\"\" .,.. \"$$$$$    .,dcd                            !!!!!!\n!!!!!!!         .  d!    .?$$$   .,cc,      .,d$d.                  !!!!!!\n!!!!!!!!        <. $$c- <$d$$$   <$$$$---$\"$$$$$$$                  !!!!!!\n!!!!!!!         d$$$dcccd$$$$$   d$$$dcccd$$$$$$$$                  `!!!!!\n!!!!!!         ,$$$$$$$$$$$$$$d d$$$$$$$$$$$$$$$$                   `!!!!!\n!!!!!          `$$$$$$$$$$$$$$$<$$$$$$$$$$$$$$$$'                    !!!!!\n!!!!!          `$$$$$$$$$$$$$$$$\"$$$$$$$$$$$$$d>                     !!!!!\n!!!!!           ?$$$$$$$$$$$$??$c`$$$$$$$$$$$?>'                     `!!!!\n!!!!!           `?$$$$$$!>?\"\"    ,$$$$$$$$$?>>'                       !!!!\n!!!!!.           <<?$$$$$$c.    ,d$$?$$$$$$>>''                       `!!!\n!!!!!!            <!?$d\"??$$d--\"?\"\"  ,$$$$d;>''                       `!!!\n!!!!!!             $$$dccccccccc- cc$$$$$$$>>'                         !!!\n!!!!!              `?$$$$$$$\"\"\"\"  `\"$$$$$>>>''                         `!!\n!!!!!                \"?$$$$$cccccc$$$$??>>>>'                           !!\n!!!!>                  \"$$$$$$$$$$$$$$>>>>''                            `!\n!!!!!                    \"$$$$$$$$???>'''                                !\n!!!!!>                     `\"\"\"\"\"                                        `\n!!!!!!;                       .                                          `\n!!!!!!!                       ?d.                                         \n!!!!!!!!                       $$c,                                       \n!!!!!!!!>                      ?$$$d.              .,c                    \n!!!!!!!!!                       $$$$$$$$$dc,.,,cc$$$$$                    \n!!!!!!!!!                  .,dcc$$$$$$$$$$$$$$$$$$$$$$                    \n!!!!!!!!!               .d$$$$$$$$$$$$$$$$$$$$$$$$$$$$                    \n!!!!!!!!!             ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$          .         \n!!!!!!!!!           ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$         !!         \n!!!!!!!!!         ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$        ,!'         \n!!!!!!!!>        c$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$.       !'          \n!!!!!!''       ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$>       '           \n!!!''         d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$>                   \n!'           ,$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$>             ..    \n            d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$'           ;!!!!''`\n            $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$       ,;;!'`'  .'' \n           <$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$>    ,;'`'  ,;       \n           `$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$   -'   ,;!!'        \n            \"?$$$$$$$$$$?$$$$$$$$$$$$$$$$$$$$$$$$$$$     .<!!!'''       <!\n         !>    \"\"??$$$?<?$$$$$$$$$$$$$$$$$$$$$$$$\"\"     ;!'''          !!!\n       ;!!!!;,      `\"''\"\"????$$$$$$$$$$$$$$$$\"\"   ,;-''               ',!\n      ;!!!!<!!!; .                `\"\"\"\"\"\"\"\"\"\"\"    `'                  ' ' \n      !!!! ;!!! ;!!!!>;,;, ..                  ' .                   '  ' \n     !!' ,;!!! ;'`!!!!!!!!;!!!!!;  .        >' .''                 ;      \n    !!' ;!!'!';! !! !!!!!!!!!!!!!  '         -'                           \n   <!!  !! `!;! `!' !!!!!!!!!!<!       .                                  \n   `!  ;!  ;!!! <' <!!!! `!!! <       !                                   \n  `;   !>  <!! ;'  !!!!'  !!';!     ;'                                    \n   !   !   !!! !   `!!!  ;!! !      '  '                                  \n  ;   `!  `!! ,'    !'   ;!'                                              \n      '   !`! !    <     !! <      '                                      \n           ! ;!        >;! ;>                                             \n             !'       ; !! '                                              \n          ' ;!        > ! '                                               \n            '"
       
       (compared using ==)
       
       Diff:
       @@ -67,5 +67,5 @@
                   ! ;!        >;! ;>                                             
                     !'       ; !! '                                              
                  ' ;!        > ! '                                               
       -            '                                                             
       +            '
     # /tmp/d20131110-20795-16g74nv/spec.rb:105:in `block (2 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

Finished in 0.07522 seconds
5 examples, 1 failure

Failed examples:

rspec /tmp/d20131110-20795-16g74nv/spec.rb:31 # Bitmap renders La Gioconda
Мария Терзиева
  • Некоректно
  • 3 успешни тест(а)
  • 2 неуспешни тест(а)
Мария Терзиева
class Bitmap
def initialize(bytes_array, bytes_on_a_row = bytes_array.size)
@bytes_array, @bytes_on_a_row = bytes_array, bytes_on_a_row
end
def render(palette = ['.', '#'])
length = palette.size == 16 ? palette_size / 4 : palette.size / 2
pixels_hash_keys = ['0', '1'].repeated_permutation(length).map(&:join)
pixels_hash = Hash[pixels_hash_keys.zip(palette)]
pixelated_bytes_array = @bytes_array.map do |byte|
("%08b" % byte).chars.each_slice(length).map(&:join)
end
bitmap = pixelated_bytes_array.map do |byte|
byte.map do |pixel|
pixels_hash[pixel]
end.join
end
@bytes_on_a_row.step(@bytes_array.size - 1, @bytes_on_a_row) do |index|
bitmap = bitmap.insert(index, "\n")
end
bitmap.join
end
end
..F.F

Failures:

  1) Bitmap can render a column
     Failure/Error: expect(Bitmap.new([9, 32, 7, 1], 1).render).to eq <<-ASCII.strip
       
       expected: "....#..#\n..#.....\n.....###\n.......#"
            got: "....#..#\n\n\n..#..........###.......#"
       
       (compared using ==)
       
       Diff:
       @@ -1,5 +1,5 @@
        ....#..#
       -..#.....
       -.....###
       -.......#
       +
       +
       +..#..........###.......#
     # /tmp/d20131110-20795-1vuqne5/spec.rb:16:in `block (2 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  2) Bitmap renders La Gioconda
     Failure/Error: Bitmap.new(the_bitmap, 37).render(["!", "\n", ">", "'", "<", "`", " ", ".", ";", ",", "c", "d", "-", "\"", "?", "$"]).should eq expectation
     NameError:
       undefined local variable or method `palette_size' for #<Bitmap:0xb8dec6b0>
     # /tmp/d20131110-20795-1vuqne5/solution.rb:7:in `render'
     # /tmp/d20131110-20795-1vuqne5/spec.rb:105:in `block (2 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

Finished in 0.00788 seconds
5 examples, 2 failures

Failed examples:

rspec /tmp/d20131110-20795-1vuqne5/spec.rb:15 # Bitmap can render a column
rspec /tmp/d20131110-20795-1vuqne5/spec.rb:31 # Bitmap renders La Gioconda
Георги Шопов
  • Некоректно
  • 3 успешни тест(а)
  • 2 неуспешни тест(а)
Георги Шопов
BYTE = 8
class Bitmap
def initialize(bytes, bytes_per_line = bytes.length)
@bytes = bytes.map { |byte| byte.to_s(2) }
@bytes = @bytes.map { |byte| byte.prepend('0' * (BYTE - byte.length)) }
@bytes_per_line = bytes_per_line
end
def render(colors = ['.', '#'])
pixel_bits = Math.log2(colors.length).to_i
@bytes.each_with_index.map do |byte, index|
newline = index == @bytes_per_line - 1 && index != @bytes.length - 1 ? "\n" : ''
byte.chars.each_slice(pixel_bits).map do |slice|
colors[slice.join.to_i(2)]
end.join + newline
end.join
end
end
..F.F

Failures:

  1) Bitmap can render a column
     Failure/Error: expect(Bitmap.new([9, 32, 7, 1], 1).render).to eq <<-ASCII.strip
       
       expected: "....#..#\n..#.....\n.....###\n.......#"
            got: "....#..#\n..#..........###.......#"
       
       (compared using ==)
       
       Diff:
       @@ -1,5 +1,3 @@
        ....#..#
       -..#.....
       -.....###
       -.......#
       +..#..........###.......#
     # /tmp/d20131110-20795-o2zrkz/spec.rb:16:in `block (2 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  2) Bitmap renders La Gioconda
     Failure/Error: Bitmap.new(the_bitmap, 37).render(["!", "\n", ">", "'", "<", "`", " ", ".", ";", ",", "c", "d", "-", "\"", "?", "$"]).should eq expectation
       
       expected: "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!>''''''<!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!'''''`             ``'!!!!!!!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!!!!!!''`          .....         `'!!!!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!!!'`      .      ;;;;;'            `'!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!'     .   '     .;;;;'                `!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!'      ;          `````                   `!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!        .,ccdcccccc,,.                       `!!!!!!!!!!!!\n!!!!!!!!!!!!!!!     .-\"?$$$$$$$$$$$$$$c,                      `!!!!!!!!!!!\n!!!!!!!!!!!!!!    ,ccc$$$$$$$$$$$$$$$$$$$,                     `!!!!!!!!!!\n!!!!!!!!!!!!!    d$$$$$$$$$$$$$$$$$$$$$$$$;.                    `!!!!!!!!!\n!!!!!!!!!!!!    <$$$$$$$$$$$$$$$$$$$$$$$$$$;.                    `!!!!!!!!\n!!!!!!!!!!!     $$$$$$$$$$$$$$$$$$$$$$$$$$$d;;.                   !!!!!!!!\n!!!!!!!!!!'     $$$$$$$$$$$$$$$$$$$$$$$$$$$$$d;.                   !!!!!!!\n!!!!!!!!!'     <$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$                   !!!!!!!\n!!!!!!!!'      `$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$                   `!!!!!!\n!!!!!!!!        c$$$$???$$$$$$$d\"\"  \"\"\"??????\"                      !!!!!!\n!!!!!!!         `\"\" .,.. \"$$$$$    .,dcd                            !!!!!!\n!!!!!!!         .  d!    .?$$$   .,cc,      .,d$d.                  !!!!!!\n!!!!!!!!        <. $$c- <$d$$$   <$$$$---$\"$$$$$$$                  !!!!!!\n!!!!!!!         d$$$dcccd$$$$$   d$$$dcccd$$$$$$$$                  `!!!!!\n!!!!!!         ,$$$$$$$$$$$$$$d d$$$$$$$$$$$$$$$$                   `!!!!!\n!!!!!          `$$$$$$$$$$$$$$$<$$$$$$$$$$$$$$$$'                    !!!!!\n!!!!!          `$$$$$$$$$$$$$$$$\"$$$$$$$$$$$$$d>                     !!!!!\n!!!!!           ?$$$$$$$$$$$$??$c`$$$$$$$$$$$?>'                     `!!!!\n!!!!!           `?$$$$$$!>?\"\"    ,$$$$$$$$$?>>'                       !!!!\n!!!!!.           <<?$$$$$$c.    ,d$$?$$$$$$>>''                       `!!!\n!!!!!!            <!?$d\"??$$d--\"?\"\"  ,$$$$d;>''                       `!!!\n!!!!!!             $$$dccccccccc- cc$$$$$$$>>'                         !!!\n!!!!!              `?$$$$$$$\"\"\"\"  `\"$$$$$>>>''                         `!!\n!!!!!                \"?$$$$$cccccc$$$$??>>>>'                           !!\n!!!!>                  \"$$$$$$$$$$$$$$>>>>''                            `!\n!!!!!                    \"$$$$$$$$???>'''                                !\n!!!!!>                     `\"\"\"\"\"                                        `\n!!!!!!;                       .                                          `\n!!!!!!!                       ?d.                                         \n!!!!!!!!                       $$c,                                       \n!!!!!!!!>                      ?$$$d.              .,c                    \n!!!!!!!!!                       $$$$$$$$$dc,.,,cc$$$$$                    \n!!!!!!!!!                  .,dcc$$$$$$$$$$$$$$$$$$$$$$                    \n!!!!!!!!!               .d$$$$$$$$$$$$$$$$$$$$$$$$$$$$                    \n!!!!!!!!!             ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$          .         \n!!!!!!!!!           ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$         !!         \n!!!!!!!!!         ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$        ,!'         \n!!!!!!!!>        c$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$.       !'          \n!!!!!!''       ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$>       '           \n!!!''         d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$>                   \n!'           ,$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$>             ..    \n            d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$'           ;!!!!''`\n            $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$       ,;;!'`'  .'' \n           <$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$>    ,;'`'  ,;       \n           `$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$   -'   ,;!!'        \n            \"?$$$$$$$$$$?$$$$$$$$$$$$$$$$$$$$$$$$$$$     .<!!!'''       <!\n         !>    \"\"??$$$?<?$$$$$$$$$$$$$$$$$$$$$$$$\"\"     ;!'''          !!!\n       ;!!!!;,      `\"''\"\"????$$$$$$$$$$$$$$$$\"\"   ,;-''               ',!\n      ;!!!!<!!!; .                `\"\"\"\"\"\"\"\"\"\"\"    `'                  ' ' \n      !!!! ;!!! ;!!!!>;,;, ..                  ' .                   '  ' \n     !!' ,;!!! ;'`!!!!!!!!;!!!!!;  .        >' .''                 ;      \n    !!' ;!!'!';! !! !!!!!!!!!!!!!  '         -'                           \n   <!!  !! `!;! `!' !!!!!!!!!!<!       .                                  \n   `!  ;!  ;!!! <' <!!!! `!!! <       !                                   \n  `;   !>  <!! ;'  !!!!'  !!';!     ;'                                    \n   !   !   !!! !   `!!!  ;!! !      '  '                                  \n  ;   `!  `!! ,'    !'   ;!'                                              \n      '   !`! !    <     !! <      '                                      \n           ! ;!        >;! ;>                                             \n             !'       ; !! '                                              \n          ' ;!        > ! '                                               \n            '                                                             "
            got: "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!>''''''<!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'''''`             ``'!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!''`          .....         `'!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'`      .      ;;;;;'            `'!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'     .   '     .;;;;'                `!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'      ;          `````                   `!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!        .,ccdcccccc,,.                       `!!!!!!!!!!!!!!!!!!!!!!!!!!!     .-\"?$$$$$$$$$$$$$$c,                      `!!!!!!!!!!!!!!!!!!!!!!!!!    ,ccc$$$$$$$$$$$$$$$$$$$,                     `!!!!!!!!!!!!!!!!!!!!!!!    d$$$$$$$$$$$$$$$$$$$$$$$$;.                    `!!!!!!!!!!!!!!!!!!!!!    <$$$$$$$$$$$$$$$$$$$$$$$$$$;.                    `!!!!!!!!!!!!!!!!!!!     $$$$$$$$$$$$$$$$$$$$$$$$$$$d;;.                   !!!!!!!!!!!!!!!!!!'     $$$$$$$$$$$$$$$$$$$$$$$$$$$$$d;.                   !!!!!!!!!!!!!!!!'     <$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$                   !!!!!!!!!!!!!!!'      `$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$                   `!!!!!!!!!!!!!!        c$$$$???$$$$$$$d\"\"  \"\"\"??????\"                      !!!!!!!!!!!!!         `\"\" .,.. \"$$$$$    .,dcd                            !!!!!!!!!!!!!         .  d!    .?$$$   .,cc,      .,d$d.                  !!!!!!!!!!!!!!        <. $$c- <$d$$$   <$$$$---$\"$$$$$$$                  !!!!!!!!!!!!!         d$$$dcccd$$$$$   d$$$dcccd$$$$$$$$                  `!!!!!!!!!!!         ,$$$$$$$$$$$$$$d d$$$$$$$$$$$$$$$$                   `!!!!!!!!!!          `$$$$$$$$$$$$$$$<$$$$$$$$$$$$$$$$'                    !!!!!!!!!!          `$$$$$$$$$$$$$$$$\"$$$$$$$$$$$$$d>                     !!!!!!!!!!           ?$$$$$$$$$$$$??$c`$$$$$$$$$$$?>'                     `!!!!!!!!!           `?$$$$$$!>?\"\"    ,$$$$$$$$$?>>'                       !!!!!!!!!.           <<?$$$$$$c.    ,d$$?$$$$$$>>''                       `!!!!!!!!!            <!?$d\"??$$d--\"?\"\"  ,$$$$d;>''                       `!!!!!!!!!             $$$dccccccccc- cc$$$$$$$>>'                         !!!!!!!!              `?$$$$$$$\"\"\"\"  `\"$$$$$>>>''                         `!!!!!!!                \"?$$$$$cccccc$$$$??>>>>'                           !!!!!!>                  \"$$$$$$$$$$$$$$>>>>''                            `!!!!!!                    \"$$$$$$$$???>'''                                !!!!!!>                     `\"\"\"\"\"                                        `!!!!!!;                       .                                          `!!!!!!!                       ?d.                                         !!!!!!!!                       $$c,                                       !!!!!!!!>                      ?$$$d.              .,c                    !!!!!!!!!                       $$$$$$$$$dc,.,,cc$$$$$                    !!!!!!!!!                  .,dcc$$$$$$$$$$$$$$$$$$$$$$                    !!!!!!!!!               .d$$$$$$$$$$$$$$$$$$$$$$$$$$$$                    !!!!!!!!!             ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$          .         !!!!!!!!!           ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$         !!         !!!!!!!!!         ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$        ,!'         !!!!!!!!>        c$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$.       !'          !!!!!!''       ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$>       '           !!!''         d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$>                   !'           ,$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$>             ..                d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$'           ;!!!!''`            $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$       ,;;!'`'  .''            <$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$>    ,;'`'  ,;                  `$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$   -'   ,;!!'                    \"?$$$$$$$$$$?$$$$$$$$$$$$$$$$$$$$$$$$$$$     .<!!!'''       <!         !>    \"\"??$$$?<?$$$$$$$$$$$$$$$$$$$$$$$$\"\"     ;!'''          !!!       ;!!!!;,      `\"''\"\"????$$$$$$$$$$$$$$$$\"\"   ,;-''               ',!      ;!!!!<!!!; .                `\"\"\"\"\"\"\"\"\"\"\"    `'                  ' '       !!!! ;!!! ;!!!!>;,;, ..                  ' .                   '  '      !!' ,;!!! ;'`!!!!!!!!;!!!!!;  .        >' .''                 ;          !!' ;!!'!';! !! !!!!!!!!!!!!!  '         -'                              <!!  !! `!;! `!' !!!!!!!!!!<!       .                                     `!  ;!  ;!!! <' <!!!! `!!! <       !                                     `;   !>  <!! ;'  !!!!'  !!';!     ;'                                       !   !   !!! !   `!!!  ;!! !      '  '                                    ;   `!  `!! ,'    !'   ;!'                                                    '   !`! !    <     !! <      '                                                 ! ;!        >;! ;>                                                          !'       ; !! '                                                        ' ;!        > ! '                                                           '                                                             "
       
       (compared using ==)
       
       Diff:
       @@ -1,71 +1,3 @@
        !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
       -!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
       -!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!>''''''<!!!!!!!!!!!!!!!!!!!!!!!!!!!!
       -!!!!!!!!!!!!!!!!!!!!!!!!!!!!'''''`             ``'!!!!!!!!!!!!!!!!!!!!!!!!
       -!!!!!!!!!!!!!!!!!!!!!!!!''`          .....         `'!!!!!!!!!!!!!!!!!!!!!
       -!!!!!!!!!!!!!!!!!!!!!'`      .      ;;;;;'            `'!!!!!!!!!!!!!!!!!!
       -!!!!!!!!!!!!!!!!!!!'     .   '     .;;;;'                `!!!!!!!!!!!!!!!!
       -!!!!!!!!!!!!!!!!!'      ;          `````                   `!!!!!!!!!!!!!!
       -!!!!!!!!!!!!!!!!        .,ccdcccccc,,.                       `!!!!!!!!!!!!
       -!!!!!!!!!!!!!!!     .-"?$$$$$$$$$$$$$$c,                      `!!!!!!!!!!!
       -!!!!!!!!!!!!!!    ,ccc$$$$$$$$$$$$$$$$$$$,                     `!!!!!!!!!!
       -!!!!!!!!!!!!!    d$$$$$$$$$$$$$$$$$$$$$$$$;.                    `!!!!!!!!!
       -!!!!!!!!!!!!    <$$$$$$$$$$$$$$$$$$$$$$$$$$;.                    `!!!!!!!!
       -!!!!!!!!!!!     $$$$$$$$$$$$$$$$$$$$$$$$$$$d;;.                   !!!!!!!!
       -!!!!!!!!!!'     $$$$$$$$$$$$$$$$$$$$$$$$$$$$$d;.                   !!!!!!!
       -!!!!!!!!!'     <$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$                   !!!!!!!
       -!!!!!!!!'      `$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$                   `!!!!!!
       -!!!!!!!!        c$$$$???$$$$$$$d""  """??????"                      !!!!!!
       -!!!!!!!         `"" .,.. "$$$$$    .,dcd                            !!!!!!
       -!!!!!!!         .  d!    .?$$$   .,cc,      .,d$d.                  !!!!!!
       -!!!!!!!!        <. $$c- <$d$$$   <$$$$---$"$$$$$$$                  !!!!!!
       -!!!!!!!         d$$$dcccd$$$$$   d$$$dcccd$$$$$$$$                  `!!!!!
       -!!!!!!         ,$$$$$$$$$$$$$$d d$$$$$$$$$$$$$$$$                   `!!!!!
       -!!!!!          `$$$$$$$$$$$$$$$<$$$$$$$$$$$$$$$$'                    !!!!!
       -!!!!!          `$$$$$$$$$$$$$$$$"$$$$$$$$$$$$$d>                     !!!!!
       -!!!!!           ?$$$$$$$$$$$$??$c`$$$$$$$$$$$?>'                     `!!!!
       -!!!!!           `?$$$$$$!>?""    ,$$$$$$$$$?>>'                       !!!!
       -!!!!!.           <<?$$$$$$c.    ,d$$?$$$$$$>>''                       `!!!
       -!!!!!!            <!?$d"??$$d--"?""  ,$$$$d;>''                       `!!!
       -!!!!!!             $$$dccccccccc- cc$$$$$$$>>'                         !!!
       -!!!!!              `?$$$$$$$""""  `"$$$$$>>>''                         `!!
       -!!!!!                "?$$$$$cccccc$$$$??>>>>'                           !!
       -!!!!>                  "$$$$$$$$$$$$$$>>>>''                            `!
       -!!!!!                    "$$$$$$$$???>'''                                !
       -!!!!!>                     `"""""                                        `
       -!!!!!!;                       .                                          `
       -!!!!!!!                       ?d.                                         
       -!!!!!!!!                       $$c,                                       
       -!!!!!!!!>                      ?$$$d.              .,c                    
       -!!!!!!!!!                       $$$$$$$$$dc,.,,cc$$$$$                    
       -!!!!!!!!!                  .,dcc$$$$$$$$$$$$$$$$$$$$$$                    
       -!!!!!!!!!               .d$$$$$$$$$$$$$$$$$$$$$$$$$$$$                    
       -!!!!!!!!!             ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$          .         
       -!!!!!!!!!           ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$         !!         
       -!!!!!!!!!         ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$        ,!'         
       -!!!!!!!!>        c$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$.       !'          
       -!!!!!!''       ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$>       '           
       -!!!''         d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$>                   
       -!'           ,$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$>             ..    
       -            d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$'           ;!!!!''`
       -            $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$       ,;;!'`'  .'' 
       -           <$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$>    ,;'`'  ,;       
       -           `$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$   -'   ,;!!'        
       -            "?$$$$$$$$$$?$$$$$$$$$$$$$$$$$$$$$$$$$$$     .<!!!'''       <!
       -         !>    ""??$$$?<?$$$$$$$$$$$$$$$$$$$$$$$$""     ;!'''          !!!
       -       ;!!!!;,      `"''""????$$$$$$$$$$$$$$$$""   ,;-''               ',!
       -      ;!!!!<!!!; .                `"""""""""""    `'                  ' ' 
       -      !!!! ;!!! ;!!!!>;,;, ..                  ' .                   '  ' 
       -     !!' ,;!!! ;'`!!!!!!!!;!!!!!;  .        >' .''                 ;      
       -    !!' ;!!'!';! !! !!!!!!!!!!!!!  '         -'                           
       -   <!!  !! `!;! `!' !!!!!!!!!!<!       .                                  
       -   `!  ;!  ;!!! <' <!!!! `!!! <       !                                   
       -  `;   !>  <!! ;'  !!!!'  !!';!     ;'                                    
       -   !   !   !!! !   `!!!  ;!! !      '  '                                  
       -  ;   `!  `!! ,'    !'   ;!'                                              
       -      '   !`! !    <     !! <      '                                      
       -           ! ;!        >;! ;>                                             
       -             !'       ; !! '                                              
       -          ' ;!        > ! '                                               
       -            '                                                             
       +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!>''''''<!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'''''`             ``'!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!''`          .....         `'!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'`      .      ;;;;;'            `'!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'     .   '     .;;;;'                `!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'      ;          `````                   `!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!        .,ccdcccccc,,.                       `!!!!!!!!!!!!!!!!!!!!!!!!!!!     .-"?$$$$$$$$$$$$$$c,                      `!!!!!!!!!!!!!!!!!!!!!!!!!    ,ccc$$$$$$$$$$$$$$$$$$$,                     `!!!!!!!!!!!!!!!!!!!!!!!    d$$$$$$$$$$$$$$$$$$$$$$$$;.                    `!!!!!!!!!!!!!!!!!!!!!    <$$$$$$$$$$$$$$$$$$$$$$$$$$;.                    `!!!!!!!!!!!!!!!!!!!     $$$$$$$$$$$$$$$$$$$$$$$$$$$d;;.                   !!!!!!!!!!!!!!!!!!'     $$$$$$$$$$$$$$$$$$$$$$$$$$$$$d;.                   !!!!!!!!!!!!!!!!'     <$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$                   !!!!!!!!!!!!!!!'      `$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$                   `!!!!!!!!!!!!!!        c$$$$???$$$$$$$d""  """??????"                      !!!!!!!!!!!!!         `"" .,.. "$$$$$    .,dcd                            !!!!!!!!!!!!!         .  d!    .?$$$   .,cc,      .,d$d.                  !!!!!!!!!!!!!!        <. $$c- <$d$$$   <$$$$---$"$$$$$$$                  !!!!!!!!!!!!!         d$$$dcccd$$$$$   d$$$dcccd$$$$$$$$                  `!!!!!!!!!!!         ,$$$$$$$$$$$$$$d d$$$$$$$$$$$$$$$$                   `!!!!!!!!!!          `$$$$$$$$$$$$$$$<$$$$$$$$$$$$$$$$'                    !!!!!!!!!!          `$$$$$$$$$$$$$$$$"$$$$$$$$$$$$$d>                     !!!!!!!!!!           ?$$$$$$$$$$$$??$c`$$$$$$$$$$$?>'                     `!!!!!!!!!           `?$$$$$$!>?""    ,$$$$$$$$$?>>'                       !!!!!!!!!.           <<?$$$$$$c.    ,d$$?$$$$$$>>''                       `!!!!!!!!!            <!?$d"??$$d--"?""  ,$$$$d;>''                       `!!!!!!!!!             $$$dccccccccc- cc$$$$$$$>>'                         !!!!!!!!              `?$$$$$$$""""  `"$$$$$>>>''                         `!!!!!!!                "?$$$$$cccccc$$$$??>>>>'                           !!!!!!>                  "$$$$$$$$$$$$$$>>>>''                            `!!!!!!                    "$$$$$$$$???>'''                                !!!!!!>                     `"""""                                        `!!!!!!;                       .                                          `!!!!!!!                       ?d.                                         !!!!!!!!                       $$c,                                       !!!!!!!!>                      ?$$$d.              .,c                    !!!!!!!!!                       $$$$$$$$$dc,.,,cc$$$$$                    !!!!!!!!!                  .,dcc$$$$$$$$$$$$$$$$$$$$$$                    !!!!!!!!!               .d$$$$$$$$$$$$$$$$$$$$$$$$$$$$                    !!!!!!!!!             ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$          .         !!!!!!!!!           ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$         !!         !!!!!!!!!         ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$        ,!'         !!!!!!!!>        c$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$.       !'          !!!!!!''       ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$>       '           !!!''         d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$>                   !'           ,$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$>             ..                d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$'           ;!!!!''`            $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$       ,;;!'`'  .''            <$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$>    ,;'`'  ,;                  `$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$   -'   ,;!!'                    "?$$$$$$$$$$?$$$$$$$$$$$$$$$$$$$$$$$$$$$     .<!!!'''       <!         !>    ""??$$$?<?$$$$$$$$$$$$$$$$$$$$$$$$""     ;!'''          !!!       ;!!!!;,      `"''""????$$$$$$$$$$$$$$$$""   ,;-''               ',!      ;!!!!<!!!; .                `"""""""""""    `'                  ' '       !!!! ;!!! ;!!!!>;,;, ..                  ' .                   '  '      !!' ,;!!! ;'`!!!!!!!!;!!!!!;  .        >' .''                 ;          !!' ;!!'!';! !! !!!!!!!!!!!!!  '         -'                              <!!  !! `!;! `!' !!!!!!!!!!<!       .                                     `!  ;!  ;!!! <' <!!!! `!!! <       !                                     `;   !>  <!! ;'  !!!!'  !!';!     ;'                                       !   !   !!! !   `!!!  ;!! !      '  '                                    ;   `!  `!! ,'    !'   ;!'                                                    '   !`! !    <     !! <      '                                                 ! ;!        >;! ;>                                                          !'       ; !! '                                                        ' ;!        > ! '                                                           '                                                             
     # /tmp/d20131110-20795-o2zrkz/spec.rb:105:in `block (2 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

Finished in 0.07034 seconds
5 examples, 2 failures

Failed examples:

rspec /tmp/d20131110-20795-o2zrkz/spec.rb:15 # Bitmap can render a column
rspec /tmp/d20131110-20795-o2zrkz/spec.rb:31 # Bitmap renders La Gioconda
Сияна Славова
  • Коректно
  • 5 успешни тест(а)
  • 0 неуспешни тест(а)
Сияна Славова
class Bitmap
def initialize (bytes_list,bytes_per_row = 0)
@bytes_list = bytes_list
@bytes_per_row = bytes_per_row
end
def render (pallete = ['.', '#'])
new_bytes_list = @bytes_per_row != 0 ? add_new_line : @bytes_list
bytes = new_bytes_list.map do |byte|
if byte != "\n"
change_symbols byte.to_s(2).rjust(8 ,"0"), pallete
else
byte
end
end
bytes.join
end
def change_symbols (bytes, pallete)
changed_pallete = []
bytes.each_line do |line|
if pallete.length == 2
slice = 1
elsif pallete.length == 4
slice = 2
else
slice = 4
end
line.split(//).each_slice(slice) do |current|
current.join.to_i(2)
changed_pallete << pallete[current.join.to_i(2)]
end
end
changed_pallete
end
def add_new_line
new_bytes_list = []
@bytes_list.each_with_index do |item, index|
new_bytes_list << item
new_bytes_list
if (((index + 1) % @bytes_per_row) == 0) and (index + 1 != @bytes_list.count)
new_bytes_list << "\n"
end
end
new_bytes_list
end
end
.....

Finished in 0.11616 seconds
5 examples, 0 failures
Александър Антов
  • Некоректно
  • 4 успешни тест(а)
  • 1 неуспешни тест(а)
Александър Антов
class Bitmap
attr_accessor :decimal_array
attr_accessor :bytes_per_row
def initialize(arr, bytes = 0)
self.decimal_array = arr
self.bytes_per_row = bytes
end
def decimal_to_binary_string(dec_arr, palette_size)
bin_string = ""
temp_bin_string = ""
dec_arr.each do |dec|
temp_bin_string = dec.to_s(palette_size)
bin_padding = ""
((16 / palette_size) - temp_bin_string.length).times { bin_padding += "0" }
temp_bin_string = bin_padding + temp_bin_string
bin_string += temp_bin_string
end
if self.bytes_per_row == 0
return bin_string
else
string_arr = bin_string.chars.to_a.each_slice((16 / palette_size) * bytes_per_row).map(&:join)
bin_string = ""
string_arr.each do |iter|
bin_string += iter + "\n"
end
return bin_string.chop
end
end
def render(palette = [".", "#"])
bin_string = decimal_to_binary_string(self.decimal_array, palette.count)
(0..palette.count-1).each do |iter|
bin_string.gsub!(iter.to_s, palette[iter])
end
return bin_string
end
end
....F

Failures:

  1) Bitmap renders La Gioconda
     Failure/Error: Bitmap.new(the_bitmap, 37).render(["!", "\n", ">", "'", "<", "`", " ", ".", ";", ",", "c", "d", "-", "\"", "?", "$"]).should eq expectation
       
       expected: "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!>''''''<!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!'''''`             ``'!!!!!!!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!!!!!!''`          .....         `'!!!!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!!!'`      .      ;;;;;'            `'!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!'     .   '     .;;;;'                `!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!'      ;          `````                   `!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!        .,ccdcccccc,,.                       `!!!!!!!!!!!!\n!!!!!!!!!!!!!!!     .-\"?$$$$$$$$$$$$$$c,                      `!!!!!!!!!!!\n!!!!!!!!!!!!!!    ,ccc$$$$$$$$$$$$$$$$$$$,                     `!!!!!!!!!!\n!!!!!!!!!!!!!    d$$$$$$$$$$$$$$$$$$$$$$$$;.                    `!!!!!!!!!\n!!!!!!!!!!!!    <$$$$$$$$$$$$$$$$$$$$$$$$$$;.                    `!!!!!!!!\n!!!!!!!!!!!     $$$$$$$$$$$$$$$$$$$$$$$$$$$d;;.                   !!!!!!!!\n!!!!!!!!!!'     $$$$$$$$$$$$$$$$$$$$$$$$$$$$$d;.                   !!!!!!!\n!!!!!!!!!'     <$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$                   !!!!!!!\n!!!!!!!!'      `$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$                   `!!!!!!\n!!!!!!!!        c$$$$???$$$$$$$d\"\"  \"\"\"??????\"                      !!!!!!\n!!!!!!!         `\"\" .,.. \"$$$$$    .,dcd                            !!!!!!\n!!!!!!!         .  d!    .?$$$   .,cc,      .,d$d.                  !!!!!!\n!!!!!!!!        <. $$c- <$d$$$   <$$$$---$\"$$$$$$$                  !!!!!!\n!!!!!!!         d$$$dcccd$$$$$   d$$$dcccd$$$$$$$$                  `!!!!!\n!!!!!!         ,$$$$$$$$$$$$$$d d$$$$$$$$$$$$$$$$                   `!!!!!\n!!!!!          `$$$$$$$$$$$$$$$<$$$$$$$$$$$$$$$$'                    !!!!!\n!!!!!          `$$$$$$$$$$$$$$$$\"$$$$$$$$$$$$$d>                     !!!!!\n!!!!!           ?$$$$$$$$$$$$??$c`$$$$$$$$$$$?>'                     `!!!!\n!!!!!           `?$$$$$$!>?\"\"    ,$$$$$$$$$?>>'                       !!!!\n!!!!!.           <<?$$$$$$c.    ,d$$?$$$$$$>>''                       `!!!\n!!!!!!            <!?$d\"??$$d--\"?\"\"  ,$$$$d;>''                       `!!!\n!!!!!!             $$$dccccccccc- cc$$$$$$$>>'                         !!!\n!!!!!              `?$$$$$$$\"\"\"\"  `\"$$$$$>>>''                         `!!\n!!!!!                \"?$$$$$cccccc$$$$??>>>>'                           !!\n!!!!>                  \"$$$$$$$$$$$$$$>>>>''                            `!\n!!!!!                    \"$$$$$$$$???>'''                                !\n!!!!!>                     `\"\"\"\"\"                                        `\n!!!!!!;                       .                                          `\n!!!!!!!                       ?d.                                         \n!!!!!!!!                       $$c,                                       \n!!!!!!!!>                      ?$$$d.              .,c                    \n!!!!!!!!!                       $$$$$$$$$dc,.,,cc$$$$$                    \n!!!!!!!!!                  .,dcc$$$$$$$$$$$$$$$$$$$$$$                    \n!!!!!!!!!               .d$$$$$$$$$$$$$$$$$$$$$$$$$$$$                    \n!!!!!!!!!             ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$          .         \n!!!!!!!!!           ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$         !!         \n!!!!!!!!!         ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$        ,!'         \n!!!!!!!!>        c$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$.       !'          \n!!!!!!''       ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$>       '           \n!!!''         d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$>                   \n!'           ,$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$>             ..    \n            d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$'           ;!!!!''`\n            $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$       ,;;!'`'  .'' \n           <$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$>    ,;'`'  ,;       \n           `$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$   -'   ,;!!'        \n            \"?$$$$$$$$$$?$$$$$$$$$$$$$$$$$$$$$$$$$$$     .<!!!'''       <!\n         !>    \"\"??$$$?<?$$$$$$$$$$$$$$$$$$$$$$$$\"\"     ;!'''          !!!\n       ;!!!!;,      `\"''\"\"????$$$$$$$$$$$$$$$$\"\"   ,;-''               ',!\n      ;!!!!<!!!; .                `\"\"\"\"\"\"\"\"\"\"\"    `'                  ' ' \n      !!!! ;!!! ;!!!!>;,;, ..                  ' .                   '  ' \n     !!' ,;!!! ;'`!!!!!!!!;!!!!!;  .        >' .''                 ;      \n    !!' ;!!'!';! !! !!!!!!!!!!!!!  '         -'                           \n   <!!  !! `!;! `!' !!!!!!!!!!<!       .                                  \n   `!  ;!  ;!!! <' <!!!! `!!! <       !                                   \n  `;   !>  <!! ;'  !!!!'  !!';!     ;'                                    \n   !   !   !!! !   `!!!  ;!! !      '  '                                  \n  ;   `!  `!! ,'    !'   ;!'                                              \n      '   !`! !    <     !! <      '                                      \n           ! ;!        >;! ;>                                             \n             !'       ; !! '                                              \n          ' ;!        > ! '                                               \n            '                                                             "
            got: "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!>''''''<!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!'''''`             \n``'!!!!!!!!!!!!!!!!!!!!!!!!''`       \n   .....         `'!!!!!!!!!!!!!!!!!!\n!!!'`      .      ;;;;;'            `\n'!!!!!!!!!!!!!!!!!!'     .   '     .;\n;;;'                `!!!!!!!!!!!!!!!!\n'      ;          `````              \n     `!!!!!!!!!!!!!!!        .,aabaaa\naaa,,.                       `!!!!!!!\n!!!!!!     .cdeffffffffffffffa,      \n                `!!!!!!!!!!!!!    ,aa\nafffffffffffffffffff,                \n     `!!!!!!!!!!!    bfffffffffffffff\nfffffffff;.                    `!!!!!\n!!!!!!    <ffffffffffffffffffffffffff\n;.                    `!!!!!!!!!     \nfffffffffffffffffffffffffffb;;.      \n             !!!!!!!!!'     fffffffff\nffffffffffffffffffffb;.              \n     !!!!!!!!'     <fffffffffffffffff\nfffffffffffffff                   !!!\n!!!!!'      `ffffffffffffffffffffffff\nffffffff                   `!!!!!!!  \n      affffeeefffffffbdd  dddeeeeeed \n                     !!!!!!         `\ndd .,.. dfffff    .,bab              \n              !!!!!!         .  b    \n.efff   .,aa,      .,bfb.            \n      !!!!!!!        <. ffac <fbfff  \n <ffffcccfdfffffff                  !\n!!!!!         bfffbaaabfffff   bfffba\naabffffffff                  `!!!!!! \n        ,ffffffffffffffb bfffffffffff\nfffff                   `!!!!!       \n   `fffffffffffffff<ffffffffffffffff'\n                    !!!!!          `f\nfffffffffffffffdfffffffffffffb>      \n               !!!!!           efffff\nfffffffeefa`fffffffffffe>'           \n          `!!!!           `effffff>ed\nd    ,fffffffffe>>'                  \n     !!!!.           <<effffffa.    ,\nbffeffffff>>''                       \n`!!!!!            <!efbdeeffbccdedd  \n,ffffb;>''                       `!!!\n!!             fffbaaaaaaaaac aafffff\nff>>'                         !!!!   \n           `efffffffdddd  `dfffff>>>'\n'                         `!!!       \n         defffffaaaaaaffffee>>>>'    \n                       !!!>          \n        dffffffffffffff>>>>''        \n                    `!!!             \n       dffffffffeee>'''              \n                  !!!>               \n      `ddddd                         \n               `!!!;                 \n      .                              \n            `!!!                     \n  eb.                                \n         !!!!                       f\nfa,                                  \n     !!!!>                      efffb\n.              .,a                   \n !!!!                       fffffffff\nba,.,,aafffff                    !!!!\n                  .,baaffffffffffffff\nffffffff                    !!!!     \n          .bfffffffffffffffffffffffff\nfff                    !!!!          \n   ,bffffffffffffffffffffffffffffff  \n        .         !!!!           ,bff\nffffffffffffffffffffffffffffff       \n  !         !!!!         ,bffffffffff\nffffffffffffffffffffffff        ,!'  \n       !!!!>        affffffffffffffff\nffffffffffffffffffff.       '        \n  !!!''       ,bfffffffffffffffffffff\nffffffffffffffff>       '           !\n''         bfffffffffffffffffffffffff\nffffffffffffff>                   '  \n         ,fffffffffffffffffffffffffff\nfffffffffffff>             ..        \n        bffffffffffffffffffffffffffff\nfffffffffffff'           ;!!''`      \n      fffffffffffffffffffffffffffffff\nfffffffffff       ,;;'`'  .''        \n    <ffffffffffffffffffffffffffffffff\nfffffffff>    ,;'`'  ,;              \n    `ffffffffffffffffffffffffffffffff\nfffffffff   c'   ,;!'                \n    deffffffffffeffffffffffffffffffff\nfffffff     .<!!'''       <!         \n!>    ddeefffe<efffffffffffffffffffff\nfffdd     ;!'''          !!       ;!!\n;,      `d''ddeeeeffffffffffffffffdd \n  ,;c''               ',!      ;!!<!;\n .                `ddddddddddd    `' \n                 ' '       !! ;! ;!!>\n;,;, ..                  ' .         \n          '  '      !' ,;!! ;'`!!!!;!\n!!;  .        >' .''                 \n;          !' ;!'';! ! !!!!!!  '     \n    c'                              <\n!  ! `; `!' !!!!!<!       .          \n                           `  ;  ;! <\n' <!! `! <                           \n                 `;   !>  <! ;'  !!' \n !';     ;'                          \n             !   !   !! !   `!  ;! ! \n     '  '                            \n        ;   `!  `! ,'    '   ;'      \n                                     \n         '   `     <     ! <      '  \n                                     \n          ! ;        >;! ;>          \n                                     \n           !'       ; ! '            \n                                     \n       ' ;!        >  '              \n                                     \n        '                            \n                                 "
       
       (compared using ==)
       
       Diff:
       @@ -1,71 +1,127 @@
       -!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
       -!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
       -!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!>''''''<!!!!!!!!!!!!!!!!!!!!!!!!!!!!
       -!!!!!!!!!!!!!!!!!!!!!!!!!!!!'''''`             ``'!!!!!!!!!!!!!!!!!!!!!!!!
       -!!!!!!!!!!!!!!!!!!!!!!!!''`          .....         `'!!!!!!!!!!!!!!!!!!!!!
       -!!!!!!!!!!!!!!!!!!!!!'`      .      ;;;;;'            `'!!!!!!!!!!!!!!!!!!
       -!!!!!!!!!!!!!!!!!!!'     .   '     .;;;;'                `!!!!!!!!!!!!!!!!
       -!!!!!!!!!!!!!!!!!'      ;          `````                   `!!!!!!!!!!!!!!
       -!!!!!!!!!!!!!!!!        .,ccdcccccc,,.                       `!!!!!!!!!!!!
       -!!!!!!!!!!!!!!!     .-"?$$$$$$$$$$$$$$c,                      `!!!!!!!!!!!
       -!!!!!!!!!!!!!!    ,ccc$$$$$$$$$$$$$$$$$$$,                     `!!!!!!!!!!
       -!!!!!!!!!!!!!    d$$$$$$$$$$$$$$$$$$$$$$$$;.                    `!!!!!!!!!
       -!!!!!!!!!!!!    <$$$$$$$$$$$$$$$$$$$$$$$$$$;.                    `!!!!!!!!
       -!!!!!!!!!!!     $$$$$$$$$$$$$$$$$$$$$$$$$$$d;;.                   !!!!!!!!
       -!!!!!!!!!!'     $$$$$$$$$$$$$$$$$$$$$$$$$$$$$d;.                   !!!!!!!
       -!!!!!!!!!'     <$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$                   !!!!!!!
       -!!!!!!!!'      `$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$                   `!!!!!!
       -!!!!!!!!        c$$$$???$$$$$$$d""  """??????"                      !!!!!!
       -!!!!!!!         `"" .,.. "$$$$$    .,dcd                            !!!!!!
       -!!!!!!!         .  d!    .?$$$   .,cc,      .,d$d.                  !!!!!!
       -!!!!!!!!        <. $$c- <$d$$$   <$$$$---$"$$$$$$$                  !!!!!!
       -!!!!!!!         d$$$dcccd$$$$$   d$$$dcccd$$$$$$$$                  `!!!!!
       -!!!!!!         ,$$$$$$$$$$$$$$d d$$$$$$$$$$$$$$$$                   `!!!!!
       -!!!!!          `$$$$$$$$$$$$$$$<$$$$$$$$$$$$$$$$'                    !!!!!
       -!!!!!          `$$$$$$$$$$$$$$$$"$$$$$$$$$$$$$d>                     !!!!!
       -!!!!!           ?$$$$$$$$$$$$??$c`$$$$$$$$$$$?>'                     `!!!!
       -!!!!!           `?$$$$$$!>?""    ,$$$$$$$$$?>>'                       !!!!
       -!!!!!.           <<?$$$$$$c.    ,d$$?$$$$$$>>''                       `!!!
       -!!!!!!            <!?$d"??$$d--"?""  ,$$$$d;>''                       `!!!
       -!!!!!!             $$$dccccccccc- cc$$$$$$$>>'                         !!!
       -!!!!!              `?$$$$$$$""""  `"$$$$$>>>''                         `!!
       -!!!!!                "?$$$$$cccccc$$$$??>>>>'                           !!
       -!!!!>                  "$$$$$$$$$$$$$$>>>>''                            `!
       -!!!!!                    "$$$$$$$$???>'''                                !
       -!!!!!>                     `"""""                                        `
       -!!!!!!;                       .                                          `
       -!!!!!!!                       ?d.                                         
       -!!!!!!!!                       $$c,                                       
       -!!!!!!!!>                      ?$$$d.              .,c                    
       -!!!!!!!!!                       $$$$$$$$$dc,.,,cc$$$$$                    
       -!!!!!!!!!                  .,dcc$$$$$$$$$$$$$$$$$$$$$$                    
       -!!!!!!!!!               .d$$$$$$$$$$$$$$$$$$$$$$$$$$$$                    
       -!!!!!!!!!             ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$          .         
       -!!!!!!!!!           ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$         !!         
       -!!!!!!!!!         ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$        ,!'         
       -!!!!!!!!>        c$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$.       !'          
       -!!!!!!''       ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$>       '           
       -!!!''         d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$>                   
       -!'           ,$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$>             ..    
       -            d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$'           ;!!!!''`
       -            $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$       ,;;!'`'  .'' 
       -           <$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$>    ,;'`'  ,;       
       -           `$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$   -'   ,;!!'        
       -            "?$$$$$$$$$$?$$$$$$$$$$$$$$$$$$$$$$$$$$$     .<!!!'''       <!
       -         !>    ""??$$$?<?$$$$$$$$$$$$$$$$$$$$$$$$""     ;!'''          !!!
       -       ;!!!!;,      `"''""????$$$$$$$$$$$$$$$$""   ,;-''               ',!
       -      ;!!!!<!!!; .                `"""""""""""    `'                  ' ' 
       -      !!!! ;!!! ;!!!!>;,;, ..                  ' .                   '  ' 
       -     !!' ,;!!! ;'`!!!!!!!!;!!!!!;  .        >' .''                 ;      
       -    !!' ;!!'!';! !! !!!!!!!!!!!!!  '         -'                           
       -   <!!  !! `!;! `!' !!!!!!!!!!<!       .                                  
       -   `!  ;!  ;!!! <' <!!!! `!!! <       !                                   
       -  `;   !>  <!! ;'  !!!!'  !!';!     ;'                                    
       -   !   !   !!! !   `!!!  ;!! !      '  '                                  
       -  ;   `!  `!! ,'    !'   ;!'                                              
       -      '   !`! !    <     !! <      '                                      
       -           ! ;!        >;! ;>                                             
       -             !'       ; !! '                                              
       -          ' ;!        > ! '                                               
       -            '                                                             
       +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
       +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
       +!!!!!!!!!!!!!!!!!!!>''''''<!!!!!!!!!!
       +!!!!!!!!!!!!!!!!!!'''''`             
       +``'!!!!!!!!!!!!!!!!!!!!!!!!''`       
       +   .....         `'!!!!!!!!!!!!!!!!!!
       +!!!'`      .      ;;;;;'            `
       +'!!!!!!!!!!!!!!!!!!'     .   '     .;
       +;;;'                `!!!!!!!!!!!!!!!!
       +'      ;          `````              
       +     `!!!!!!!!!!!!!!!        .,aabaaa
       +aaa,,.                       `!!!!!!!
       +!!!!!!     .cdeffffffffffffffa,      
       +                `!!!!!!!!!!!!!    ,aa
       +afffffffffffffffffff,                
       +     `!!!!!!!!!!!    bfffffffffffffff
       +fffffffff;.                    `!!!!!
       +!!!!!!    <ffffffffffffffffffffffffff
       +;.                    `!!!!!!!!!     
       +fffffffffffffffffffffffffffb;;.      
       +             !!!!!!!!!'     fffffffff
       +ffffffffffffffffffffb;.              
       +     !!!!!!!!'     <fffffffffffffffff
       +fffffffffffffff                   !!!
       +!!!!!'      `ffffffffffffffffffffffff
       +ffffffff                   `!!!!!!!  
       +      affffeeefffffffbdd  dddeeeeeed 
       +                     !!!!!!         `
       +dd .,.. dfffff    .,bab              
       +              !!!!!!         .  b    
       +.efff   .,aa,      .,bfb.            
       +      !!!!!!!        <. ffac <fbfff  
       + <ffffcccfdfffffff                  !
       +!!!!!         bfffbaaabfffff   bfffba
       +aabffffffff                  `!!!!!! 
       +        ,ffffffffffffffb bfffffffffff
       +fffff                   `!!!!!       
       +   `fffffffffffffff<ffffffffffffffff'
       +                    !!!!!          `f
       +fffffffffffffffdfffffffffffffb>      
       +               !!!!!           efffff
       +fffffffeefa`fffffffffffe>'           
       +          `!!!!           `effffff>ed
       +d    ,fffffffffe>>'                  
       +     !!!!.           <<effffffa.    ,
       +bffeffffff>>''                       
       +`!!!!!            <!efbdeeffbccdedd  
       +,ffffb;>''                       `!!!
       +!!             fffbaaaaaaaaac aafffff
       +ff>>'                         !!!!   
       +           `efffffffdddd  `dfffff>>>'
       +'                         `!!!       
       +         defffffaaaaaaffffee>>>>'    
       +                       !!!>          
       +        dffffffffffffff>>>>''        
       +                    `!!!             
       +       dffffffffeee>'''              
       +                  !!!>               
       +      `ddddd                         
       +               `!!!;                 
       +      .                              
       +            `!!!                     
       +  eb.                                
       +         !!!!                       f
       +fa,                                  
       +     !!!!>                      efffb
       +.              .,a                   
       + !!!!                       fffffffff
       +ba,.,,aafffff                    !!!!
       +                  .,baaffffffffffffff
       +ffffffff                    !!!!     
       +          .bfffffffffffffffffffffffff
       +fff                    !!!!          
       +   ,bffffffffffffffffffffffffffffff  
       +        .         !!!!           ,bff
       +ffffffffffffffffffffffffffffff       
       +  !         !!!!         ,bffffffffff
       +ffffffffffffffffffffffff        ,!'  
       +       !!!!>        affffffffffffffff
       +ffffffffffffffffffff.       '        
       +  !!!''       ,bfffffffffffffffffffff
       +ffffffffffffffff>       '           !
       +''         bfffffffffffffffffffffffff
       +ffffffffffffff>                   '  
       +         ,fffffffffffffffffffffffffff
       +fffffffffffff>             ..        
       +        bffffffffffffffffffffffffffff
       +fffffffffffff'           ;!!''`      
       +      fffffffffffffffffffffffffffffff
       +fffffffffff       ,;;'`'  .''        
       +    <ffffffffffffffffffffffffffffffff
       +fffffffff>    ,;'`'  ,;              
       +    `ffffffffffffffffffffffffffffffff
       +fffffffff   c'   ,;!'                
       +    deffffffffffeffffffffffffffffffff
       +fffffff     .<!!'''       <!         
       +!>    ddeefffe<efffffffffffffffffffff
       +fffdd     ;!'''          !!       ;!!
       +;,      `d''ddeeeeffffffffffffffffdd 
       +  ,;c''               ',!      ;!!<!;
       + .                `ddddddddddd    `' 
       +                 ' '       !! ;! ;!!>
       +;,;, ..                  ' .         
       +          '  '      !' ,;!! ;'`!!!!;!
       +!!;  .        >' .''                 
       +;          !' ;!'';! ! !!!!!!  '     
       +    c'                              <
       +!  ! `; `!' !!!!!<!       .          
       +                           `  ;  ;! <
       +' <!! `! <                           
       +                 `;   !>  <! ;'  !!' 
       + !';     ;'                          
       +             !   !   !! !   `!  ;! ! 
       +     '  '                            
       +        ;   `!  `! ,'    '   ;'      
       +                                     
       +         '   `     <     ! <      '  
       +                                     
       +          ! ;        >;! ;>          
       +                                     
       +           !'       ; ! '            
       +                                     
       +       ' ;!        >  '              
       +                                     
       +        '                            
       +                                 
     # /tmp/d20131110-20795-u5xwim/spec.rb:105:in `block (2 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

Finished in 0.03585 seconds
5 examples, 1 failure

Failed examples:

rspec /tmp/d20131110-20795-u5xwim/spec.rb:31 # Bitmap renders La Gioconda
Моника Димитрова
  • Некоректно
  • 3 успешни тест(а)
  • 2 неуспешни тест(а)
Моника Димитрова
class Bitmap
def initialize(bytes, bytes_per_line = 1)
@bytes = bytes
@bytes_per_line = bytes_per_line
end
def render(palette = ['.', '#'])
size = palette.length
rendered = @bytes.map { |byte| byte.to_s(size).rjust(16 / size, '0') }
rendered = rendered.each_slice(@bytes_per_line).map { |slice| slice.join() }.join("\n")
(0...size).each { |i| rendered = rendered.gsub(i.to_s, palette[i]) }
rendered
end
end
F...F

Failures:

  1) Bitmap renders bytes
     Failure/Error: expect(Bitmap.new([9, 32, 7]).render).to eq <<-ASCII.strip
       
       expected: "....#..#..#..........###"
            got: "....#..#\n..#.....\n.....###"
       
       (compared using ==)
       
       Diff:
       @@ -1,2 +1,4 @@
       -....#..#..#..........###
       +....#..#
       +..#.....
       +.....###
     # /tmp/d20131110-20795-13n90na/spec.rb:3:in `block (2 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  2) Bitmap renders La Gioconda
     Failure/Error: Bitmap.new(the_bitmap, 37).render(["!", "\n", ">", "'", "<", "`", " ", ".", ";", ",", "c", "d", "-", "\"", "?", "$"]).should eq expectation
       
       expected: "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!>''''''<!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!'''''`             ``'!!!!!!!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!!!!!!''`          .....         `'!!!!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!!!'`      .      ;;;;;'            `'!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!'     .   '     .;;;;'                `!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!'      ;          `````                   `!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!        .,ccdcccccc,,.                       `!!!!!!!!!!!!\n!!!!!!!!!!!!!!!     .-\"?$$$$$$$$$$$$$$c,                      `!!!!!!!!!!!\n!!!!!!!!!!!!!!    ,ccc$$$$$$$$$$$$$$$$$$$,                     `!!!!!!!!!!\n!!!!!!!!!!!!!    d$$$$$$$$$$$$$$$$$$$$$$$$;.                    `!!!!!!!!!\n!!!!!!!!!!!!    <$$$$$$$$$$$$$$$$$$$$$$$$$$;.                    `!!!!!!!!\n!!!!!!!!!!!     $$$$$$$$$$$$$$$$$$$$$$$$$$$d;;.                   !!!!!!!!\n!!!!!!!!!!'     $$$$$$$$$$$$$$$$$$$$$$$$$$$$$d;.                   !!!!!!!\n!!!!!!!!!'     <$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$                   !!!!!!!\n!!!!!!!!'      `$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$                   `!!!!!!\n!!!!!!!!        c$$$$???$$$$$$$d\"\"  \"\"\"??????\"                      !!!!!!\n!!!!!!!         `\"\" .,.. \"$$$$$    .,dcd                            !!!!!!\n!!!!!!!         .  d!    .?$$$   .,cc,      .,d$d.                  !!!!!!\n!!!!!!!!        <. $$c- <$d$$$   <$$$$---$\"$$$$$$$                  !!!!!!\n!!!!!!!         d$$$dcccd$$$$$   d$$$dcccd$$$$$$$$                  `!!!!!\n!!!!!!         ,$$$$$$$$$$$$$$d d$$$$$$$$$$$$$$$$                   `!!!!!\n!!!!!          `$$$$$$$$$$$$$$$<$$$$$$$$$$$$$$$$'                    !!!!!\n!!!!!          `$$$$$$$$$$$$$$$$\"$$$$$$$$$$$$$d>                     !!!!!\n!!!!!           ?$$$$$$$$$$$$??$c`$$$$$$$$$$$?>'                     `!!!!\n!!!!!           `?$$$$$$!>?\"\"    ,$$$$$$$$$?>>'                       !!!!\n!!!!!.           <<?$$$$$$c.    ,d$$?$$$$$$>>''                       `!!!\n!!!!!!            <!?$d\"??$$d--\"?\"\"  ,$$$$d;>''                       `!!!\n!!!!!!             $$$dccccccccc- cc$$$$$$$>>'                         !!!\n!!!!!              `?$$$$$$$\"\"\"\"  `\"$$$$$>>>''                         `!!\n!!!!!                \"?$$$$$cccccc$$$$??>>>>'                           !!\n!!!!>                  \"$$$$$$$$$$$$$$>>>>''                            `!\n!!!!!                    \"$$$$$$$$???>'''                                !\n!!!!!>                     `\"\"\"\"\"                                        `\n!!!!!!;                       .                                          `\n!!!!!!!                       ?d.                                         \n!!!!!!!!                       $$c,                                       \n!!!!!!!!>                      ?$$$d.              .,c                    \n!!!!!!!!!                       $$$$$$$$$dc,.,,cc$$$$$                    \n!!!!!!!!!                  .,dcc$$$$$$$$$$$$$$$$$$$$$$                    \n!!!!!!!!!               .d$$$$$$$$$$$$$$$$$$$$$$$$$$$$                    \n!!!!!!!!!             ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$          .         \n!!!!!!!!!           ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$         !!         \n!!!!!!!!!         ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$        ,!'         \n!!!!!!!!>        c$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$.       !'          \n!!!!!!''       ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$>       '           \n!!!''         d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$>                   \n!'           ,$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$>             ..    \n            d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$'           ;!!!!''`\n            $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$       ,;;!'`'  .'' \n           <$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$>    ,;'`'  ,;       \n           `$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$   -'   ,;!!'        \n            \"?$$$$$$$$$$?$$$$$$$$$$$$$$$$$$$$$$$$$$$     .<!!!'''       <!\n         !>    \"\"??$$$?<?$$$$$$$$$$$$$$$$$$$$$$$$\"\"     ;!'''          !!!\n       ;!!!!;,      `\"''\"\"????$$$$$$$$$$$$$$$$\"\"   ,;-''               ',!\n      ;!!!!<!!!; .                `\"\"\"\"\"\"\"\"\"\"\"    `'                  ' ' \n      !!!! ;!!! ;!!!!>;,;, ..                  ' .                   '  ' \n     !!' ,;!!! ;'`!!!!!!!!;!!!!!;  .        >' .''                 ;      \n    !!' ;!!'!';! !! !!!!!!!!!!!!!  '         -'                           \n   <!!  !! `!;! `!' !!!!!!!!!!<!       .                                  \n   `!  ;!  ;!!! <' <!!!! `!!! <       !                                   \n  `;   !>  <!! ;'  !!!!'  !!';!     ;'                                    \n   !   !   !!! !   `!!!  ;!! !      '  '                                  \n  ;   `!  `!! ,'    !'   ;!'                                              \n      '   !`! !    <     !! <      '                                      \n           ! ;!        >;! ;>                                             \n             !'       ; !! '                                              \n          ' ;!        > ! '                                               \n            '                                                             "
            got: "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!>''''''<!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!'''''`             ``'!!!!!!!!!!!!\n!!!!!!!!!!!!''`          .....         `'!!!!!!!!!!!\n!!!!!!!!!!'`      .      ;;;;;'            `'!!!!!!!!!\n!!!!!!!!!'     .   '     .;;;;'                `!!!!!!!!\n!!!!!!!!'      ;          `````                   `!!!!!!!\n!!!!!!!!        .,aabaaaaaa,,.                       `!!!!!!\n!!!!!!!     .cdeffffffffffffffa,                      `!!!!!!\n!!!!!!!    ,aaafffffffffffffffffff,                     `!!!!!\n!!!!!!    bffffffffffffffffffffffff;.                    `!!!!!\n!!!!!!    <ffffffffffffffffffffffffff;.                    `!!!!\n!!!!!     fffffffffffffffffffffffffffb;;.                   !!!!\n!!!!!'     fffffffffffffffffffffffffffffb;.                   !!!!\n!!!!'     <ffffffffffffffffffffffffffffffff                   !!!!\n!!!!'      `ffffffffffffffffffffffffffffffff                   `!!!\n!!!!        affffeeefffffffbdd  dddeeeeeed                      !!!\n!!!         `dd .,.. dfffff    .,bab                            !!!\n!!!         .  b    .efff   .,aa,      .,bfb.                  !!!\n!!!!        <. ffac <fbfff   <ffffcccfdfffffff                  !!!\n!!!         bfffbaaabfffff   bfffbaaabffffffff                  `!!!\n!!!         ,ffffffffffffffb bffffffffffffffff                   `!!!\n!!          `fffffffffffffff<ffffffffffffffff'                    !!!\n!!          `ffffffffffffffffdfffffffffffffb>                     !!!\n!!           effffffffffffeefa`fffffffffffe>'                     `!!\n!!           `effffff>edd    ,fffffffffe>>'                       !!\n!!.           <<effffffa.    ,bffeffffff>>''                       `!!\n!!!            <!efbdeeffbccdedd  ,ffffb;>''                       `!!\n!!!             fffbaaaaaaaaac aafffffff>>'                         !!\n!!              `efffffffdddd  `dfffff>>>''                         `!\n!!                defffffaaaaaaffffee>>>>'                           !\n!!>                  dffffffffffffff>>>>''                            `!\n!!                    dffffffffeee>'''                                !\n!!>                     `ddddd                                        `\n!!!;                       .                                          `\n!!!                       eb.                                         \n!!!!                       ffa,                                       \n!!!!>                      efffb.              .,a                    \n!!!!                       fffffffffba,.,,aafffff                    \n!!!!                  .,baaffffffffffffffffffffff                    \n!!!!               .bffffffffffffffffffffffffffff                    \n!!!!             ,bffffffffffffffffffffffffffffff          .         \n!!!!           ,bffffffffffffffffffffffffffffffff         !         \n!!!!         ,bffffffffffffffffffffffffffffffffff        ,!'         \n!!!!>        affffffffffffffffffffffffffffffffffff.       '          \n!!!''       ,bfffffffffffffffffffffffffffffffffffff>       '           \n!''         bfffffffffffffffffffffffffffffffffffffff>                   \n'           ,ffffffffffffffffffffffffffffffffffffffff>             ..    \n            bfffffffffffffffffffffffffffffffffffffffff'           ;!!''`\n            ffffffffffffffffffffffffffffffffffffffffff       ,;;'`'  .'' \n           <fffffffffffffffffffffffffffffffffffffffff>    ,;'`'  ,;       \n           `fffffffffffffffffffffffffffffffffffffffff   c'   ,;!'        \n            deffffffffffefffffffffffffffffffffffffff     .<!!'''       <!\n         !>    ddeefffe<effffffffffffffffffffffffdd     ;!'''          !!\n       ;!!;,      `d''ddeeeeffffffffffffffffdd   ,;c''               ',!\n      ;!!<!; .                `ddddddddddd    `'                  ' ' \n      !! ;! ;!!>;,;, ..                  ' .                   '  ' \n     !' ,;!! ;'`!!!!;!!!;  .        >' .''                 ;      \n    !' ;!'';! ! !!!!!!  '         c'                           \n   <!  ! `; `!' !!!!!<!       .                                  \n   `  ;  ;! <' <!! `! <                                          \n  `;   !>  <! ;'  !!'  !';     ;'                                    \n   !   !   !! !   `!  ;! !      '  '                                  \n  ;   `!  `! ,'    '   ;'                                              \n      '   `     <     ! <      '                                      \n           ! ;        >;! ;>                                             \n             !'       ; ! '                                              \n          ' ;!        >  '                                               \n            '                                                             "
       
       (compared using ==)
       
       Diff:
       @@ -1,71 +1,71 @@
       -!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
       -!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
       -!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!>''''''<!!!!!!!!!!!!!!!!!!!!!!!!!!!!
       -!!!!!!!!!!!!!!!!!!!!!!!!!!!!'''''`             ``'!!!!!!!!!!!!!!!!!!!!!!!!
       -!!!!!!!!!!!!!!!!!!!!!!!!''`          .....         `'!!!!!!!!!!!!!!!!!!!!!
       -!!!!!!!!!!!!!!!!!!!!!'`      .      ;;;;;'            `'!!!!!!!!!!!!!!!!!!
       -!!!!!!!!!!!!!!!!!!!'     .   '     .;;;;'                `!!!!!!!!!!!!!!!!
       -!!!!!!!!!!!!!!!!!'      ;          `````                   `!!!!!!!!!!!!!!
       -!!!!!!!!!!!!!!!!        .,ccdcccccc,,.                       `!!!!!!!!!!!!
       -!!!!!!!!!!!!!!!     .-"?$$$$$$$$$$$$$$c,                      `!!!!!!!!!!!
       -!!!!!!!!!!!!!!    ,ccc$$$$$$$$$$$$$$$$$$$,                     `!!!!!!!!!!
       -!!!!!!!!!!!!!    d$$$$$$$$$$$$$$$$$$$$$$$$;.                    `!!!!!!!!!
       -!!!!!!!!!!!!    <$$$$$$$$$$$$$$$$$$$$$$$$$$;.                    `!!!!!!!!
       -!!!!!!!!!!!     $$$$$$$$$$$$$$$$$$$$$$$$$$$d;;.                   !!!!!!!!
       -!!!!!!!!!!'     $$$$$$$$$$$$$$$$$$$$$$$$$$$$$d;.                   !!!!!!!
       -!!!!!!!!!'     <$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$                   !!!!!!!
       -!!!!!!!!'      `$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$                   `!!!!!!
       -!!!!!!!!        c$$$$???$$$$$$$d""  """??????"                      !!!!!!
       -!!!!!!!         `"" .,.. "$$$$$    .,dcd                            !!!!!!
       -!!!!!!!         .  d!    .?$$$   .,cc,      .,d$d.                  !!!!!!
       -!!!!!!!!        <. $$c- <$d$$$   <$$$$---$"$$$$$$$                  !!!!!!
       -!!!!!!!         d$$$dcccd$$$$$   d$$$dcccd$$$$$$$$                  `!!!!!
       -!!!!!!         ,$$$$$$$$$$$$$$d d$$$$$$$$$$$$$$$$                   `!!!!!
       -!!!!!          `$$$$$$$$$$$$$$$<$$$$$$$$$$$$$$$$'                    !!!!!
       -!!!!!          `$$$$$$$$$$$$$$$$"$$$$$$$$$$$$$d>                     !!!!!
       -!!!!!           ?$$$$$$$$$$$$??$c`$$$$$$$$$$$?>'                     `!!!!
       -!!!!!           `?$$$$$$!>?""    ,$$$$$$$$$?>>'                       !!!!
       -!!!!!.           <<?$$$$$$c.    ,d$$?$$$$$$>>''                       `!!!
       -!!!!!!            <!?$d"??$$d--"?""  ,$$$$d;>''                       `!!!
       -!!!!!!             $$$dccccccccc- cc$$$$$$$>>'                         !!!
       -!!!!!              `?$$$$$$$""""  `"$$$$$>>>''                         `!!
       -!!!!!                "?$$$$$cccccc$$$$??>>>>'                           !!
       -!!!!>                  "$$$$$$$$$$$$$$>>>>''                            `!
       -!!!!!                    "$$$$$$$$???>'''                                !
       -!!!!!>                     `"""""                                        `
       -!!!!!!;                       .                                          `
       -!!!!!!!                       ?d.                                         
       -!!!!!!!!                       $$c,                                       
       -!!!!!!!!>                      ?$$$d.              .,c                    
       -!!!!!!!!!                       $$$$$$$$$dc,.,,cc$$$$$                    
       -!!!!!!!!!                  .,dcc$$$$$$$$$$$$$$$$$$$$$$                    
       -!!!!!!!!!               .d$$$$$$$$$$$$$$$$$$$$$$$$$$$$                    
       -!!!!!!!!!             ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$          .         
       -!!!!!!!!!           ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$         !!         
       -!!!!!!!!!         ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$        ,!'         
       -!!!!!!!!>        c$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$.       !'          
       -!!!!!!''       ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$>       '           
       -!!!''         d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$>                   
       -!'           ,$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$>             ..    
       -            d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$'           ;!!!!''`
       -            $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$       ,;;!'`'  .'' 
       -           <$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$>    ,;'`'  ,;       
       -           `$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$   -'   ,;!!'        
       -            "?$$$$$$$$$$?$$$$$$$$$$$$$$$$$$$$$$$$$$$     .<!!!'''       <!
       -         !>    ""??$$$?<?$$$$$$$$$$$$$$$$$$$$$$$$""     ;!'''          !!!
       -       ;!!!!;,      `"''""????$$$$$$$$$$$$$$$$""   ,;-''               ',!
       -      ;!!!!<!!!; .                `"""""""""""    `'                  ' ' 
       -      !!!! ;!!! ;!!!!>;,;, ..                  ' .                   '  ' 
       -     !!' ,;!!! ;'`!!!!!!!!;!!!!!;  .        >' .''                 ;      
       -    !!' ;!!'!';! !! !!!!!!!!!!!!!  '         -'                           
       -   <!!  !! `!;! `!' !!!!!!!!!!<!       .                                  
       -   `!  ;!  ;!!! <' <!!!! `!!! <       !                                   
       -  `;   !>  <!! ;'  !!!!'  !!';!     ;'                                    
       -   !   !   !!! !   `!!!  ;!! !      '  '                                  
       -  ;   `!  `!! ,'    !'   ;!'                                              
       -      '   !`! !    <     !! <      '                                      
       -           ! ;!        >;! ;>                                             
       -             !'       ; !! '                                              
       -          ' ;!        > ! '                                               
       +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
       +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
       +!!!!!!!!!!!!!!!!!!!>''''''<!!!!!!!!!!!!!!
       +!!!!!!!!!!!!!!'''''`             ``'!!!!!!!!!!!!
       +!!!!!!!!!!!!''`          .....         `'!!!!!!!!!!!
       +!!!!!!!!!!'`      .      ;;;;;'            `'!!!!!!!!!
       +!!!!!!!!!'     .   '     .;;;;'                `!!!!!!!!
       +!!!!!!!!'      ;          `````                   `!!!!!!!
       +!!!!!!!!        .,aabaaaaaa,,.                       `!!!!!!
       +!!!!!!!     .cdeffffffffffffffa,                      `!!!!!!
       +!!!!!!!    ,aaafffffffffffffffffff,                     `!!!!!
       +!!!!!!    bffffffffffffffffffffffff;.                    `!!!!!
       +!!!!!!    <ffffffffffffffffffffffffff;.                    `!!!!
       +!!!!!     fffffffffffffffffffffffffffb;;.                   !!!!
       +!!!!!'     fffffffffffffffffffffffffffffb;.                   !!!!
       +!!!!'     <ffffffffffffffffffffffffffffffff                   !!!!
       +!!!!'      `ffffffffffffffffffffffffffffffff                   `!!!
       +!!!!        affffeeefffffffbdd  dddeeeeeed                      !!!
       +!!!         `dd .,.. dfffff    .,bab                            !!!
       +!!!         .  b    .efff   .,aa,      .,bfb.                  !!!
       +!!!!        <. ffac <fbfff   <ffffcccfdfffffff                  !!!
       +!!!         bfffbaaabfffff   bfffbaaabffffffff                  `!!!
       +!!!         ,ffffffffffffffb bffffffffffffffff                   `!!!
       +!!          `fffffffffffffff<ffffffffffffffff'                    !!!
       +!!          `ffffffffffffffffdfffffffffffffb>                     !!!
       +!!           effffffffffffeefa`fffffffffffe>'                     `!!
       +!!           `effffff>edd    ,fffffffffe>>'                       !!
       +!!.           <<effffffa.    ,bffeffffff>>''                       `!!
       +!!!            <!efbdeeffbccdedd  ,ffffb;>''                       `!!
       +!!!             fffbaaaaaaaaac aafffffff>>'                         !!
       +!!              `efffffffdddd  `dfffff>>>''                         `!
       +!!                defffffaaaaaaffffee>>>>'                           !
       +!!>                  dffffffffffffff>>>>''                            `!
       +!!                    dffffffffeee>'''                                !
       +!!>                     `ddddd                                        `
       +!!!;                       .                                          `
       +!!!                       eb.                                         
       +!!!!                       ffa,                                       
       +!!!!>                      efffb.              .,a                    
       +!!!!                       fffffffffba,.,,aafffff                    
       +!!!!                  .,baaffffffffffffffffffffff                    
       +!!!!               .bffffffffffffffffffffffffffff                    
       +!!!!             ,bffffffffffffffffffffffffffffff          .         
       +!!!!           ,bffffffffffffffffffffffffffffffff         !         
       +!!!!         ,bffffffffffffffffffffffffffffffffff        ,!'         
       +!!!!>        affffffffffffffffffffffffffffffffffff.       '          
       +!!!''       ,bfffffffffffffffffffffffffffffffffffff>       '           
       +!''         bfffffffffffffffffffffffffffffffffffffff>                   
       +'           ,ffffffffffffffffffffffffffffffffffffffff>             ..    
       +            bfffffffffffffffffffffffffffffffffffffffff'           ;!!''`
       +            ffffffffffffffffffffffffffffffffffffffffff       ,;;'`'  .'' 
       +           <fffffffffffffffffffffffffffffffffffffffff>    ,;'`'  ,;       
       +           `fffffffffffffffffffffffffffffffffffffffff   c'   ,;!'        
       +            deffffffffffefffffffffffffffffffffffffff     .<!!'''       <!
       +         !>    ddeefffe<effffffffffffffffffffffffdd     ;!'''          !!
       +       ;!!;,      `d''ddeeeeffffffffffffffffdd   ,;c''               ',!
       +      ;!!<!; .                `ddddddddddd    `'                  ' ' 
       +      !! ;! ;!!>;,;, ..                  ' .                   '  ' 
       +     !' ,;!! ;'`!!!!;!!!;  .        >' .''                 ;      
       +    !' ;!'';! ! !!!!!!  '         c'                           
       +   <!  ! `; `!' !!!!!<!       .                                  
       +   `  ;  ;! <' <!! `! <                                          
       +  `;   !>  <! ;'  !!'  !';     ;'                                    
       +   !   !   !! !   `!  ;! !      '  '                                  
       +  ;   `!  `! ,'    '   ;'                                              
       +      '   `     <     ! <      '                                      
       +           ! ;        >;! ;>                                             
       +             !'       ; ! '                                              
       +          ' ;!        >  '                                               
                    '                                                             
     # /tmp/d20131110-20795-13n90na/spec.rb:105:in `block (2 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

Finished in 0.02725 seconds
5 examples, 2 failures

Failed examples:

rspec /tmp/d20131110-20795-13n90na/spec.rb:2 # Bitmap renders bytes
rspec /tmp/d20131110-20795-13n90na/spec.rb:31 # Bitmap renders La Gioconda
Марио Даскалов
  • Коректно
  • 5 успешни тест(а)
  • 0 неуспешни тест(а)
Марио Даскалов
class Bitmap
def initialize(byte_array, line_length=byte_array.size)
@bitmap = byte_array.map do |byte|
("%08b" % byte).each_char.map(&:to_i)
end.flatten
@line_length = line_length
end
def render(palette=['.', '#'])
color_bits_size = Math.log2(palette.size).to_i
line_length = @line_length * 8 / color_bits_size
encoded_color_map = @bitmap.each_slice(color_bits_size).map do |bit_seq|
bit_seq.join.to_i(2)
end
encoded_color_map.map do |color|
palette[color]
end.each_slice(line_length).map(&:join).join("\n")
end
end
.....

Finished in 0.10557 seconds
5 examples, 0 failures
Николай Генов
  • Некоректно
  • 4 успешни тест(а)
  • 1 неуспешни тест(а)
Николай Генов
class Bitmap
def initialize(bytes, bytes_per_row = bytes.size)
@bytes, @bytes_per_row = bytes, bytes_per_row
end
def render(palette = ['.','#'])
size = 16 / palette.length
@bytes.each_slice(@bytes_per_row).map do |bytes|
bytes.map do|byte|
changed_byte = byte.to_s(palette.length).rjust(size, '0')
0.upto(size - 1).map { |position| palette[changed_byte[position].to_i] }
end.join()
end.join("\n")
end
end
....F

Failures:

  1) Bitmap renders La Gioconda
     Failure/Error: Bitmap.new(the_bitmap, 37).render(["!", "\n", ">", "'", "<", "`", " ", ".", ";", ",", "c", "d", "-", "\"", "?", "$"]).should eq expectation
       
       expected: "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!>''''''<!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!'''''`             ``'!!!!!!!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!!!!!!''`          .....         `'!!!!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!!!'`      .      ;;;;;'            `'!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!'     .   '     .;;;;'                `!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!'      ;          `````                   `!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!        .,ccdcccccc,,.                       `!!!!!!!!!!!!\n!!!!!!!!!!!!!!!     .-\"?$$$$$$$$$$$$$$c,                      `!!!!!!!!!!!\n!!!!!!!!!!!!!!    ,ccc$$$$$$$$$$$$$$$$$$$,                     `!!!!!!!!!!\n!!!!!!!!!!!!!    d$$$$$$$$$$$$$$$$$$$$$$$$;.                    `!!!!!!!!!\n!!!!!!!!!!!!    <$$$$$$$$$$$$$$$$$$$$$$$$$$;.                    `!!!!!!!!\n!!!!!!!!!!!     $$$$$$$$$$$$$$$$$$$$$$$$$$$d;;.                   !!!!!!!!\n!!!!!!!!!!'     $$$$$$$$$$$$$$$$$$$$$$$$$$$$$d;.                   !!!!!!!\n!!!!!!!!!'     <$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$                   !!!!!!!\n!!!!!!!!'      `$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$                   `!!!!!!\n!!!!!!!!        c$$$$???$$$$$$$d\"\"  \"\"\"??????\"                      !!!!!!\n!!!!!!!         `\"\" .,.. \"$$$$$    .,dcd                            !!!!!!\n!!!!!!!         .  d!    .?$$$   .,cc,      .,d$d.                  !!!!!!\n!!!!!!!!        <. $$c- <$d$$$   <$$$$---$\"$$$$$$$                  !!!!!!\n!!!!!!!         d$$$dcccd$$$$$   d$$$dcccd$$$$$$$$                  `!!!!!\n!!!!!!         ,$$$$$$$$$$$$$$d d$$$$$$$$$$$$$$$$                   `!!!!!\n!!!!!          `$$$$$$$$$$$$$$$<$$$$$$$$$$$$$$$$'                    !!!!!\n!!!!!          `$$$$$$$$$$$$$$$$\"$$$$$$$$$$$$$d>                     !!!!!\n!!!!!           ?$$$$$$$$$$$$??$c`$$$$$$$$$$$?>'                     `!!!!\n!!!!!           `?$$$$$$!>?\"\"    ,$$$$$$$$$?>>'                       !!!!\n!!!!!.           <<?$$$$$$c.    ,d$$?$$$$$$>>''                       `!!!\n!!!!!!            <!?$d\"??$$d--\"?\"\"  ,$$$$d;>''                       `!!!\n!!!!!!             $$$dccccccccc- cc$$$$$$$>>'                         !!!\n!!!!!              `?$$$$$$$\"\"\"\"  `\"$$$$$>>>''                         `!!\n!!!!!                \"?$$$$$cccccc$$$$??>>>>'                           !!\n!!!!>                  \"$$$$$$$$$$$$$$>>>>''                            `!\n!!!!!                    \"$$$$$$$$???>'''                                !\n!!!!!>                     `\"\"\"\"\"                                        `\n!!!!!!;                       .                                          `\n!!!!!!!                       ?d.                                         \n!!!!!!!!                       $$c,                                       \n!!!!!!!!>                      ?$$$d.              .,c                    \n!!!!!!!!!                       $$$$$$$$$dc,.,,cc$$$$$                    \n!!!!!!!!!                  .,dcc$$$$$$$$$$$$$$$$$$$$$$                    \n!!!!!!!!!               .d$$$$$$$$$$$$$$$$$$$$$$$$$$$$                    \n!!!!!!!!!             ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$          .         \n!!!!!!!!!           ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$         !!         \n!!!!!!!!!         ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$        ,!'         \n!!!!!!!!>        c$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$.       !'          \n!!!!!!''       ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$>       '           \n!!!''         d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$>                   \n!'           ,$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$>             ..    \n            d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$'           ;!!!!''`\n            $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$       ,;;!'`'  .'' \n           <$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$>    ,;'`'  ,;       \n           `$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$   -'   ,;!!'        \n            \"?$$$$$$$$$$?$$$$$$$$$$$$$$$$$$$$$$$$$$$     .<!!!'''       <!\n         !>    \"\"??$$$?<?$$$$$$$$$$$$$$$$$$$$$$$$\"\"     ;!'''          !!!\n       ;!!!!;,      `\"''\"\"????$$$$$$$$$$$$$$$$\"\"   ,;-''               ',!\n      ;!!!!<!!!; .                `\"\"\"\"\"\"\"\"\"\"\"    `'                  ' ' \n      !!!! ;!!! ;!!!!>;,;, ..                  ' .                   '  ' \n     !!' ,;!!! ;'`!!!!!!!!;!!!!!;  .        >' .''                 ;      \n    !!' ;!!'!';! !! !!!!!!!!!!!!!  '         -'                           \n   <!!  !! `!;! `!' !!!!!!!!!!<!       .                                  \n   `!  ;!  ;!!! <' <!!!! `!!! <       !                                   \n  `;   !>  <!! ;'  !!!!'  !!';!     ;'                                    \n   !   !   !!! !   `!!!  ;!! !      '  '                                  \n  ;   `!  `!! ,'    !'   ;!'                                              \n      '   !`! !    <     !! <      '                                      \n           ! ;!        >;! ;>                                             \n             !'       ; !! '                                              \n          ' ;!        > ! '                                               \n            '                                                             "
            got: "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!>'''!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!'''       `!!!!!!!!!!!!\n!!!!!!!!!!!!'`     ..     '!!!!!!!!!!\n!!!!!!!!!!'`      ;;;      `!!!!!!!!!\n!!!!!!!!!'        ;;'        !!!!!!!!\n!!!!!!!!'   ;     ``          !!!!!!!\n!!!!!!!!    .!!!!!,            !!!!!!\n!!!!!!!   .!!!!!!!!!           `!!!!!\n!!!!!!!  ,!!!!!!!!!!!           !!!!!\n!!!!!!   !!!!!!!!!!!!;          `!!!!\n!!!!!!  <!!!!!!!!!!!!!.          !!!!\n!!!!!   !!!!!!!!!!!!!!;.         !!!!\n!!!!!'  !!!!!!!!!!!!!!!;          !!!\n!!!!'   !!!!!!!!!!!!!!!!          !!!\n!!!!'   !!!!!!!!!!!!!!!!          !!!\n!!!!    !!!!!!!!! !!!!!           !!!\n!!!     `!.. !!!  ,!              !!!\n!!!     .    !!  ,!   .!!         !!!\n!!!!    < !!<!!  !!!!!!!!         !!!\n!!!     !!!!!!!  !!!!!!!!         `!!\n!!!     !!!!!!!!!!!!!!!!!         `!!\n!!      !!!!!!!!!!!!!!!!'          !!\n!!      !!!!!!!!!!!!!!!!           !!\n!!      !!!!!!!!!!!!!!!>           !!\n!!      `!!!>!!  !!!!!>'           !!\n!!.      <!!!!  ,!!!!!>'           `!\n!!!      <!!!!!!!! !!!>'           `!\n!!!       !!!!!!!!!!!!>             !\n!!        !!!!!! `!!!>'             !\n!!         !!!!!!!!!>>'             !\n!!>         !!!!!!!>>'              `\n!!           !!!!!!''                \n!!>           !!!                    \n!!!;           .                     \n!!!            !.                    \n!!!!            !,                   \n!!!!>           !!.       ,          \n!!!!            !!!!!!.,!!!          \n!!!!          ,!!!!!!!!!!!!          \n!!!!        .!!!!!!!!!!!!!!          \n!!!!       ,!!!!!!!!!!!!!!!     .    \n!!!!      ,!!!!!!!!!!!!!!!!          \n!!!!     ,!!!!!!!!!!!!!!!!!    ,'    \n!!!!>    !!!!!!!!!!!!!!!!!!.   '     \n!!!'    !!!!!!!!!!!!!!!!!!!>   '     \n!''    !!!!!!!!!!!!!!!!!!!!>         \n'      !!!!!!!!!!!!!!!!!!!!>      .  \n      !!!!!!!!!!!!!!!!!!!!!'     ;!''\n      !!!!!!!!!!!!!!!!!!!!!    ;'` .'\n      !!!!!!!!!!!!!!!!!!!!!  ,'' ;   \n      !!!!!!!!!!!!!!!!!!!!! !  ;'    \n      !!!!!!!!!!!!!!!!!!!!   <!''   <\n     >  !!!!!!!!!!!!!!!!!!  ;''     !\n    !!;   `'!!!!!!!!!!!!  ;'        ,\n   ;!<!;         `!!!!!  `         ''\n   !! ! ;!>;; .                     '\n   ' ;! '!!!!;!!;     > '            \n  !';'';  !!!!!!       '             \n  ! ! ; `'!!!!!<                     \n      ! < !! ! <                     \n `  > ! ' !' !'   ;                  \n      !   !  !    '                  \n ; ` ` ,  '  '                       \n   ' `        <                      \n            ; >                      \n       '   ;!                        \n     ';    > '                       \n      '                              "
       
       (compared using ==)
       
       Diff:
       @@ -1,71 +1,71 @@
       -!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
       -!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
       -!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!>''''''<!!!!!!!!!!!!!!!!!!!!!!!!!!!!
       -!!!!!!!!!!!!!!!!!!!!!!!!!!!!'''''`             ``'!!!!!!!!!!!!!!!!!!!!!!!!
       -!!!!!!!!!!!!!!!!!!!!!!!!''`          .....         `'!!!!!!!!!!!!!!!!!!!!!
       -!!!!!!!!!!!!!!!!!!!!!'`      .      ;;;;;'            `'!!!!!!!!!!!!!!!!!!
       -!!!!!!!!!!!!!!!!!!!'     .   '     .;;;;'                `!!!!!!!!!!!!!!!!
       -!!!!!!!!!!!!!!!!!'      ;          `````                   `!!!!!!!!!!!!!!
       -!!!!!!!!!!!!!!!!        .,ccdcccccc,,.                       `!!!!!!!!!!!!
       -!!!!!!!!!!!!!!!     .-"?$$$$$$$$$$$$$$c,                      `!!!!!!!!!!!
       -!!!!!!!!!!!!!!    ,ccc$$$$$$$$$$$$$$$$$$$,                     `!!!!!!!!!!
       -!!!!!!!!!!!!!    d$$$$$$$$$$$$$$$$$$$$$$$$;.                    `!!!!!!!!!
       -!!!!!!!!!!!!    <$$$$$$$$$$$$$$$$$$$$$$$$$$;.                    `!!!!!!!!
       -!!!!!!!!!!!     $$$$$$$$$$$$$$$$$$$$$$$$$$$d;;.                   !!!!!!!!
       -!!!!!!!!!!'     $$$$$$$$$$$$$$$$$$$$$$$$$$$$$d;.                   !!!!!!!
       -!!!!!!!!!'     <$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$                   !!!!!!!
       -!!!!!!!!'      `$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$                   `!!!!!!
       -!!!!!!!!        c$$$$???$$$$$$$d""  """??????"                      !!!!!!
       -!!!!!!!         `"" .,.. "$$$$$    .,dcd                            !!!!!!
       -!!!!!!!         .  d!    .?$$$   .,cc,      .,d$d.                  !!!!!!
       -!!!!!!!!        <. $$c- <$d$$$   <$$$$---$"$$$$$$$                  !!!!!!
       -!!!!!!!         d$$$dcccd$$$$$   d$$$dcccd$$$$$$$$                  `!!!!!
       -!!!!!!         ,$$$$$$$$$$$$$$d d$$$$$$$$$$$$$$$$                   `!!!!!
       -!!!!!          `$$$$$$$$$$$$$$$<$$$$$$$$$$$$$$$$'                    !!!!!
       -!!!!!          `$$$$$$$$$$$$$$$$"$$$$$$$$$$$$$d>                     !!!!!
       -!!!!!           ?$$$$$$$$$$$$??$c`$$$$$$$$$$$?>'                     `!!!!
       -!!!!!           `?$$$$$$!>?""    ,$$$$$$$$$?>>'                       !!!!
       -!!!!!.           <<?$$$$$$c.    ,d$$?$$$$$$>>''                       `!!!
       -!!!!!!            <!?$d"??$$d--"?""  ,$$$$d;>''                       `!!!
       -!!!!!!             $$$dccccccccc- cc$$$$$$$>>'                         !!!
       -!!!!!              `?$$$$$$$""""  `"$$$$$>>>''                         `!!
       -!!!!!                "?$$$$$cccccc$$$$??>>>>'                           !!
       -!!!!>                  "$$$$$$$$$$$$$$>>>>''                            `!
       -!!!!!                    "$$$$$$$$???>'''                                !
       -!!!!!>                     `"""""                                        `
       -!!!!!!;                       .                                          `
       -!!!!!!!                       ?d.                                         
       -!!!!!!!!                       $$c,                                       
       -!!!!!!!!>                      ?$$$d.              .,c                    
       -!!!!!!!!!                       $$$$$$$$$dc,.,,cc$$$$$                    
       -!!!!!!!!!                  .,dcc$$$$$$$$$$$$$$$$$$$$$$                    
       -!!!!!!!!!               .d$$$$$$$$$$$$$$$$$$$$$$$$$$$$                    
       -!!!!!!!!!             ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$          .         
       -!!!!!!!!!           ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$         !!         
       -!!!!!!!!!         ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$        ,!'         
       -!!!!!!!!>        c$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$.       !'          
       -!!!!!!''       ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$>       '           
       -!!!''         d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$>                   
       -!'           ,$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$>             ..    
       -            d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$'           ;!!!!''`
       -            $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$       ,;;!'`'  .'' 
       -           <$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$>    ,;'`'  ,;       
       -           `$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$   -'   ,;!!'        
       -            "?$$$$$$$$$$?$$$$$$$$$$$$$$$$$$$$$$$$$$$     .<!!!'''       <!
       -         !>    ""??$$$?<?$$$$$$$$$$$$$$$$$$$$$$$$""     ;!'''          !!!
       -       ;!!!!;,      `"''""????$$$$$$$$$$$$$$$$""   ,;-''               ',!
       -      ;!!!!<!!!; .                `"""""""""""    `'                  ' ' 
       -      !!!! ;!!! ;!!!!>;,;, ..                  ' .                   '  ' 
       -     !!' ,;!!! ;'`!!!!!!!!;!!!!!;  .        >' .''                 ;      
       -    !!' ;!!'!';! !! !!!!!!!!!!!!!  '         -'                           
       -   <!!  !! `!;! `!' !!!!!!!!!!<!       .                                  
       -   `!  ;!  ;!!! <' <!!!! `!!! <       !                                   
       -  `;   !>  <!! ;'  !!!!'  !!';!     ;'                                    
       -   !   !   !!! !   `!!!  ;!! !      '  '                                  
       -  ;   `!  `!! ,'    !'   ;!'                                              
       -      '   !`! !    <     !! <      '                                      
       -           ! ;!        >;! ;>                                             
       -             !'       ; !! '                                              
       -          ' ;!        > ! '                                               
       -            '                                                             
       +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
       +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
       +!!!!!!!!!!!!!!!!!!!>'''!!!!!!!!!!!!!!
       +!!!!!!!!!!!!!!'''       `!!!!!!!!!!!!
       +!!!!!!!!!!!!'`     ..     '!!!!!!!!!!
       +!!!!!!!!!!'`      ;;;      `!!!!!!!!!
       +!!!!!!!!!'        ;;'        !!!!!!!!
       +!!!!!!!!'   ;     ``          !!!!!!!
       +!!!!!!!!    .!!!!!,            !!!!!!
       +!!!!!!!   .!!!!!!!!!           `!!!!!
       +!!!!!!!  ,!!!!!!!!!!!           !!!!!
       +!!!!!!   !!!!!!!!!!!!;          `!!!!
       +!!!!!!  <!!!!!!!!!!!!!.          !!!!
       +!!!!!   !!!!!!!!!!!!!!;.         !!!!
       +!!!!!'  !!!!!!!!!!!!!!!;          !!!
       +!!!!'   !!!!!!!!!!!!!!!!          !!!
       +!!!!'   !!!!!!!!!!!!!!!!          !!!
       +!!!!    !!!!!!!!! !!!!!           !!!
       +!!!     `!.. !!!  ,!              !!!
       +!!!     .    !!  ,!   .!!         !!!
       +!!!!    < !!<!!  !!!!!!!!         !!!
       +!!!     !!!!!!!  !!!!!!!!         `!!
       +!!!     !!!!!!!!!!!!!!!!!         `!!
       +!!      !!!!!!!!!!!!!!!!'          !!
       +!!      !!!!!!!!!!!!!!!!           !!
       +!!      !!!!!!!!!!!!!!!>           !!
       +!!      `!!!>!!  !!!!!>'           !!
       +!!.      <!!!!  ,!!!!!>'           `!
       +!!!      <!!!!!!!! !!!>'           `!
       +!!!       !!!!!!!!!!!!>             !
       +!!        !!!!!! `!!!>'             !
       +!!         !!!!!!!!!>>'             !
       +!!>         !!!!!!!>>'              `
       +!!           !!!!!!''                
       +!!>           !!!                    
       +!!!;           .                     
       +!!!            !.                    
       +!!!!            !,                   
       +!!!!>           !!.       ,          
       +!!!!            !!!!!!.,!!!          
       +!!!!          ,!!!!!!!!!!!!          
       +!!!!        .!!!!!!!!!!!!!!          
       +!!!!       ,!!!!!!!!!!!!!!!     .    
       +!!!!      ,!!!!!!!!!!!!!!!!          
       +!!!!     ,!!!!!!!!!!!!!!!!!    ,'    
       +!!!!>    !!!!!!!!!!!!!!!!!!.   '     
       +!!!'    !!!!!!!!!!!!!!!!!!!>   '     
       +!''    !!!!!!!!!!!!!!!!!!!!>         
       +'      !!!!!!!!!!!!!!!!!!!!>      .  
       +      !!!!!!!!!!!!!!!!!!!!!'     ;!''
       +      !!!!!!!!!!!!!!!!!!!!!    ;'` .'
       +      !!!!!!!!!!!!!!!!!!!!!  ,'' ;   
       +      !!!!!!!!!!!!!!!!!!!!! !  ;'    
       +      !!!!!!!!!!!!!!!!!!!!   <!''   <
       +     >  !!!!!!!!!!!!!!!!!!  ;''     !
       +    !!;   `'!!!!!!!!!!!!  ;'        ,
       +   ;!<!;         `!!!!!  `         ''
       +   !! ! ;!>;; .                     '
       +   ' ;! '!!!!;!!;     > '            
       +  !';'';  !!!!!!       '             
       +  ! ! ; `'!!!!!<                     
       +      ! < !! ! <                     
       + `  > ! ' !' !'   ;                  
       +      !   !  !    '                  
       + ; ` ` ,  '  '                       
       +   ' `        <                      
       +            ; >                      
       +       '   ;!                        
       +     ';    > '                       
       +      '                              
     # /tmp/d20131110-20795-x53orj/spec.rb:105:in `block (2 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

Finished in 0.03379 seconds
5 examples, 1 failure

Failed examples:

rspec /tmp/d20131110-20795-x53orj/spec.rb:31 # Bitmap renders La Gioconda
Росен Рачев
  • Некоректно
  • 3 успешни тест(а)
  • 2 неуспешни тест(а)
Росен Рачев
class Bitmap
attr_accessor :bytes, :per_row
def initialize(list, per_row = list.length)
@bytes = []
@per_row = per_row
list.each { |byte| @bytes << byte.to_s(2).rjust(8, '0') }
end
def render(palette = ['.', '#'])
image = []
range = {2 => 1, 4 => 2, 16 => 4}
@bytes.each_with_index do |byte, index|
byte.split("").each_slice(range[palette.length]).map { |slice| byte = byte.gsub(slice.join, palette[slice.join.to_i(2)]) }
image << byte
end
1.upto(image.length / @per_row - 1).each { |row| image.insert @per_row * row, "\n" if (@per_row < @bytes.length) }
image.join
end
end
..F.F

Failures:

  1) Bitmap can render a column
     Failure/Error: expect(Bitmap.new([9, 32, 7, 1], 1).render).to eq <<-ASCII.strip
       
       expected: "....#..#\n..#.....\n.....###\n.......#"
            got: "....#..#\n\n\n..#..........###.......#"
       
       (compared using ==)
       
       Diff:
       @@ -1,5 +1,5 @@
        ....#..#
       -..#.....
       -.....###
       -.......#
       +
       +
       +..#..........###.......#
     # /tmp/d20131110-20795-zmyul3/spec.rb:16:in `block (2 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  2) Bitmap renders La Gioconda
     Failure/Error: Bitmap.new(the_bitmap, 37).render(["!", "\n", ">", "'", "<", "`", " ", ".", ";", ",", "c", "d", "-", "\"", "?", "$"]).should eq expectation
       
       expected: "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!>''''''<!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!'''''`             ``'!!!!!!!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!!!!!!''`          .....         `'!!!!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!!!'`      .      ;;;;;'            `'!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!'     .   '     .;;;;'                `!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!'      ;          `````                   `!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!        .,ccdcccccc,,.                       `!!!!!!!!!!!!\n!!!!!!!!!!!!!!!     .-\"?$$$$$$$$$$$$$$c,                      `!!!!!!!!!!!\n!!!!!!!!!!!!!!    ,ccc$$$$$$$$$$$$$$$$$$$,                     `!!!!!!!!!!\n!!!!!!!!!!!!!    d$$$$$$$$$$$$$$$$$$$$$$$$;.                    `!!!!!!!!!\n!!!!!!!!!!!!    <$$$$$$$$$$$$$$$$$$$$$$$$$$;.                    `!!!!!!!!\n!!!!!!!!!!!     $$$$$$$$$$$$$$$$$$$$$$$$$$$d;;.                   !!!!!!!!\n!!!!!!!!!!'     $$$$$$$$$$$$$$$$$$$$$$$$$$$$$d;.                   !!!!!!!\n!!!!!!!!!'     <$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$                   !!!!!!!\n!!!!!!!!'      `$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$                   `!!!!!!\n!!!!!!!!        c$$$$???$$$$$$$d\"\"  \"\"\"??????\"                      !!!!!!\n!!!!!!!         `\"\" .,.. \"$$$$$    .,dcd                            !!!!!!\n!!!!!!!         .  d!    .?$$$   .,cc,      .,d$d.                  !!!!!!\n!!!!!!!!        <. $$c- <$d$$$   <$$$$---$\"$$$$$$$                  !!!!!!\n!!!!!!!         d$$$dcccd$$$$$   d$$$dcccd$$$$$$$$                  `!!!!!\n!!!!!!         ,$$$$$$$$$$$$$$d d$$$$$$$$$$$$$$$$                   `!!!!!\n!!!!!          `$$$$$$$$$$$$$$$<$$$$$$$$$$$$$$$$'                    !!!!!\n!!!!!          `$$$$$$$$$$$$$$$$\"$$$$$$$$$$$$$d>                     !!!!!\n!!!!!           ?$$$$$$$$$$$$??$c`$$$$$$$$$$$?>'                     `!!!!\n!!!!!           `?$$$$$$!>?\"\"    ,$$$$$$$$$?>>'                       !!!!\n!!!!!.           <<?$$$$$$c.    ,d$$?$$$$$$>>''                       `!!!\n!!!!!!            <!?$d\"??$$d--\"?\"\"  ,$$$$d;>''                       `!!!\n!!!!!!             $$$dccccccccc- cc$$$$$$$>>'                         !!!\n!!!!!              `?$$$$$$$\"\"\"\"  `\"$$$$$>>>''                         `!!\n!!!!!                \"?$$$$$cccccc$$$$??>>>>'                           !!\n!!!!>                  \"$$$$$$$$$$$$$$>>>>''                            `!\n!!!!!                    \"$$$$$$$$???>'''                                !\n!!!!!>                     `\"\"\"\"\"                                        `\n!!!!!!;                       .                                          `\n!!!!!!!                       ?d.                                         \n!!!!!!!!                       $$c,                                       \n!!!!!!!!>                      ?$$$d.              .,c                    \n!!!!!!!!!                       $$$$$$$$$dc,.,,cc$$$$$                    \n!!!!!!!!!                  .,dcc$$$$$$$$$$$$$$$$$$$$$$                    \n!!!!!!!!!               .d$$$$$$$$$$$$$$$$$$$$$$$$$$$$                    \n!!!!!!!!!             ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$          .         \n!!!!!!!!!           ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$         !!         \n!!!!!!!!!         ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$        ,!'         \n!!!!!!!!>        c$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$.       !'          \n!!!!!!''       ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$>       '           \n!!!''         d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$>                   \n!'           ,$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$>             ..    \n            d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$'           ;!!!!''`\n            $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$       ,;;!'`'  .'' \n           <$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$>    ,;'`'  ,;       \n           `$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$   -'   ,;!!'        \n            \"?$$$$$$$$$$?$$$$$$$$$$$$$$$$$$$$$$$$$$$     .<!!!'''       <!\n         !>    \"\"??$$$?<?$$$$$$$$$$$$$$$$$$$$$$$$\"\"     ;!'''          !!!\n       ;!!!!;,      `\"''\"\"????$$$$$$$$$$$$$$$$\"\"   ,;-''               ',!\n      ;!!!!<!!!; .                `\"\"\"\"\"\"\"\"\"\"\"    `'                  ' ' \n      !!!! ;!!! ;!!!!>;,;, ..                  ' .                   '  ' \n     !!' ,;!!! ;'`!!!!!!!!;!!!!!;  .        >' .''                 ;      \n    !!' ;!!'!';! !! !!!!!!!!!!!!!  '         -'                           \n   <!!  !! `!;! `!' !!!!!!!!!!<!       .                                  \n   `!  ;!  ;!!! <' <!!!! `!!! <       !                                   \n  `;   !>  <!! ;'  !!!!'  !!';!     ;'                                    \n   !   !   !!! !   `!!!  ;!! !      '  '                                  \n  ;   `!  `!! ,'    !'   ;!'                                              \n      '   !`! !    <     !! <      '                                      \n           ! ;!        >;! ;>                                             \n             !'       ; !! '                                              \n          ' ;!        > ! '                                               \n            '                                                             "
            got: "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!>''''''<!!!!!!!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'''''`             ``'!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!''`          .....         `'!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'`      .      ;;;;;'            `'!!!!!!!!\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'     .   '     .;;;;'                `!!!!\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'      ;          `````                   `\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!        .,ccdcccccc,,.                    \n   `!!!!!!!!!!!!!!!!!!!!!!!!!!!     .-\"?$$$$$$$$$$$$$$c,                \n      `!!!!!!!!!!!!!!!!!!!!!!!!!    ,ccc$$$$$$$$$$$$$$$$$$$,            \n         `!!!!!!!!!!!!!!!!!!!!!!!    d$$$$$$$$$$$$$$$$$$$$$$$$;.        \n            `!!!!!!!!!!!!!!!!!!!!!    <$$$$$$$$$$$$$$$$$$$$$$$$$$;.     \n               `!!!!!!!!!!!!!!!!!!!     $$$$$$$$$$$$$$$$$$$$$$$$$$$d;;. \n                  !!!!!!!!!!!!!!!!!!'     $$$$$$$$$$$$$$$$$$$$$$$$$$$$$d\n;.                   !!!!!!!!!!!!!!!!'     <$$$$$$$$$$$$$$$$$$$$$$$$$$$$\n$$$$                   !!!!!!!!!!!!!!!'      `$$$$$$$$$$$$$$$$$$$$$$$$$$\n$$$$$$                   `!!!!!!!!!!!!!!        c$$$$???$$$$$$$d\"\"  \"\"\"?\n?????\"                      !!!!!!!!!!!!!         `\"\" .,.. \"$$$$$    .,d\ncd                            !!!!!!!!!!!!!         .  d!    .?$$$   .,c\nc,      .,d$d.                  !!!!!!!!!!!!!!        <. $$c- <$d$$$   <\n$$$$---$\"$$$$$$$                  !!!!!!!!!!!!!         d$$$dcccd$$$$$  \n d$$$dcccd$$$$$$$$                  `!!!!!!!!!!!         ,$$$$$$$$$$$$$$\nd d$$$$$$$$$$$$$$$$                   `!!!!!!!!!!          `$$$$$$$$$$$$\n$$$<$$$$$$$$$$$$$$$$'                    !!!!!!!!!!          `$$$$$$$$$$\n$$$$$$\"$$$$$$$$$$$$$d>                     !!!!!!!!!!           ?$$$$$$$\n$$$$$??$c`$$$$$$$$$$$?>'                     `!!!!!!!!!           `?$$$$\n$$!>?\"\"    ,$$$$$$$$$?>>'                       !!!!!!!!!.           <<?\n$$$$$$c.    ,d$$?$$$$$$>>''                       `!!!!!!!!!            \n<!?$d\"??$$d--\"?\"\"  ,$$$$d;>''                       `!!!!!!!!!          \n   $$$dccccccccc- cc$$$$$$$>>'                         !!!!!!!!         \n     `?$$$$$$$\"\"\"\"  `\"$$$$$>>>''                         `!!!!!!!       \n         \"?$$$$$cccccc$$$$??>>>>'                           !!!!!!>     \n             \"$$$$$$$$$$$$$$>>>>''                            `!!!!!!   \n                 \"$$$$$$$$???>'''                                !!!!!!>\n                     `\"\"\"\"\"                                        `!!!!\n!!;                       .                                          `!!\n!!!!!                       ?d.                                         \n!!!!!!!!                       $$c,                                     \n  !!!!!!!!>                      ?$$$d.              .,c                \n    !!!!!!!!!                       $$$$$$$$$dc,.,,cc$$$$$              \n      !!!!!!!!!                  .,dcc$$$$$$$$$$$$$$$$$$$$$$            \n        !!!!!!!!!               .d$$$$$$$$$$$$$$$$$$$$$$$$$$$$          \n          !!!!!!!!!             ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$        \n  .         !!!!!!!!!           ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$      \n   !!         !!!!!!!!!         ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$    \n    ,!'         !!!!!!!!>        c$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$. \n      !'          !!!!!!''       ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$\n>       '           !!!''         d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$\n$$>                   !'           ,$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$\n$$$$>             ..                d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$\n$$$$$$'           ;!!!!''`            $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$\n$$$$$$$$       ,;;!'`'  .''            <$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$\n$$$$$$$$$>    ,;'`'  ,;                  `$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$\n$$$$$$$$$$$   -'   ,;!!'                    \"?$$$$$$$$$$?$$$$$$$$$$$$$$$\n$$$$$$$$$$$$     .<!!!'''       <!         !>    \"\"??$$$?<?$$$$$$$$$$$$$\n$$$$$$$$$$$\"\"     ;!'''          !!!       ;!!!!;,      `\"''\"\"????$$$$$$\n$$$$$$$$$$\"\"   ,;-''               ',!      ;!!!!<!!!; .                \n`\"\"\"\"\"\"\"\"\"\"\"    `'                  ' '       !!!! ;!!! ;!!!!>;,;, ..   \n               ' .                   '  '      !!' ,;!!! ;'`!!!!!!!!;!!!\n!!;  .        >' .''                 ;          !!' ;!!'!';! !! !!!!!!!!\n!!!!!  '         -'                              <!!  !! `!;! `!' !!!!!!\n!!!!<!       .                                     `!  ;!  ;!!! <' <!!!!\n `!!! <       !                                     `;   !>  <!! ;'  !!!\n!'  !!';!     ;'                                       !   !   !!! !   `\n!!!  ;!! !      '  '                                    ;   `!  `!! ,'  \n  !'   ;!'                                                    '   !`! ! \n   <     !! <      '                                                 ! ;\n!        >;! ;>                                                         \n !'       ; !! '                                                        ' ;!        > ! '                                                           '                                                             "
       
       (compared using ==)
       
       Diff:
       @@ -1,71 +1,71 @@
        !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
       -!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
       -!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!>''''''<!!!!!!!!!!!!!!!!!!!!!!!!!!!!
       -!!!!!!!!!!!!!!!!!!!!!!!!!!!!'''''`             ``'!!!!!!!!!!!!!!!!!!!!!!!!
       -!!!!!!!!!!!!!!!!!!!!!!!!''`          .....         `'!!!!!!!!!!!!!!!!!!!!!
       -!!!!!!!!!!!!!!!!!!!!!'`      .      ;;;;;'            `'!!!!!!!!!!!!!!!!!!
       -!!!!!!!!!!!!!!!!!!!'     .   '     .;;;;'                `!!!!!!!!!!!!!!!!
       -!!!!!!!!!!!!!!!!!'      ;          `````                   `!!!!!!!!!!!!!!
       -!!!!!!!!!!!!!!!!        .,ccdcccccc,,.                       `!!!!!!!!!!!!
       -!!!!!!!!!!!!!!!     .-"?$$$$$$$$$$$$$$c,                      `!!!!!!!!!!!
       -!!!!!!!!!!!!!!    ,ccc$$$$$$$$$$$$$$$$$$$,                     `!!!!!!!!!!
       -!!!!!!!!!!!!!    d$$$$$$$$$$$$$$$$$$$$$$$$;.                    `!!!!!!!!!
       -!!!!!!!!!!!!    <$$$$$$$$$$$$$$$$$$$$$$$$$$;.                    `!!!!!!!!
       -!!!!!!!!!!!     $$$$$$$$$$$$$$$$$$$$$$$$$$$d;;.                   !!!!!!!!
       -!!!!!!!!!!'     $$$$$$$$$$$$$$$$$$$$$$$$$$$$$d;.                   !!!!!!!
       -!!!!!!!!!'     <$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$                   !!!!!!!
       -!!!!!!!!'      `$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$                   `!!!!!!
       -!!!!!!!!        c$$$$???$$$$$$$d""  """??????"                      !!!!!!
       -!!!!!!!         `"" .,.. "$$$$$    .,dcd                            !!!!!!
       -!!!!!!!         .  d!    .?$$$   .,cc,      .,d$d.                  !!!!!!
       -!!!!!!!!        <. $$c- <$d$$$   <$$$$---$"$$$$$$$                  !!!!!!
       -!!!!!!!         d$$$dcccd$$$$$   d$$$dcccd$$$$$$$$                  `!!!!!
       -!!!!!!         ,$$$$$$$$$$$$$$d d$$$$$$$$$$$$$$$$                   `!!!!!
       -!!!!!          `$$$$$$$$$$$$$$$<$$$$$$$$$$$$$$$$'                    !!!!!
       -!!!!!          `$$$$$$$$$$$$$$$$"$$$$$$$$$$$$$d>                     !!!!!
       -!!!!!           ?$$$$$$$$$$$$??$c`$$$$$$$$$$$?>'                     `!!!!
       -!!!!!           `?$$$$$$!>?""    ,$$$$$$$$$?>>'                       !!!!
       -!!!!!.           <<?$$$$$$c.    ,d$$?$$$$$$>>''                       `!!!
       -!!!!!!            <!?$d"??$$d--"?""  ,$$$$d;>''                       `!!!
       -!!!!!!             $$$dccccccccc- cc$$$$$$$>>'                         !!!
       -!!!!!              `?$$$$$$$""""  `"$$$$$>>>''                         `!!
       -!!!!!                "?$$$$$cccccc$$$$??>>>>'                           !!
       -!!!!>                  "$$$$$$$$$$$$$$>>>>''                            `!
       -!!!!!                    "$$$$$$$$???>'''                                !
       -!!!!!>                     `"""""                                        `
       -!!!!!!;                       .                                          `
       -!!!!!!!                       ?d.                                         
       -!!!!!!!!                       $$c,                                       
       -!!!!!!!!>                      ?$$$d.              .,c                    
       -!!!!!!!!!                       $$$$$$$$$dc,.,,cc$$$$$                    
       -!!!!!!!!!                  .,dcc$$$$$$$$$$$$$$$$$$$$$$                    
       -!!!!!!!!!               .d$$$$$$$$$$$$$$$$$$$$$$$$$$$$                    
       -!!!!!!!!!             ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$          .         
       -!!!!!!!!!           ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$         !!         
       -!!!!!!!!!         ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$        ,!'         
       -!!!!!!!!>        c$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$.       !'          
       -!!!!!!''       ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$>       '           
       -!!!''         d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$>                   
       -!'           ,$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$>             ..    
       -            d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$'           ;!!!!''`
       -            $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$       ,;;!'`'  .'' 
       -           <$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$>    ,;'`'  ,;       
       -           `$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$   -'   ,;!!'        
       -            "?$$$$$$$$$$?$$$$$$$$$$$$$$$$$$$$$$$$$$$     .<!!!'''       <!
       -         !>    ""??$$$?<?$$$$$$$$$$$$$$$$$$$$$$$$""     ;!'''          !!!
       -       ;!!!!;,      `"''""????$$$$$$$$$$$$$$$$""   ,;-''               ',!
       -      ;!!!!<!!!; .                `"""""""""""    `'                  ' ' 
       -      !!!! ;!!! ;!!!!>;,;, ..                  ' .                   '  ' 
       -     !!' ,;!!! ;'`!!!!!!!!;!!!!!;  .        >' .''                 ;      
       -    !!' ;!!'!';! !! !!!!!!!!!!!!!  '         -'                           
       -   <!!  !! `!;! `!' !!!!!!!!!!<!       .                                  
       -   `!  ;!  ;!!! <' <!!!! `!!! <       !                                   
       -  `;   !>  <!! ;'  !!!!'  !!';!     ;'                                    
       -   !   !   !!! !   `!!!  ;!! !      '  '                                  
       -  ;   `!  `!! ,'    !'   ;!'                                              
       -      '   !`! !    <     !! <      '                                      
       -           ! ;!        >;! ;>                                             
       -             !'       ; !! '                                              
       -          ' ;!        > ! '                                               
       -            '                                                             
       +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
       +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!>''''''<!!!!!!!!!!!!!!!!!!!!!!!!
       +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'''''`             ``'!!!!!!!!!!!!!!!!!!
       +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!''`          .....         `'!!!!!!!!!!!!!
       +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'`      .      ;;;;;'            `'!!!!!!!!
       +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'     .   '     .;;;;'                `!!!!
       +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'      ;          `````                   `
       +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!        .,ccdcccccc,,.                    
       +   `!!!!!!!!!!!!!!!!!!!!!!!!!!!     .-"?$$$$$$$$$$$$$$c,                
       +      `!!!!!!!!!!!!!!!!!!!!!!!!!    ,ccc$$$$$$$$$$$$$$$$$$$,            
       +         `!!!!!!!!!!!!!!!!!!!!!!!    d$$$$$$$$$$$$$$$$$$$$$$$$;.        
       +            `!!!!!!!!!!!!!!!!!!!!!    <$$$$$$$$$$$$$$$$$$$$$$$$$$;.     
       +               `!!!!!!!!!!!!!!!!!!!     $$$$$$$$$$$$$$$$$$$$$$$$$$$d;;. 
       +                  !!!!!!!!!!!!!!!!!!'     $$$$$$$$$$$$$$$$$$$$$$$$$$$$$d
       +;.                   !!!!!!!!!!!!!!!!'     <$$$$$$$$$$$$$$$$$$$$$$$$$$$$
       +$$$$                   !!!!!!!!!!!!!!!'      `$$$$$$$$$$$$$$$$$$$$$$$$$$
       +$$$$$$                   `!!!!!!!!!!!!!!        c$$$$???$$$$$$$d""  """?
       +?????"                      !!!!!!!!!!!!!         `"" .,.. "$$$$$    .,d
       +cd                            !!!!!!!!!!!!!         .  d!    .?$$$   .,c
       +c,      .,d$d.                  !!!!!!!!!!!!!!        <. $$c- <$d$$$   <
       +$$$$---$"$$$$$$$                  !!!!!!!!!!!!!         d$$$dcccd$$$$$  
       + d$$$dcccd$$$$$$$$                  `!!!!!!!!!!!         ,$$$$$$$$$$$$$$
       +d d$$$$$$$$$$$$$$$$                   `!!!!!!!!!!          `$$$$$$$$$$$$
       +$$$<$$$$$$$$$$$$$$$$'                    !!!!!!!!!!          `$$$$$$$$$$
       +$$$$$$"$$$$$$$$$$$$$d>                     !!!!!!!!!!           ?$$$$$$$
       +$$$$$??$c`$$$$$$$$$$$?>'                     `!!!!!!!!!           `?$$$$
       +$$!>?""    ,$$$$$$$$$?>>'                       !!!!!!!!!.           <<?
       +$$$$$$c.    ,d$$?$$$$$$>>''                       `!!!!!!!!!            
       +<!?$d"??$$d--"?""  ,$$$$d;>''                       `!!!!!!!!!          
       +   $$$dccccccccc- cc$$$$$$$>>'                         !!!!!!!!         
       +     `?$$$$$$$""""  `"$$$$$>>>''                         `!!!!!!!       
       +         "?$$$$$cccccc$$$$??>>>>'                           !!!!!!>     
       +             "$$$$$$$$$$$$$$>>>>''                            `!!!!!!   
       +                 "$$$$$$$$???>'''                                !!!!!!>
       +                     `"""""                                        `!!!!
       +!!;                       .                                          `!!
       +!!!!!                       ?d.                                         
       +!!!!!!!!                       $$c,                                     
       +  !!!!!!!!>                      ?$$$d.              .,c                
       +    !!!!!!!!!                       $$$$$$$$$dc,.,,cc$$$$$              
       +      !!!!!!!!!                  .,dcc$$$$$$$$$$$$$$$$$$$$$$            
       +        !!!!!!!!!               .d$$$$$$$$$$$$$$$$$$$$$$$$$$$$          
       +          !!!!!!!!!             ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$        
       +  .         !!!!!!!!!           ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$      
       +   !!         !!!!!!!!!         ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$    
       +    ,!'         !!!!!!!!>        c$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$. 
       +      !'          !!!!!!''       ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
       +>       '           !!!''         d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
       +$$>                   !'           ,$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
       +$$$$>             ..                d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
       +$$$$$$'           ;!!!!''`            $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
       +$$$$$$$$       ,;;!'`'  .''            <$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
       +$$$$$$$$$>    ,;'`'  ,;                  `$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
       +$$$$$$$$$$$   -'   ,;!!'                    "?$$$$$$$$$$?$$$$$$$$$$$$$$$
       +$$$$$$$$$$$$     .<!!!'''       <!         !>    ""??$$$?<?$$$$$$$$$$$$$
       +$$$$$$$$$$$""     ;!'''          !!!       ;!!!!;,      `"''""????$$$$$$
       +$$$$$$$$$$""   ,;-''               ',!      ;!!!!<!!!; .                
       +`"""""""""""    `'                  ' '       !!!! ;!!! ;!!!!>;,;, ..   
       +               ' .                   '  '      !!' ,;!!! ;'`!!!!!!!!;!!!
       +!!;  .        >' .''                 ;          !!' ;!!'!';! !! !!!!!!!!
       +!!!!!  '         -'                              <!!  !! `!;! `!' !!!!!!
       +!!!!<!       .                                     `!  ;!  ;!!! <' <!!!!
       + `!!! <       !                                     `;   !>  <!! ;'  !!!
       +!'  !!';!     ;'                                       !   !   !!! !   `
       +!!!  ;!! !      '  '                                    ;   `!  `!! ,'  
       +  !'   ;!'                                                    '   !`! ! 
       +   <     !! <      '                                                 ! ;
       +!        >;! ;>                                                         
       + !'       ; !! '                                                        ' ;!        > ! '                                                           '                                                             
     # /tmp/d20131110-20795-zmyul3/spec.rb:105:in `block (2 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

Finished in 0.19006 seconds
5 examples, 2 failures

Failed examples:

rspec /tmp/d20131110-20795-zmyul3/spec.rb:15 # Bitmap can render a column
rspec /tmp/d20131110-20795-zmyul3/spec.rb:31 # Bitmap renders La Gioconda
Методи Димитров
  • Некоректно
  • 3 успешни тест(а)
  • 2 неуспешни тест(а)
Методи Димитров
class Bitmap
include Math
def initialize(image, bytes_per_row = image.size)
@image = image
@bytes_per_row = bytes_per_row
end
def encode_pixel_with_pattern(pixel, pattern)
(256 | pixel).to_s(pattern.size).chars[1..-1].map do |bit|
pattern[bit.to_i(pattern.size)]
end
end
def render(pattern = ['.', '#'])
rendered_image = @image.each_with_index.map do |pixel, index|
encoded_pixel = encode_pixel_with_pattern(pixel, pattern)
if index.pred % @bytes_per_row == 0 and index.next < @image.size
encoded_pixel += ["\n"]
end
encoded_pixel.reduce(:+)
end
rendered_image.reduce(:+)
end
end
F...F

Failures:

  1) Bitmap renders bytes
     Failure/Error: expect(Bitmap.new([9, 32, 7]).render).to eq <<-ASCII.strip
       
       expected: "....#..#..#..........###"
            got: "....#..#..#.....\n.....###"
       
       (compared using ==)
       
       Diff:
       @@ -1,2 +1,3 @@
       -....#..#..#..........###
       +....#..#..#.....
       +.....###
     # /tmp/d20131110-20795-139hv60/spec.rb:3:in `block (2 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  2) Bitmap renders La Gioconda
     Failure/Error: Bitmap.new(the_bitmap, 37).render(["!", "\n", ">", "'", "<", "`", " ", ".", ";", ",", "c", "d", "-", "\"", "?", "$"]).should eq expectation
       
       expected: "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!>''''''<!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!'''''`             ``'!!!!!!!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!!!!!!''`          .....         `'!!!!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!!!'`      .      ;;;;;'            `'!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!'     .   '     .;;;;'                `!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!'      ;          `````                   `!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!        .,ccdcccccc,,.                       `!!!!!!!!!!!!\n!!!!!!!!!!!!!!!     .-\"?$$$$$$$$$$$$$$c,                      `!!!!!!!!!!!\n!!!!!!!!!!!!!!    ,ccc$$$$$$$$$$$$$$$$$$$,                     `!!!!!!!!!!\n!!!!!!!!!!!!!    d$$$$$$$$$$$$$$$$$$$$$$$$;.                    `!!!!!!!!!\n!!!!!!!!!!!!    <$$$$$$$$$$$$$$$$$$$$$$$$$$;.                    `!!!!!!!!\n!!!!!!!!!!!     $$$$$$$$$$$$$$$$$$$$$$$$$$$d;;.                   !!!!!!!!\n!!!!!!!!!!'     $$$$$$$$$$$$$$$$$$$$$$$$$$$$$d;.                   !!!!!!!\n!!!!!!!!!'     <$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$                   !!!!!!!\n!!!!!!!!'      `$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$                   `!!!!!!\n!!!!!!!!        c$$$$???$$$$$$$d\"\"  \"\"\"??????\"                      !!!!!!\n!!!!!!!         `\"\" .,.. \"$$$$$    .,dcd                            !!!!!!\n!!!!!!!         .  d!    .?$$$   .,cc,      .,d$d.                  !!!!!!\n!!!!!!!!        <. $$c- <$d$$$   <$$$$---$\"$$$$$$$                  !!!!!!\n!!!!!!!         d$$$dcccd$$$$$   d$$$dcccd$$$$$$$$                  `!!!!!\n!!!!!!         ,$$$$$$$$$$$$$$d d$$$$$$$$$$$$$$$$                   `!!!!!\n!!!!!          `$$$$$$$$$$$$$$$<$$$$$$$$$$$$$$$$'                    !!!!!\n!!!!!          `$$$$$$$$$$$$$$$$\"$$$$$$$$$$$$$d>                     !!!!!\n!!!!!           ?$$$$$$$$$$$$??$c`$$$$$$$$$$$?>'                     `!!!!\n!!!!!           `?$$$$$$!>?\"\"    ,$$$$$$$$$?>>'                       !!!!\n!!!!!.           <<?$$$$$$c.    ,d$$?$$$$$$>>''                       `!!!\n!!!!!!            <!?$d\"??$$d--\"?\"\"  ,$$$$d;>''                       `!!!\n!!!!!!             $$$dccccccccc- cc$$$$$$$>>'                         !!!\n!!!!!              `?$$$$$$$\"\"\"\"  `\"$$$$$>>>''                         `!!\n!!!!!                \"?$$$$$cccccc$$$$??>>>>'                           !!\n!!!!>                  \"$$$$$$$$$$$$$$>>>>''                            `!\n!!!!!                    \"$$$$$$$$???>'''                                !\n!!!!!>                     `\"\"\"\"\"                                        `\n!!!!!!;                       .                                          `\n!!!!!!!                       ?d.                                         \n!!!!!!!!                       $$c,                                       \n!!!!!!!!>                      ?$$$d.              .,c                    \n!!!!!!!!!                       $$$$$$$$$dc,.,,cc$$$$$                    \n!!!!!!!!!                  .,dcc$$$$$$$$$$$$$$$$$$$$$$                    \n!!!!!!!!!               .d$$$$$$$$$$$$$$$$$$$$$$$$$$$$                    \n!!!!!!!!!             ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$          .         \n!!!!!!!!!           ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$         !!         \n!!!!!!!!!         ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$        ,!'         \n!!!!!!!!>        c$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$.       !'          \n!!!!!!''       ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$>       '           \n!!!''         d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$>                   \n!'           ,$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$>             ..    \n            d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$'           ;!!!!''`\n            $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$       ,;;!'`'  .'' \n           <$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$>    ,;'`'  ,;       \n           `$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$   -'   ,;!!'        \n            \"?$$$$$$$$$$?$$$$$$$$$$$$$$$$$$$$$$$$$$$     .<!!!'''       <!\n         !>    \"\"??$$$?<?$$$$$$$$$$$$$$$$$$$$$$$$\"\"     ;!'''          !!!\n       ;!!!!;,      `\"''\"\"????$$$$$$$$$$$$$$$$\"\"   ,;-''               ',!\n      ;!!!!<!!!; .                `\"\"\"\"\"\"\"\"\"\"\"    `'                  ' ' \n      !!!! ;!!! ;!!!!>;,;, ..                  ' .                   '  ' \n     !!' ,;!!! ;'`!!!!!!!!;!!!!!;  .        >' .''                 ;      \n    !!' ;!!'!';! !! !!!!!!!!!!!!!  '         -'                           \n   <!!  !! `!;! `!' !!!!!!!!!!<!       .                                  \n   `!  ;!  ;!!! <' <!!!! `!!! <       !                                   \n  `;   !>  <!! ;'  !!!!'  !!';!     ;'                                    \n   !   !   !!! !   `!!!  ;!! !      '  '                                  \n  ;   `!  `!! ,'    !'   ;!'                                              \n      '   !`! !    <     !! <      '                                      \n           ! ;!        >;! ;>                                             \n             !'       ; !! '                                              \n          ' ;!        > ! '                                               \n            '                                                             "
            got: "!!!!\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!>''''''<!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!!!!!!'''''`             ``'!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!!''`          .....         `'!!!!!!!!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!'`      .      ;;;;;'            `'!!!!!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!'     .   '     .;;;;'                `!!!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!'      ;          `````                   `!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!        .,ccdcccccc,,.                       `!!!!!!!!!!!!!!!!\n!!!!!!!!!!!     .-\"?$$$$$$$$$$$$$$c,                      `!!!!!!!!!!!!!!!\n!!!!!!!!!!    ,ccc$$$$$$$$$$$$$$$$$$$,                     `!!!!!!!!!!!!!!\n!!!!!!!!!    d$$$$$$$$$$$$$$$$$$$$$$$$;.                    `!!!!!!!!!!!!!\n!!!!!!!!    <$$$$$$$$$$$$$$$$$$$$$$$$$$;.                    `!!!!!!!!!!!!\n!!!!!!!     $$$$$$$$$$$$$$$$$$$$$$$$$$$d;;.                   !!!!!!!!!!!!\n!!!!!!'     $$$$$$$$$$$$$$$$$$$$$$$$$$$$$d;.                   !!!!!!!!!!!\n!!!!!'     <$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$                   !!!!!!!!!!!\n!!!!'      `$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$                   `!!!!!!!!!!\n!!!!        c$$$$???$$$$$$$d\"\"  \"\"\"??????\"                      !!!!!!!!!!\n!!!         `\"\" .,.. \"$$$$$    .,dcd                            !!!!!!!!!!\n!!!         .  d!    .?$$$   .,cc,      .,d$d.                  !!!!!!!!!!\n!!!!        <. $$c- <$d$$$   <$$$$---$\"$$$$$$$                  !!!!!!!!!!\n!!!         d$$$dcccd$$$$$   d$$$dcccd$$$$$$$$                  `!!!!!!!!!\n!!         ,$$$$$$$$$$$$$$d d$$$$$$$$$$$$$$$$                   `!!!!!!!!!\n!          `$$$$$$$$$$$$$$$<$$$$$$$$$$$$$$$$'                    !!!!!!!!!\n!          `$$$$$$$$$$$$$$$$\"$$$$$$$$$$$$$d>                     !!!!!!!!!\n!           ?$$$$$$$$$$$$??$c`$$$$$$$$$$$?>'                     `!!!!!!!!\n!           `?$$$$$$!>?\"\"    ,$$$$$$$$$?>>'                       !!!!!!!!\n!.           <<?$$$$$$c.    ,d$$?$$$$$$>>''                       `!!!!!!!\n!!            <!?$d\"??$$d--\"?\"\"  ,$$$$d;>''                       `!!!!!!!\n!!             $$$dccccccccc- cc$$$$$$$>>'                         !!!!!!!\n!              `?$$$$$$$\"\"\"\"  `\"$$$$$>>>''                         `!!!!!!\n!                \"?$$$$$cccccc$$$$??>>>>'                           !!!!!!\n>                  \"$$$$$$$$$$$$$$>>>>''                            `!!!!!\n!                    \"$$$$$$$$???>'''                                !!!!!\n!>                     `\"\"\"\"\"                                        `!!!!\n!!;                       .                                          `!!!!\n!!!                       ?d.                                         !!!!\n!!!!                       $$c,                                       !!!!\n!!!!>                      ?$$$d.              .,c                    !!!!\n!!!!!                       $$$$$$$$$dc,.,,cc$$$$$                    !!!!\n!!!!!                  .,dcc$$$$$$$$$$$$$$$$$$$$$$                    !!!!\n!!!!!               .d$$$$$$$$$$$$$$$$$$$$$$$$$$$$                    !!!!\n!!!!!             ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$          .         !!!!\n!!!!!           ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$         !!         !!!!\n!!!!!         ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$        ,!'         !!!!\n!!!!>        c$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$.       !'          !!!!\n!!''       ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$>       '           !!!'\n'         d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$>                   !'  \n         ,$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$>             ..        \n        d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$'           ;!!!!''`    \n        $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$       ,;;!'`'  .''     \n       <$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$>    ,;'`'  ,;           \n       `$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$   -'   ,;!!'            \n        \"?$$$$$$$$$$?$$$$$$$$$$$$$$$$$$$$$$$$$$$     .<!!!'''       <!    \n     !>    \"\"??$$$?<?$$$$$$$$$$$$$$$$$$$$$$$$\"\"     ;!'''          !!!    \n   ;!!!!;,      `\"''\"\"????$$$$$$$$$$$$$$$$\"\"   ,;-''               ',!    \n  ;!!!!<!!!; .                `\"\"\"\"\"\"\"\"\"\"\"    `'                  ' '     \n  !!!! ;!!! ;!!!!>;,;, ..                  ' .                   '  '     \n !!' ,;!!! ;'`!!!!!!!!;!!!!!;  .        >' .''                 ;          \n!!' ;!!'!';! !! !!!!!!!!!!!!!  '         -'                              <\n!!  !! `!;! `!' !!!!!!!!!!<!       .                                     `\n!  ;!  ;!!! <' <!!!! `!!! <       !                                     `;\n   !>  <!! ;'  !!!!'  !!';!     ;'                                       !\n   !   !!! !   `!!!  ;!! !      '  '                                    ; \n  `!  `!! ,'    !'   ;!'                                                  \n  '   !`! !    <     !! <      '                                          \n       ! ;!        >;! ;>                                                 \n         !'       ; !! '                                                  \n      ' ;!        > ! '                                                   \n        '                                                             "
       
       (compared using ==)
       
       Diff:
       
       @@ -1,71 +1,72 @@
       +!!!!
        !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
        !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
       -!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!>''''''<!!!!!!!!!!!!!!!!!!!!!!!!!!!!
       -!!!!!!!!!!!!!!!!!!!!!!!!!!!!'''''`             ``'!!!!!!!!!!!!!!!!!!!!!!!!
       -!!!!!!!!!!!!!!!!!!!!!!!!''`          .....         `'!!!!!!!!!!!!!!!!!!!!!
       -!!!!!!!!!!!!!!!!!!!!!'`      .      ;;;;;'            `'!!!!!!!!!!!!!!!!!!
       -!!!!!!!!!!!!!!!!!!!'     .   '     .;;;;'                `!!!!!!!!!!!!!!!!
       -!!!!!!!!!!!!!!!!!'      ;          `````                   `!!!!!!!!!!!!!!
       -!!!!!!!!!!!!!!!!        .,ccdcccccc,,.                       `!!!!!!!!!!!!
       -!!!!!!!!!!!!!!!     .-"?$$$$$$$$$$$$$$c,                      `!!!!!!!!!!!
       -!!!!!!!!!!!!!!    ,ccc$$$$$$$$$$$$$$$$$$$,                     `!!!!!!!!!!
       -!!!!!!!!!!!!!    d$$$$$$$$$$$$$$$$$$$$$$$$;.                    `!!!!!!!!!
       -!!!!!!!!!!!!    <$$$$$$$$$$$$$$$$$$$$$$$$$$;.                    `!!!!!!!!
       -!!!!!!!!!!!     $$$$$$$$$$$$$$$$$$$$$$$$$$$d;;.                   !!!!!!!!
       -!!!!!!!!!!'     $$$$$$$$$$$$$$$$$$$$$$$$$$$$$d;.                   !!!!!!!
       -!!!!!!!!!'     <$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$                   !!!!!!!
       -!!!!!!!!'      `$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$                   `!!!!!!
       -!!!!!!!!        c$$$$???$$$$$$$d""  """??????"                      !!!!!!
       -!!!!!!!         `"" .,.. "$$$$$    .,dcd                            !!!!!!
       -!!!!!!!         .  d!    .?$$$   .,cc,      .,d$d.                  !!!!!!
       -!!!!!!!!        <. $$c- <$d$$$   <$$$$---$"$$$$$$$                  !!!!!!
       -!!!!!!!         d$$$dcccd$$$$$   d$$$dcccd$$$$$$$$                  `!!!!!
       -!!!!!!         ,$$$$$$$$$$$$$$d d$$$$$$$$$$$$$$$$                   `!!!!!
       -!!!!!          `$$$$$$$$$$$$$$$<$$$$$$$$$$$$$$$$'                    !!!!!
       -!!!!!          `$$$$$$$$$$$$$$$$"$$$$$$$$$$$$$d>                     !!!!!
       -!!!!!           ?$$$$$$$$$$$$??$c`$$$$$$$$$$$?>'                     `!!!!
       -!!!!!           `?$$$$$$!>?""    ,$$$$$$$$$?>>'                       !!!!
       -!!!!!.           <<?$$$$$$c.    ,d$$?$$$$$$>>''                       `!!!
       -!!!!!!            <!?$d"??$$d--"?""  ,$$$$d;>''                       `!!!
       -!!!!!!             $$$dccccccccc- cc$$$$$$$>>'                         !!!
       -!!!!!              `?$$$$$$$""""  `"$$$$$>>>''                         `!!
       -!!!!!                "?$$$$$cccccc$$$$??>>>>'                           !!
       -!!!!>                  "$$$$$$$$$$$$$$>>>>''                            `!
       -!!!!!                    "$$$$$$$$???>'''                                !
       -!!!!!>                     `"""""                                        `
       -!!!!!!;                       .                                          `
       -!!!!!!!                       ?d.                                         
       -!!!!!!!!                       $$c,                                       
       -!!!!!!!!>                      ?$$$d.              .,c                    
       -!!!!!!!!!                       $$$$$$$$$dc,.,,cc$$$$$                    
       -!!!!!!!!!                  .,dcc$$$$$$$$$$$$$$$$$$$$$$                    
       -!!!!!!!!!               .d$$$$$$$$$$$$$$$$$$$$$$$$$$$$                    
       -!!!!!!!!!             ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$          .         
       -!!!!!!!!!           ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$         !!         
       -!!!!!!!!!         ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$        ,!'         
       -!!!!!!!!>        c$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$.       !'          
       -!!!!!!''       ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$>       '           
       -!!!''         d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$>                   
       -!'           ,$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$>             ..    
       -            d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$'           ;!!!!''`
       -            $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$       ,;;!'`'  .'' 
       -           <$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$>    ,;'`'  ,;       
       -           `$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$   -'   ,;!!'        
       -            "?$$$$$$$$$$?$$$$$$$$$$$$$$$$$$$$$$$$$$$     .<!!!'''       <!
       -         !>    ""??$$$?<?$$$$$$$$$$$$$$$$$$$$$$$$""     ;!'''          !!!
       -       ;!!!!;,      `"''""????$$$$$$$$$$$$$$$$""   ,;-''               ',!
       -      ;!!!!<!!!; .                `"""""""""""    `'                  ' ' 
       -      !!!! ;!!! ;!!!!>;,;, ..                  ' .                   '  ' 
       -     !!' ,;!!! ;'`!!!!!!!!;!!!!!;  .        >' .''                 ;      
       -    !!' ;!!'!';! !! !!!!!!!!!!!!!  '         -'                           
       -   <!!  !! `!;! `!' !!!!!!!!!!<!       .                                  
       -   `!  ;!  ;!!! <' <!!!! `!!! <       !                                   
       -  `;   !>  <!! ;'  !!!!'  !!';!     ;'                                    
       -   !   !   !!! !   `!!!  ;!! !      '  '                                  
       -  ;   `!  `!! ,'    !'   ;!'                                              
       -      '   !`! !    <     !! <      '                                      
       -           ! ;!        >;! ;>                                             
       -             !'       ; !! '                                              
       -          ' ;!        > ! '                                               
       -            '                                                             
       +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!>''''''<!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
       +!!!!!!!!!!!!!!!!!!!!!!!!'''''`             ``'!!!!!!!!!!!!!!!!!!!!!!!!!!!!
       +!!!!!!!!!!!!!!!!!!!!''`          .....         `'!!!!!!!!!!!!!!!!!!!!!!!!!
       +!!!!!!!!!!!!!!!!!'`      .      ;;;;;'            `'!!!!!!!!!!!!!!!!!!!!!!
       +!!!!!!!!!!!!!!!'     .   '     .;;;;'                `!!!!!!!!!!!!!!!!!!!!
       +!!!!!!!!!!!!!'      ;          `````                   `!!!!!!!!!!!!!!!!!!
       +!!!!!!!!!!!!        .,ccdcccccc,,.                       `!!!!!!!!!!!!!!!!
       +!!!!!!!!!!!     .-"?$$$$$$$$$$$$$$c,                      `!!!!!!!!!!!!!!!
       +!!!!!!!!!!    ,ccc$$$$$$$$$$$$$$$$$$$,                     `!!!!!!!!!!!!!!
       +!!!!!!!!!    d$$$$$$$$$$$$$$$$$$$$$$$$;.                    `!!!!!!!!!!!!!
       +!!!!!!!!    <$$$$$$$$$$$$$$$$$$$$$$$$$$;.                    `!!!!!!!!!!!!
       +!!!!!!!     $$$$$$$$$$$$$$$$$$$$$$$$$$$d;;.                   !!!!!!!!!!!!
       +!!!!!!'     $$$$$$$$$$$$$$$$$$$$$$$$$$$$$d;.                   !!!!!!!!!!!
       +!!!!!'     <$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$                   !!!!!!!!!!!
       +!!!!'      `$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$                   `!!!!!!!!!!
       +!!!!        c$$$$???$$$$$$$d""  """??????"                      !!!!!!!!!!
       +!!!         `"" .,.. "$$$$$    .,dcd                            !!!!!!!!!!
       +!!!         .  d!    .?$$$   .,cc,      .,d$d.                  !!!!!!!!!!
       +!!!!        <. $$c- <$d$$$   <$$$$---$"$$$$$$$                  !!!!!!!!!!
       +!!!         d$$$dcccd$$$$$   d$$$dcccd$$$$$$$$                  `!!!!!!!!!
       +!!         ,$$$$$$$$$$$$$$d d$$$$$$$$$$$$$$$$                   `!!!!!!!!!
       +!          `$$$$$$$$$$$$$$$<$$$$$$$$$$$$$$$$'                    !!!!!!!!!
       +!          `$$$$$$$$$$$$$$$$"$$$$$$$$$$$$$d>                     !!!!!!!!!
       +!           ?$$$$$$$$$$$$??$c`$$$$$$$$$$$?>'                     `!!!!!!!!
       +!           `?$$$$$$!>?""    ,$$$$$$$$$?>>'                       !!!!!!!!
       +!.           <<?$$$$$$c.    ,d$$?$$$$$$>>''                       `!!!!!!!
       +!!            <!?$d"??$$d--"?""  ,$$$$d;>''                       `!!!!!!!
       +!!             $$$dccccccccc- cc$$$$$$$>>'                         !!!!!!!
       +!              `?$$$$$$$""""  `"$$$$$>>>''                         `!!!!!!
       +!                "?$$$$$cccccc$$$$??>>>>'                           !!!!!!
       +>                  "$$$$$$$$$$$$$$>>>>''                            `!!!!!
       +!                    "$$$$$$$$???>'''                                !!!!!
       +!>                     `"""""                                        `!!!!
       +!!;                       .                                          `!!!!
       +!!!                       ?d.                                         !!!!
       +!!!!                       $$c,                                       !!!!
       +!!!!>                      ?$$$d.              .,c                    !!!!
       +!!!!!                       $$$$$$$$$dc,.,,cc$$$$$                    !!!!
       +!!!!!                  .,dcc$$$$$$$$$$$$$$$$$$$$$$                    !!!!
       +!!!!!               .d$$$$$$$$$$$$$$$$$$$$$$$$$$$$                    !!!!
       +!!!!!             ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$          .         !!!!
       +!!!!!           ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$         !!         !!!!
       +!!!!!         ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$        ,!'         !!!!
       +!!!!>        c$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$.       !'          !!!!
       +!!''       ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$>       '           !!!'
       +'         d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$>                   !'  
       +         ,$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$>             ..        
       +        d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$'           ;!!!!''`    
       +        $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$       ,;;!'`'  .''     
       +       <$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$>    ,;'`'  ,;           
       +       `$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$   -'   ,;!!'            
       +        "?$$$$$$$$$$?$$$$$$$$$$$$$$$$$$$$$$$$$$$     .<!!!'''       <!    
       +     !>    ""??$$$?<?$$$$$$$$$$$$$$$$$$$$$$$$""     ;!'''          !!!    
       +   ;!!!!;,      `"''""????$$$$$$$$$$$$$$$$""   ,;-''               ',!    
       +  ;!!!!<!!!; .                `"""""""""""    `'                  ' '     
       +  !!!! ;!!! ;!!!!>;,;, ..                  ' .                   '  '     
       + !!' ,;!!! ;'`!!!!!!!!;!!!!!;  .        >' .''                 ;          
       +!!' ;!!'!';! !! !!!!!!!!!!!!!  '         -'                              <
       +!!  !! `!;! `!' !!!!!!!!!!<!       .                                     `
       +!  ;!  ;!!! <' <!!!! `!!! <       !                                     `;
       +   !>  <!! ;'  !!!!'  !!';!     ;'                                       !
       +   !   !!! !   `!!!  ;!! !      '  '                                    ; 
       +  `!  `!! ,'    !'   ;!'                                                  
       +  '   !`! !    <     !! <      '                                          
       +       ! ;!        >;! ;>                                                 
       +         !'       ; !! '                                                  
       +      ' ;!        > ! '                                                   
       +        '                                                             
     # /tmp/d20131110-20795-139hv60/spec.rb:105:in `block (2 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

Finished in 0.04643 seconds
5 examples, 2 failures

Failed examples:

rspec /tmp/d20131110-20795-139hv60/spec.rb:2 # Bitmap renders bytes
rspec /tmp/d20131110-20795-139hv60/spec.rb:31 # Bitmap renders La Gioconda
Калоян Калудов
  • Некоректно
  • 0 успешни тест(а)
  • 5 неуспешни тест(а)
Калоян Калудов
class Bitmap
def initialize(bytes, bytes_per_row=nil)
@byte_string = ""
@bytes_per_row = bytes_per_row
bytes.each_with_index do |byte, index|
binary = byte.to_s(2)
@byte_string += "0" * (8 - binary.size) + binary
end
end
def render(palette=[".", "#"])
output_string = ""
slice_size = Math.log2(palette.size)
slice_count = @byte_string.size / slice_size - 1
0.upto(slice_count) do |index|
slice = @byte_string[index * slice_size, slice_size]
output_string += palette[slice.to_i(2)]
if @bytes_per_row and index != slice_count
if (index + 1) % (8 / slice_size * @bytes_per_row) == 0
output_string += "\n"
end
end
end
puts output_string
end
end
....#..#..#..........###
F....#..#..#.....
.....###.......#
F....#..#
..#.....
.....###
.......#
F..#*...x
..**...*
F!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!>''''''<!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!'''''`             ``'!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!''`          .....         `'!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!'`      .      ;;;;;'            `'!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!'     .   '     .;;;;'                `!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!'      ;          `````                   `!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!        .,ccdcccccc,,.                       `!!!!!!!!!!!!
!!!!!!!!!!!!!!!     .-"?$$$$$$$$$$$$$$c,                      `!!!!!!!!!!!
!!!!!!!!!!!!!!    ,ccc$$$$$$$$$$$$$$$$$$$,                     `!!!!!!!!!!
!!!!!!!!!!!!!    d$$$$$$$$$$$$$$$$$$$$$$$$;.                    `!!!!!!!!!
!!!!!!!!!!!!    <$$$$$$$$$$$$$$$$$$$$$$$$$$;.                    `!!!!!!!!
!!!!!!!!!!!     $$$$$$$$$$$$$$$$$$$$$$$$$$$d;;.                   !!!!!!!!
!!!!!!!!!!'     $$$$$$$$$$$$$$$$$$$$$$$$$$$$$d;.                   !!!!!!!
!!!!!!!!!'     <$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$                   !!!!!!!
!!!!!!!!'      `$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$                   `!!!!!!
!!!!!!!!        c$$$$???$$$$$$$d""  """??????"                      !!!!!!
!!!!!!!         `"" .,.. "$$$$$    .,dcd                            !!!!!!
!!!!!!!         .  d!    .?$$$   .,cc,      .,d$d.                  !!!!!!
!!!!!!!!        <. $$c- <$d$$$   <$$$$---$"$$$$$$$                  !!!!!!
!!!!!!!         d$$$dcccd$$$$$   d$$$dcccd$$$$$$$$                  `!!!!!
!!!!!!         ,$$$$$$$$$$$$$$d d$$$$$$$$$$$$$$$$                   `!!!!!
!!!!!          `$$$$$$$$$$$$$$$<$$$$$$$$$$$$$$$$'                    !!!!!
!!!!!          `$$$$$$$$$$$$$$$$"$$$$$$$$$$$$$d>                     !!!!!
!!!!!           ?$$$$$$$$$$$$??$c`$$$$$$$$$$$?>'                     `!!!!
!!!!!           `?$$$$$$!>?""    ,$$$$$$$$$?>>'                       !!!!
!!!!!.           <<?$$$$$$c.    ,d$$?$$$$$$>>''                       `!!!
!!!!!!            <!?$d"??$$d--"?""  ,$$$$d;>''                       `!!!
!!!!!!             $$$dccccccccc- cc$$$$$$$>>'                         !!!
!!!!!              `?$$$$$$$""""  `"$$$$$>>>''                         `!!
!!!!!                "?$$$$$cccccc$$$$??>>>>'                           !!
!!!!>                  "$$$$$$$$$$$$$$>>>>''                            `!
!!!!!                    "$$$$$$$$???>'''                                !
!!!!!>                     `"""""                                        `
!!!!!!;                       .                                          `
!!!!!!!                       ?d.                                         
!!!!!!!!                       $$c,                                       
!!!!!!!!>                      ?$$$d.              .,c                    
!!!!!!!!!                       $$$$$$$$$dc,.,,cc$$$$$                    
!!!!!!!!!                  .,dcc$$$$$$$$$$$$$$$$$$$$$$                    
!!!!!!!!!               .d$$$$$$$$$$$$$$$$$$$$$$$$$$$$                    
!!!!!!!!!             ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$          .         
!!!!!!!!!           ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$         !!         
!!!!!!!!!         ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$        ,!'         
!!!!!!!!>        c$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$.       !'          
!!!!!!''       ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$>       '           
!!!''         d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$>                   
!'           ,$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$>             ..    
            d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$'           ;!!!!''`
            $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$       ,;;!'`'  .'' 
           <$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$>    ,;'`'  ,;       
           `$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$   -'   ,;!!'        
            "?$$$$$$$$$$?$$$$$$$$$$$$$$$$$$$$$$$$$$$     .<!!!'''       <!
         !>    ""??$$$?<?$$$$$$$$$$$$$$$$$$$$$$$$""     ;!'''          !!!
       ;!!!!;,      `"''""????$$$$$$$$$$$$$$$$""   ,;-''               ',!
      ;!!!!<!!!; .                `"""""""""""    `'                  ' ' 
      !!!! ;!!! ;!!!!>;,;, ..                  ' .                   '  ' 
     !!' ,;!!! ;'`!!!!!!!!;!!!!!;  .        >' .''                 ;      
    !!' ;!!'!';! !! !!!!!!!!!!!!!  '         -'                           
   <!!  !! `!;! `!' !!!!!!!!!!<!       .                                  
   `!  ;!  ;!!! <' <!!!! `!!! <       !                                   
  `;   !>  <!! ;'  !!!!'  !!';!     ;'                                    
   !   !   !!! !   `!!!  ;!! !      '  '                                  
  ;   `!  `!! ,'    !'   ;!'                                              
      '   !`! !    <     !! <      '                                      
           ! ;!        >;! ;>                                             
             !'       ; !! '                                              
          ' ;!        > ! '                                               
            '                                                             
F

Failures:

  1) Bitmap renders bytes
     Failure/Error: expect(Bitmap.new([9, 32, 7]).render).to eq <<-ASCII.strip
       
       expected: "....#..#..#..........###"
            got: nil
       
       (compared using ==)
     # /tmp/d20131110-20795-1o3mh2m/spec.rb:3:in `block (2 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  2) Bitmap makes multiple rows, if said to
     Failure/Error: expect(Bitmap.new([9, 32, 7, 1], 2).render).to eq <<-ASCII.strip
       
       expected: "....#..#..#.....\n.....###.......#"
            got: nil
       
       (compared using ==)
     # /tmp/d20131110-20795-1o3mh2m/spec.rb:9:in `block (2 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  3) Bitmap can render a column
     Failure/Error: expect(Bitmap.new([9, 32, 7, 1], 1).render).to eq <<-ASCII.strip
       
       expected: "....#..#\n..#.....\n.....###\n.......#"
            got: nil
       
       (compared using ==)
     # /tmp/d20131110-20795-1o3mh2m/spec.rb:16:in `block (2 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  4) Bitmap supports different palettes
     Failure/Error: expect(Bitmap.new([13, 2, 5, 1], 2).render(%w(. * x #))).to eq <<-ASCII.strip
       
       expected: "..#*...x\n..**...*"
            got: nil
       
       (compared using ==)
     # /tmp/d20131110-20795-1o3mh2m/spec.rb:25:in `block (2 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  5) Bitmap renders La Gioconda
     Failure/Error: Bitmap.new(the_bitmap, 37).render(["!", "\n", ">", "'", "<", "`", " ", ".", ";", ",", "c", "d", "-", "\"", "?", "$"]).should eq expectation
       
       expected: "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!>''''''<!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!'''''`             ``'!!!!!!!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!!!!!!''`          .....         `'!!!!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!!!'`      .      ;;;;;'            `'!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!'     .   '     .;;;;'                `!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!'      ;          `````                   `!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!        .,ccdcccccc,,.                       `!!!!!!!!!!!!\n!!!!!!!!!!!!!!!     .-\"?$$$$$$$$$$$$$$c,                      `!!!!!!!!!!!\n!!!!!!!!!!!!!!    ,ccc$$$$$$$$$$$$$$$$$$$,                     `!!!!!!!!!!\n!!!!!!!!!!!!!    d$$$$$$$$$$$$$$$$$$$$$$$$;.                    `!!!!!!!!!\n!!!!!!!!!!!!    <$$$$$$$$$$$$$$$$$$$$$$$$$$;.                    `!!!!!!!!\n!!!!!!!!!!!     $$$$$$$$$$$$$$$$$$$$$$$$$$$d;;.                   !!!!!!!!\n!!!!!!!!!!'     $$$$$$$$$$$$$$$$$$$$$$$$$$$$$d;.                   !!!!!!!\n!!!!!!!!!'     <$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$                   !!!!!!!\n!!!!!!!!'      `$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$                   `!!!!!!\n!!!!!!!!        c$$$$???$$$$$$$d\"\"  \"\"\"??????\"                      !!!!!!\n!!!!!!!         `\"\" .,.. \"$$$$$    .,dcd                            !!!!!!\n!!!!!!!         .  d!    .?$$$   .,cc,      .,d$d.                  !!!!!!\n!!!!!!!!        <. $$c- <$d$$$   <$$$$---$\"$$$$$$$                  !!!!!!\n!!!!!!!         d$$$dcccd$$$$$   d$$$dcccd$$$$$$$$                  `!!!!!\n!!!!!!         ,$$$$$$$$$$$$$$d d$$$$$$$$$$$$$$$$                   `!!!!!\n!!!!!          `$$$$$$$$$$$$$$$<$$$$$$$$$$$$$$$$'                    !!!!!\n!!!!!          `$$$$$$$$$$$$$$$$\"$$$$$$$$$$$$$d>                     !!!!!\n!!!!!           ?$$$$$$$$$$$$??$c`$$$$$$$$$$$?>'                     `!!!!\n!!!!!           `?$$$$$$!>?\"\"    ,$$$$$$$$$?>>'                       !!!!\n!!!!!.           <<?$$$$$$c.    ,d$$?$$$$$$>>''                       `!!!\n!!!!!!            <!?$d\"??$$d--\"?\"\"  ,$$$$d;>''                       `!!!\n!!!!!!             $$$dccccccccc- cc$$$$$$$>>'                         !!!\n!!!!!              `?$$$$$$$\"\"\"\"  `\"$$$$$>>>''                         `!!\n!!!!!                \"?$$$$$cccccc$$$$??>>>>'                           !!\n!!!!>                  \"$$$$$$$$$$$$$$>>>>''                            `!\n!!!!!                    \"$$$$$$$$???>'''                                !\n!!!!!>                     `\"\"\"\"\"                                        `\n!!!!!!;                       .                                          `\n!!!!!!!                       ?d.                                         \n!!!!!!!!                       $$c,                                       \n!!!!!!!!>                      ?$$$d.              .,c                    \n!!!!!!!!!                       $$$$$$$$$dc,.,,cc$$$$$                    \n!!!!!!!!!                  .,dcc$$$$$$$$$$$$$$$$$$$$$$                    \n!!!!!!!!!               .d$$$$$$$$$$$$$$$$$$$$$$$$$$$$                    \n!!!!!!!!!             ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$          .         \n!!!!!!!!!           ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$         !!         \n!!!!!!!!!         ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$        ,!'         \n!!!!!!!!>        c$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$.       !'          \n!!!!!!''       ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$>       '           \n!!!''         d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$>                   \n!'           ,$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$>             ..    \n            d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$'           ;!!!!''`\n            $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$       ,;;!'`'  .'' \n           <$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$>    ,;'`'  ,;       \n           `$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$   -'   ,;!!'        \n            \"?$$$$$$$$$$?$$$$$$$$$$$$$$$$$$$$$$$$$$$     .<!!!'''       <!\n         !>    \"\"??$$$?<?$$$$$$$$$$$$$$$$$$$$$$$$\"\"     ;!'''          !!!\n       ;!!!!;,      `\"''\"\"????$$$$$$$$$$$$$$$$\"\"   ,;-''               ',!\n      ;!!!!<!!!; .                `\"\"\"\"\"\"\"\"\"\"\"    `'                  ' ' \n      !!!! ;!!! ;!!!!>;,;, ..                  ' .                   '  ' \n     !!' ,;!!! ;'`!!!!!!!!;!!!!!;  .        >' .''                 ;      \n    !!' ;!!'!';! !! !!!!!!!!!!!!!  '         -'                           \n   <!!  !! `!;! `!' !!!!!!!!!!<!       .                                  \n   `!  ;!  ;!!! <' <!!!! `!!! <       !                                   \n  `;   !>  <!! ;'  !!!!'  !!';!     ;'                                    \n   !   !   !!! !   `!!!  ;!! !      '  '                                  \n  ;   `!  `!! ,'    !'   ;!'                                              \n      '   !`! !    <     !! <      '                                      \n           ! ;!        >;! ;>                                             \n             !'       ; !! '                                              \n          ' ;!        > ! '                                               \n            '                                                             "
            got: nil
       
       (compared using ==)
     # /tmp/d20131110-20795-1o3mh2m/spec.rb:105:in `block (2 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

Finished in 0.09517 seconds
5 examples, 5 failures

Failed examples:

rspec /tmp/d20131110-20795-1o3mh2m/spec.rb:2 # Bitmap renders bytes
rspec /tmp/d20131110-20795-1o3mh2m/spec.rb:8 # Bitmap makes multiple rows, if said to
rspec /tmp/d20131110-20795-1o3mh2m/spec.rb:15 # Bitmap can render a column
rspec /tmp/d20131110-20795-1o3mh2m/spec.rb:24 # Bitmap supports different palettes
rspec /tmp/d20131110-20795-1o3mh2m/spec.rb:31 # Bitmap renders La Gioconda
Александър Попов
  • Коректно
  • 5 успешни тест(а)
  • 0 неуспешни тест(а)
Александър Попов
class Bitmap
def initialize(bytes, bytes_per_row = bytes.size)
@bytes, @bytes_per_row = bytes, bytes_per_row
end
def render(palette = ['.', '#'])
@bits_per_color = Math.log(palette.size, 2)
pixels_per_row = @bytes_per_row * (8 / @bits_per_color)
color_hash = Hash[[0,1].repeated_permutation(@bits_per_color).map(&:join)
.zip(palette)]
@bytes.map { |pixel| "%08b" % pixel }.join.chars.to_a
.each_slice(@bits_per_color).map(&:join).map { |code| color_hash[code] }
.each_slice(pixels_per_row).map(&:join).join("\n")
end
end
.....

Finished in 0.0448 seconds
5 examples, 0 failures
Деян Хаджиев
  • Коректно
  • 5 успешни тест(а)
  • 0 неуспешни тест(а)
Деян Хаджиев
module Enumerable
def split_up(length:, step: length, pad: [])
concatenated = to_a + pad.take( length - size % length )
concatenated.to_enum.each_slice(step).map { |slice| slice.take length }.each { |slice| yield slice if block_given? }.to_a
end
end
class Bitmap
def initialize(bytes, bytes_per_line = 0)
raise "Invalid bytes array" if bytes.any? { |byte| byte < 0 or byte > 255 }
@bytes = bytes
@bytes_per_line = bytes_per_line
end
def render(palette = ['.', '#'])
formated_bytes = @bytes.map { |byte| render_byte byte, palette }
if @bytes_per_line > 0
formated_bytes.split_up(length: @bytes_per_line).map { |line| line.join }.join("\n")
else
formated_bytes.join
end
end
def render_byte(byte, palette)
mask = generate_mask palette.size
shift_step = Math.log(palette.size, 2).to_i
pixel_array = Array.new(8 / shift_step) { |index| (byte >> shift_step * index) & mask}.reverse
pixel_array.map { |pixel_byte| palette[pixel_byte] }.join
end
#check if the palette size is a power of a power of 2
def generate_mask(palette_size)
number_one_bits_array = Array.new(Math.log(palette_size, 2).ceil) { |index| (palette_size - 1) >> index & 1 }
number_one_bits = number_one_bits_array.reduce(0) { |num, one_bit| num += one_bit }
raise "Invalid pallette size" if number_one_bits & (number_one_bits - 1) != 0 or palette_size & (palette_size - 1) != 0 or palette_size <= 1
palette_size - 1
end
private :generate_mask, :render_byte
end
.....

Finished in 0.06126 seconds
5 examples, 0 failures
Иван Капукаранов
  • Некоректно
  • 4 успешни тест(а)
  • 1 неуспешни тест(а)
Иван Капукаранов
class Bitmap
def initialize(bytes_array, bytes = bytes_array.length)
@bytes_array = bytes_array
@bytes = bytes
end
def render(palitra = %w(. #))
case palitra.length
when 2 then pixel_type, pixel_count = 1, 8
when 4 then pixel_type, pixel_count = 2, 4
when 16 then pixel_type, pixel_count = 4, 2
end
pattern = make_pattern pixel_type, palitra.length, palitra
picture, bytes_list = "", ""
@bytes_array.each { |byte| bytes_list << sprintf("%08b", byte) }
bytes_list.scan(/.{#{pixel_type}}/).map { |pixel| picture << pattern[pixel] }
picture.scan(/.{#{pixel_count * @bytes}}/).map { |byte| byte + "\n" }.join.strip.b
end
def make_pattern(pixel_type, palitra_length, palitra)
counter = 0
pattern = {}
while counter < palitra_length
pattern[sprintf "%0#{pixel_type}b", counter] = palitra[counter]
counter += 1
end
pattern
end
end
....F

Failures:

  1) Bitmap renders La Gioconda
     Failure/Error: Bitmap.new(the_bitmap, 37).render(["!", "\n", ">", "'", "<", "`", " ", ".", ";", ",", "c", "d", "-", "\"", "?", "$"]).should eq expectation
       
       expected: "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!>''''''<!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!'''''`             ``'!!!!!!!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!!!!!!''`          .....         `'!!!!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!!!'`      .      ;;;;;'            `'!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!'     .   '     .;;;;'                `!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!'      ;          `````                   `!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!        .,ccdcccccc,,.                       `!!!!!!!!!!!!\n!!!!!!!!!!!!!!!     .-\"?$$$$$$$$$$$$$$c,                      `!!!!!!!!!!!\n!!!!!!!!!!!!!!    ,ccc$$$$$$$$$$$$$$$$$$$,                     `!!!!!!!!!!\n!!!!!!!!!!!!!    d$$$$$$$$$$$$$$$$$$$$$$$$;.                    `!!!!!!!!!\n!!!!!!!!!!!!    <$$$$$$$$$$$$$$$$$$$$$$$$$$;.                    `!!!!!!!!\n!!!!!!!!!!!     $$$$$$$$$$$$$$$$$$$$$$$$$$$d;;.                   !!!!!!!!\n!!!!!!!!!!'     $$$$$$$$$$$$$$$$$$$$$$$$$$$$$d;.                   !!!!!!!\n!!!!!!!!!'     <$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$                   !!!!!!!\n!!!!!!!!'      `$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$                   `!!!!!!\n!!!!!!!!        c$$$$???$$$$$$$d\"\"  \"\"\"??????\"                      !!!!!!\n!!!!!!!         `\"\" .,.. \"$$$$$    .,dcd                            !!!!!!\n!!!!!!!         .  d!    .?$$$   .,cc,      .,d$d.                  !!!!!!\n!!!!!!!!        <. $$c- <$d$$$   <$$$$---$\"$$$$$$$                  !!!!!!\n!!!!!!!         d$$$dcccd$$$$$   d$$$dcccd$$$$$$$$                  `!!!!!\n!!!!!!         ,$$$$$$$$$$$$$$d d$$$$$$$$$$$$$$$$                   `!!!!!\n!!!!!          `$$$$$$$$$$$$$$$<$$$$$$$$$$$$$$$$'                    !!!!!\n!!!!!          `$$$$$$$$$$$$$$$$\"$$$$$$$$$$$$$d>                     !!!!!\n!!!!!           ?$$$$$$$$$$$$??$c`$$$$$$$$$$$?>'                     `!!!!\n!!!!!           `?$$$$$$!>?\"\"    ,$$$$$$$$$?>>'                       !!!!\n!!!!!.           <<?$$$$$$c.    ,d$$?$$$$$$>>''                       `!!!\n!!!!!!            <!?$d\"??$$d--\"?\"\"  ,$$$$d;>''                       `!!!\n!!!!!!             $$$dccccccccc- cc$$$$$$$>>'                         !!!\n!!!!!              `?$$$$$$$\"\"\"\"  `\"$$$$$>>>''                         `!!\n!!!!!                \"?$$$$$cccccc$$$$??>>>>'                           !!\n!!!!>                  \"$$$$$$$$$$$$$$>>>>''                            `!\n!!!!!                    \"$$$$$$$$???>'''                                !\n!!!!!>                     `\"\"\"\"\"                                        `\n!!!!!!;                       .                                          `\n!!!!!!!                       ?d.                                         \n!!!!!!!!                       $$c,                                       \n!!!!!!!!>                      ?$$$d.              .,c                    \n!!!!!!!!!                       $$$$$$$$$dc,.,,cc$$$$$                    \n!!!!!!!!!                  .,dcc$$$$$$$$$$$$$$$$$$$$$$                    \n!!!!!!!!!               .d$$$$$$$$$$$$$$$$$$$$$$$$$$$$                    \n!!!!!!!!!             ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$          .         \n!!!!!!!!!           ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$         !!         \n!!!!!!!!!         ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$        ,!'         \n!!!!!!!!>        c$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$.       !'          \n!!!!!!''       ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$>       '           \n!!!''         d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$>                   \n!'           ,$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$>             ..    \n            d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$'           ;!!!!''`\n            $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$       ,;;!'`'  .'' \n           <$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$>    ,;'`'  ,;       \n           `$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$   -'   ,;!!'        \n            \"?$$$$$$$$$$?$$$$$$$$$$$$$$$$$$$$$$$$$$$     .<!!!'''       <!\n         !>    \"\"??$$$?<?$$$$$$$$$$$$$$$$$$$$$$$$\"\"     ;!'''          !!!\n       ;!!!!;,      `\"''\"\"????$$$$$$$$$$$$$$$$\"\"   ,;-''               ',!\n      ;!!!!<!!!; .                `\"\"\"\"\"\"\"\"\"\"\"    `'                  ' ' \n      !!!! ;!!! ;!!!!>;,;, ..                  ' .                   '  ' \n     !!' ,;!!! ;'`!!!!!!!!;!!!!!;  .        >' .''                 ;      \n    !!' ;!!'!';! !! !!!!!!!!!!!!!  '         -'                           \n   <!!  !! `!;! `!' !!!!!!!!!!<!       .                                  \n   `!  ;!  ;!!! <' <!!!! `!!! <       !                                   \n  `;   !>  <!! ;'  !!!!'  !!';!     ;'                                    \n   !   !   !!! !   `!!!  ;!! !      '  '                                  \n  ;   `!  `!! ,'    !'   ;!'                                              \n      '   !`! !    <     !! <      '                                      \n           ! ;!        >;! ;>                                             \n             !'       ; !! '                                              \n          ' ;!        > ! '                                               \n            '                                                             "
            got: "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!>''''''<!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!'''''`             ``'!!!!!!!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!!!!!!''`          .....         `'!!!!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!!!'`      .      ;;;;;'            `'!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!'     .   '     .;;;;'                `!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!'      ;          `````                   `!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!        .,ccdcccccc,,.                       `!!!!!!!!!!!!\n!!!!!!!!!!!!!!!     .-\"?$$$$$$$$$$$$$$c,                      `!!!!!!!!!!!\n!!!!!!!!!!!!!!    ,ccc$$$$$$$$$$$$$$$$$$$,                     `!!!!!!!!!!\n!!!!!!!!!!!!!    d$$$$$$$$$$$$$$$$$$$$$$$$;.                    `!!!!!!!!!\n!!!!!!!!!!!!    <$$$$$$$$$$$$$$$$$$$$$$$$$$;.                    `!!!!!!!!\n!!!!!!!!!!!     $$$$$$$$$$$$$$$$$$$$$$$$$$$d;;.                   !!!!!!!!\n!!!!!!!!!!'     $$$$$$$$$$$$$$$$$$$$$$$$$$$$$d;.                   !!!!!!!\n!!!!!!!!!'     <$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$                   !!!!!!!\n!!!!!!!!'      `$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$                   `!!!!!!\n!!!!!!!!        c$$$$???$$$$$$$d\"\"  \"\"\"??????\"                      !!!!!!\n!!!!!!!         `\"\" .,.. \"$$$$$    .,dcd                            !!!!!!\n!!!!!!!         .  d!    .?$$$   .,cc,      .,d$d.                  !!!!!!\n!!!!!!!!        <. $$c- <$d$$$   <$$$$---$\"$$$$$$$                  !!!!!!\n!!!!!!!         d$$$dcccd$$$$$   d$$$dcccd$$$$$$$$                  `!!!!!\n!!!!!!         ,$$$$$$$$$$$$$$d d$$$$$$$$$$$$$$$$                   `!!!!!\n!!!!!          `$$$$$$$$$$$$$$$<$$$$$$$$$$$$$$$$'                    !!!!!\n!!!!!          `$$$$$$$$$$$$$$$$\"$$$$$$$$$$$$$d>                     !!!!!\n!!!!!           ?$$$$$$$$$$$$??$c`$$$$$$$$$$$?>'                     `!!!!\n!!!!!           `?$$$$$$!>?\"\"    ,$$$$$$$$$?>>'                       !!!!\n!!!!!.           <<?$$$$$$c.    ,d$$?$$$$$$>>''                       `!!!\n!!!!!!            <!?$d\"??$$d--\"?\"\"  ,$$$$d;>''                       `!!!\n!!!!!!             $$$dccccccccc- cc$$$$$$$>>'                         !!!\n!!!!!              `?$$$$$$$\"\"\"\"  `\"$$$$$>>>''                         `!!\n!!!!!                \"?$$$$$cccccc$$$$??>>>>'                           !!\n!!!!>                  \"$$$$$$$$$$$$$$>>>>''                            `!\n!!!!!                    \"$$$$$$$$???>'''                                !\n!!!!!>                     `\"\"\"\"\"                                        `\n!!!!!!;                       .                                          `\n!!!!!!!                       ?d.                                         \n!!!!!!!!                       $$c,                                       \n!!!!!!!!>                      ?$$$d.              .,c                    \n!!!!!!!!!                       $$$$$$$$$dc,.,,cc$$$$$                    \n!!!!!!!!!                  .,dcc$$$$$$$$$$$$$$$$$$$$$$                    \n!!!!!!!!!               .d$$$$$$$$$$$$$$$$$$$$$$$$$$$$                    \n!!!!!!!!!             ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$          .         \n!!!!!!!!!           ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$         !!         \n!!!!!!!!!         ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$        ,!'         \n!!!!!!!!>        c$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$.       !'          \n!!!!!!''       ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$>       '           \n!!!''         d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$>                   \n!'           ,$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$>             ..    \n            d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$'           ;!!!!''`\n            $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$       ,;;!'`'  .'' \n           <$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$>    ,;'`'  ,;       \n           `$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$   -'   ,;!!'        \n            \"?$$$$$$$$$$?$$$$$$$$$$$$$$$$$$$$$$$$$$$     .<!!!'''       <!\n         !>    \"\"??$$$?<?$$$$$$$$$$$$$$$$$$$$$$$$\"\"     ;!'''          !!!\n       ;!!!!;,      `\"''\"\"????$$$$$$$$$$$$$$$$\"\"   ,;-''               ',!\n      ;!!!!<!!!; .                `\"\"\"\"\"\"\"\"\"\"\"    `'                  ' ' \n      !!!! ;!!! ;!!!!>;,;, ..                  ' .                   '  ' \n     !!' ,;!!! ;'`!!!!!!!!;!!!!!;  .        >' .''                 ;      \n    !!' ;!!'!';! !! !!!!!!!!!!!!!  '         -'                           \n   <!!  !! `!;! `!' !!!!!!!!!!<!       .                                  \n   `!  ;!  ;!!! <' <!!!! `!!! <       !                                   \n  `;   !>  <!! ;'  !!!!'  !!';!     ;'                                    \n   !   !   !!! !   `!!!  ;!! !      '  '                                  \n  ;   `!  `!! ,'    !'   ;!'                                              \n      '   !`! !    <     !! <      '                                      \n           ! ;!        >;! ;>                                             \n             !'       ; !! '                                              \n          ' ;!        > ! '                                               \n            '"
       
       (compared using ==)
       
       Diff:
       @@ -67,5 +67,5 @@
                   ! ;!        >;! ;>                                             
                     !'       ; !! '                                              
                  ' ;!        > ! '                                               
       -            '                                                             
       +            '
     # /tmp/d20131110-20795-1xu3nfu/spec.rb:105:in `block (2 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

Finished in 0.03761 seconds
5 examples, 1 failure

Failed examples:

rspec /tmp/d20131110-20795-1xu3nfu/spec.rb:31 # Bitmap renders La Gioconda
Йордан Пулов
  • Некоректно
  • 0 успешни тест(а)
  • 5 неуспешни тест(а)
Йордан Пулов
class Bitmap
def initialize(img)
@image = img
end
def render(args)
mapImage =""
@image.map do |var|
7.downto(0) do |i|
if var < (2 ** i )
mapImage<<"0"
else
mapImage<<"1"
var-= (2 ** i)
end
end
end
mapImage.gsub! '0', args[0]
mapImage.gsub! '1', args[1]
return mapImage
end
end
FFFFF

Failures:

  1) Bitmap renders bytes
     Failure/Error: expect(Bitmap.new([9, 32, 7]).render).to eq <<-ASCII.strip
     ArgumentError:
       wrong number of arguments (0 for 1)
     # /tmp/d20131110-20795-11ydxfl/solution.rb:6:in `render'
     # /tmp/d20131110-20795-11ydxfl/spec.rb:3:in `block (2 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  2) Bitmap makes multiple rows, if said to
     Failure/Error: expect(Bitmap.new([9, 32, 7, 1], 2).render).to eq <<-ASCII.strip
     ArgumentError:
       wrong number of arguments (2 for 1)
     # /tmp/d20131110-20795-11ydxfl/solution.rb:3:in `initialize'
     # /tmp/d20131110-20795-11ydxfl/spec.rb:9:in `new'
     # /tmp/d20131110-20795-11ydxfl/spec.rb:9:in `block (2 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  3) Bitmap can render a column
     Failure/Error: expect(Bitmap.new([9, 32, 7, 1], 1).render).to eq <<-ASCII.strip
     ArgumentError:
       wrong number of arguments (2 for 1)
     # /tmp/d20131110-20795-11ydxfl/solution.rb:3:in `initialize'
     # /tmp/d20131110-20795-11ydxfl/spec.rb:16:in `new'
     # /tmp/d20131110-20795-11ydxfl/spec.rb:16:in `block (2 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  4) Bitmap supports different palettes
     Failure/Error: expect(Bitmap.new([13, 2, 5, 1], 2).render(%w(. * x #))).to eq <<-ASCII.strip
     ArgumentError:
       wrong number of arguments (2 for 1)
     # /tmp/d20131110-20795-11ydxfl/solution.rb:3:in `initialize'
     # /tmp/d20131110-20795-11ydxfl/spec.rb:25:in `new'
     # /tmp/d20131110-20795-11ydxfl/spec.rb:25:in `block (2 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  5) Bitmap renders La Gioconda
     Failure/Error: Bitmap.new(the_bitmap, 37).render(["!", "\n", ">", "'", "<", "`", " ", ".", ";", ",", "c", "d", "-", "\"", "?", "$"]).should eq expectation
     ArgumentError:
       wrong number of arguments (2 for 1)
     # /tmp/d20131110-20795-11ydxfl/solution.rb:3:in `initialize'
     # /tmp/d20131110-20795-11ydxfl/spec.rb:105:in `new'
     # /tmp/d20131110-20795-11ydxfl/spec.rb:105:in `block (2 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

Finished in 0.00549 seconds
5 examples, 5 failures

Failed examples:

rspec /tmp/d20131110-20795-11ydxfl/spec.rb:2 # Bitmap renders bytes
rspec /tmp/d20131110-20795-11ydxfl/spec.rb:8 # Bitmap makes multiple rows, if said to
rspec /tmp/d20131110-20795-11ydxfl/spec.rb:15 # Bitmap can render a column
rspec /tmp/d20131110-20795-11ydxfl/spec.rb:24 # Bitmap supports different palettes
rspec /tmp/d20131110-20795-11ydxfl/spec.rb:31 # Bitmap renders La Gioconda
Николай Хубанов
  • Коректно
  • 5 успешни тест(а)
  • 0 неуспешни тест(а)
Николай Хубанов
class Bitmap
def initialize(data, columns=data.size)
@data = data
@columns = columns
end
def render(colors=['.','#'])
@data.each_slice(@columns).map { |slice| stringify(slice, colors) }.join("\n")
end
private
def stringify(bytes, colors)
bytes.inject('') { |result, byte| result + ("%08b" % byte) }
.chars.each_slice(Math.log2(colors.size)).map(&:join)
.map { |slice| colors[slice.to_i(2)] }
.join
end
end
.....

Finished in 0.0528 seconds
5 examples, 0 failures
Диан Николов
  • Коректно
  • 5 успешни тест(а)
  • 0 неуспешни тест(а)
Диан Николов
class Bitmap
attr_reader :bitmap, :rowLength
def initialize(array, bytesPerRow = array.size)
@rawArray = array
@bytesPerRow = bytesPerRow
end
def map(array)
@bitmap = Hash.new
(0..array.size - 1).each { |t| bitmap[t] = array[t] }
end
def calcRowLength
@rowLength = 1
iterator = @bitmap.size
while iterator != 256
@rowLength += 1
iterator *= @bitmap.size
end
end
def toRadix(number)
radixArray = []
while number != 0
radixArray << number % @bitmap.size
number /= @bitmap.size
end
while radixArray.size < @rowLength
radixArray << 0
end
radixArray.reverse
end
def render(pallette = ['.', '#'])
map pallette
calcRowLength
imageString = ""
fullRadixArray = []
newLine = 0
@rawArray.each { |element| fullRadixArray << toRadix(element) }
fullRadixArray.each do |row|
if newLine % @bytesPerRow == 0 then imageString << "\n" end
newLine += 1
row.each { |i| imageString << @bitmap[i] }
end
imageString[1..-1]
end
end
.....

Finished in 0.01512 seconds
5 examples, 0 failures
Цветан Иванов
  • Коректно
  • 5 успешни тест(а)
  • 0 неуспешни тест(а)
Цветан Иванов
class Bitmap
def initialize(byte_list, line_count = byte_list.length)
@byte_list = byte_list
@line_count = line_count
end
def binary_representation
@byte_list.map{ |byte| byte.to_s(2) }.map do |byte|
("0" * (8 - byte.length)) << byte
end
end
def render(symbols = ['.', '#'])
binary_list = binary_representation.map { |byte| byte.split '' }
power_of_two_symbols = power_of_two(symbols.length)
binary_index_hash = construct_binary_hash(symbols)
bitmap_array = []
binary_list.each do |byte|
byte.each_slice(power_of_two_symbols) do |slice|
bitmap_array << binary_index_hash[slice.join]
end
end
construct_bitmap_string(bitmap_array, power_of_two_symbols)
end
def construct_bitmap_string(bitmap_array, power_of_two_symbols)
bitmap_string = ""
bytes_line = @line_count * (8 / power_of_two_symbols)
bitmap_array.each_slice(bytes_line) do |line|
bitmap_string << line.join << "\n"
end
bitmap_string[0, bitmap_string.length - 1]
end
def construct_binary_hash(symbols)
byte_size = power_of_two(symbols.length)
hash = {}
symbols.each_index do |index|
row = ("0" * ( byte_size - index.to_s(2).length)) << index.to_s(2)
hash[row] = symbols[index]
end
hash
end
def power_of_two(number)
power_counter = 0
while number != 0
number = number / 2
power_counter += 1
end
power_counter - 1
end
end
.....

Finished in 0.11173 seconds
5 examples, 0 failures
Владимир Конушлиев
  • Некоректно
  • 4 успешни тест(а)
  • 1 неуспешни тест(а)
Владимир Конушлиев
class Bitmap
#there should be a function to get this ...
LENGTH_BY_BASE = {2 => 8, 4 => 4, 16 => 2}
def initialize(bytes, bytes_per_line = bytes.size)
@bytes = bytes
@bytes_per_line = bytes_per_line
end
def render(palette = ['.','#'])
@bytes.each_slice(@bytes_per_line).map do |line|
Bitmap.line_to_image(line, palette)
end.join("\n")
end
def self.line_to_image(line, palette)
line.map do |byte|
base = palette.size
byte_s = byte.to_s(base)
full_byte = '0'*(LENGTH_BY_BASE[base] - byte_s.size) + byte_s
Bitmap.byte_to_image(full_byte, palette)
end.join
end
def self.byte_to_image(byte, palette)
byte.chars.map do |c|
palette[c.to_i]
end
end
end
....F

Failures:

  1) Bitmap renders La Gioconda
     Failure/Error: Bitmap.new(the_bitmap, 37).render(["!", "\n", ">", "'", "<", "`", " ", ".", ";", ",", "c", "d", "-", "\"", "?", "$"]).should eq expectation
       
       expected: "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!>''''''<!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!'''''`             ``'!!!!!!!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!!!!!!''`          .....         `'!!!!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!!!'`      .      ;;;;;'            `'!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!'     .   '     .;;;;'                `!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!'      ;          `````                   `!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!        .,ccdcccccc,,.                       `!!!!!!!!!!!!\n!!!!!!!!!!!!!!!     .-\"?$$$$$$$$$$$$$$c,                      `!!!!!!!!!!!\n!!!!!!!!!!!!!!    ,ccc$$$$$$$$$$$$$$$$$$$,                     `!!!!!!!!!!\n!!!!!!!!!!!!!    d$$$$$$$$$$$$$$$$$$$$$$$$;.                    `!!!!!!!!!\n!!!!!!!!!!!!    <$$$$$$$$$$$$$$$$$$$$$$$$$$;.                    `!!!!!!!!\n!!!!!!!!!!!     $$$$$$$$$$$$$$$$$$$$$$$$$$$d;;.                   !!!!!!!!\n!!!!!!!!!!'     $$$$$$$$$$$$$$$$$$$$$$$$$$$$$d;.                   !!!!!!!\n!!!!!!!!!'     <$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$                   !!!!!!!\n!!!!!!!!'      `$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$                   `!!!!!!\n!!!!!!!!        c$$$$???$$$$$$$d\"\"  \"\"\"??????\"                      !!!!!!\n!!!!!!!         `\"\" .,.. \"$$$$$    .,dcd                            !!!!!!\n!!!!!!!         .  d!    .?$$$   .,cc,      .,d$d.                  !!!!!!\n!!!!!!!!        <. $$c- <$d$$$   <$$$$---$\"$$$$$$$                  !!!!!!\n!!!!!!!         d$$$dcccd$$$$$   d$$$dcccd$$$$$$$$                  `!!!!!\n!!!!!!         ,$$$$$$$$$$$$$$d d$$$$$$$$$$$$$$$$                   `!!!!!\n!!!!!          `$$$$$$$$$$$$$$$<$$$$$$$$$$$$$$$$'                    !!!!!\n!!!!!          `$$$$$$$$$$$$$$$$\"$$$$$$$$$$$$$d>                     !!!!!\n!!!!!           ?$$$$$$$$$$$$??$c`$$$$$$$$$$$?>'                     `!!!!\n!!!!!           `?$$$$$$!>?\"\"    ,$$$$$$$$$?>>'                       !!!!\n!!!!!.           <<?$$$$$$c.    ,d$$?$$$$$$>>''                       `!!!\n!!!!!!            <!?$d\"??$$d--\"?\"\"  ,$$$$d;>''                       `!!!\n!!!!!!             $$$dccccccccc- cc$$$$$$$>>'                         !!!\n!!!!!              `?$$$$$$$\"\"\"\"  `\"$$$$$>>>''                         `!!\n!!!!!                \"?$$$$$cccccc$$$$??>>>>'                           !!\n!!!!>                  \"$$$$$$$$$$$$$$>>>>''                            `!\n!!!!!                    \"$$$$$$$$???>'''                                !\n!!!!!>                     `\"\"\"\"\"                                        `\n!!!!!!;                       .                                          `\n!!!!!!!                       ?d.                                         \n!!!!!!!!                       $$c,                                       \n!!!!!!!!>                      ?$$$d.              .,c                    \n!!!!!!!!!                       $$$$$$$$$dc,.,,cc$$$$$                    \n!!!!!!!!!                  .,dcc$$$$$$$$$$$$$$$$$$$$$$                    \n!!!!!!!!!               .d$$$$$$$$$$$$$$$$$$$$$$$$$$$$                    \n!!!!!!!!!             ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$          .         \n!!!!!!!!!           ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$         !!         \n!!!!!!!!!         ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$        ,!'         \n!!!!!!!!>        c$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$.       !'          \n!!!!!!''       ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$>       '           \n!!!''         d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$>                   \n!'           ,$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$>             ..    \n            d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$'           ;!!!!''`\n            $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$       ,;;!'`'  .'' \n           <$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$>    ,;'`'  ,;       \n           `$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$   -'   ,;!!'        \n            \"?$$$$$$$$$$?$$$$$$$$$$$$$$$$$$$$$$$$$$$     .<!!!'''       <!\n         !>    \"\"??$$$?<?$$$$$$$$$$$$$$$$$$$$$$$$\"\"     ;!'''          !!!\n       ;!!!!;,      `\"''\"\"????$$$$$$$$$$$$$$$$\"\"   ,;-''               ',!\n      ;!!!!<!!!; .                `\"\"\"\"\"\"\"\"\"\"\"    `'                  ' ' \n      !!!! ;!!! ;!!!!>;,;, ..                  ' .                   '  ' \n     !!' ,;!!! ;'`!!!!!!!!;!!!!!;  .        >' .''                 ;      \n    !!' ;!!'!';! !! !!!!!!!!!!!!!  '         -'                           \n   <!!  !! `!;! `!' !!!!!!!!!!<!       .                                  \n   `!  ;!  ;!!! <' <!!!! `!!! <       !                                   \n  `;   !>  <!! ;'  !!!!'  !!';!     ;'                                    \n   !   !   !!! !   `!!!  ;!! !      '  '                                  \n  ;   `!  `!! ,'    !'   ;!'                                              \n      '   !`! !    <     !! <      '                                      \n           ! ;!        >;! ;>                                             \n             !'       ; !! '                                              \n          ' ;!        > ! '                                               \n            '                                                             "
            got: "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!>''''''<!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!'''''`             ``'!!!!!!!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!!!!!!''`          .....         `'!!!!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!!!'`      .      ;;;;;'            `'!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!'     .   '     .;;;;'                `!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!'      ;          `````                   `!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!        .,!!!!!!!!!,,.                       `!!!!!!!!!!!!\n!!!!!!!!!!!!!!!     .!!!!!!!!!!!!!!!!!!,                      `!!!!!!!!!!!\n!!!!!!!!!!!!!!    ,!!!!!!!!!!!!!!!!!!!!!!,                     `!!!!!!!!!!\n!!!!!!!!!!!!!    !!!!!!!!!!!!!!!!!!!!!!!!!;.                    `!!!!!!!!!\n!!!!!!!!!!!!    <!!!!!!!!!!!!!!!!!!!!!!!!!!;.                    `!!!!!!!!\n!!!!!!!!!!!     !!!!!!!!!!!!!!!!!!!!!!!!!!!!;;.                   !!!!!!!!\n!!!!!!!!!!'     !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!;.                   !!!!!!!\n!!!!!!!!!'     <!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!                   !!!!!!!\n!!!!!!!!'      `!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!                   `!!!!!!\n!!!!!!!!        !!!!!!!!!!!!!!!!!!  !!!!!!!!!!                      !!!!!!\n!!!!!!!         `!! .,.. !!!!!!    .,!!!                            !!!!!!\n!!!!!!!         .  !!    .!!!!   .,!!,      .,!!!.                  !!!!!!\n!!!!!!!!        <. !!!! <!!!!!   <!!!!!!!!!!!!!!!!                  !!!!!!\n!!!!!!!         !!!!!!!!!!!!!!   !!!!!!!!!!!!!!!!!                  `!!!!!\n!!!!!!         ,!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!                   `!!!!!\n!!!!!          `!!!!!!!!!!!!!!!<!!!!!!!!!!!!!!!!'                    !!!!!\n!!!!!          `!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!>                     !!!!!\n!!!!!           !!!!!!!!!!!!!!!!!`!!!!!!!!!!!!>'                     `!!!!\n!!!!!           `!!!!!!!!>!!!    ,!!!!!!!!!!>>'                       !!!!\n!!!!!.           <<!!!!!!!!.    ,!!!!!!!!!!>>''                       `!!!\n!!!!!!            <!!!!!!!!!!!!!!!!  ,!!!!!;>''                       `!!!\n!!!!!!             !!!!!!!!!!!!!! !!!!!!!!!>>'                         !!!\n!!!!!              `!!!!!!!!!!!!  `!!!!!!>>>''                         `!!\n!!!!!                !!!!!!!!!!!!!!!!!!!>>>>'                           !!\n!!!!>                  !!!!!!!!!!!!!!!>>>>''                            `!\n!!!!!                    !!!!!!!!!!!!>'''                                !\n!!!!!>                     `!!!!!                                        `\n!!!!!!;                       .                                          `\n!!!!!!!                       !!.                                         \n!!!!!!!!                       !!!,                                       \n!!!!!!!!>                      !!!!!.              .,!                    \n!!!!!!!!!                       !!!!!!!!!!!,.,,!!!!!!!                    \n!!!!!!!!!                  .,!!!!!!!!!!!!!!!!!!!!!!!!!                    \n!!!!!!!!!               .!!!!!!!!!!!!!!!!!!!!!!!!!!!!!                    \n!!!!!!!!!             ,!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!          .         \n!!!!!!!!!           ,!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!         !!         \n!!!!!!!!!         ,!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!        ,!'         \n!!!!!!!!>        !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!.       !'          \n!!!!!!''       ,!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!>       '           \n!!!''         !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!>                   \n!'           ,!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!>             ..    \n            !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'           ;!!!!''`\n            !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!       ,;;!'`'  .'' \n           <!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!>    ,;'`'  ,;       \n           `!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!   !'   ,;!!'        \n            !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!     .<!!!'''       <!\n         !>    !!!!!!!!<!!!!!!!!!!!!!!!!!!!!!!!!!!!     ;!'''          !!!\n       ;!!!!;,      `!''!!!!!!!!!!!!!!!!!!!!!!!!   ,;!''               ',!\n      ;!!!!<!!!; .                `!!!!!!!!!!!    `'                  ' ' \n      !!!! ;!!! ;!!!!>;,;, ..                  ' .                   '  ' \n     !!' ,;!!! ;'`!!!!!!!!;!!!!!;  .        >' .''                 ;      \n    !!' ;!!'!';! !! !!!!!!!!!!!!!  '         !'                           \n   <!!  !! `!;! `!' !!!!!!!!!!<!       .                                  \n   `!  ;!  ;!!! <' <!!!! `!!! <       !                                   \n  `;   !>  <!! ;'  !!!!'  !!';!     ;'                                    \n   !   !   !!! !   `!!!  ;!! !      '  '                                  \n  ;   `!  `!! ,'    !'   ;!'                                              \n      '   !`! !    <     !! <      '                                      \n           ! ;!        >;! ;>                                             \n             !'       ; !! '                                              \n          ' ;!        > ! '                                               \n            '                                                             "
       
       (compared using ==)
       
       Diff:
       
       
       @@ -6,58 +6,58 @@
        !!!!!!!!!!!!!!!!!!!!!'`      .      ;;;;;'            `'!!!!!!!!!!!!!!!!!!
        !!!!!!!!!!!!!!!!!!!'     .   '     .;;;;'                `!!!!!!!!!!!!!!!!
        !!!!!!!!!!!!!!!!!'      ;          `````                   `!!!!!!!!!!!!!!
       -!!!!!!!!!!!!!!!!        .,ccdcccccc,,.                       `!!!!!!!!!!!!
       -!!!!!!!!!!!!!!!     .-"?$$$$$$$$$$$$$$c,                      `!!!!!!!!!!!
       -!!!!!!!!!!!!!!    ,ccc$$$$$$$$$$$$$$$$$$$,                     `!!!!!!!!!!
       -!!!!!!!!!!!!!    d$$$$$$$$$$$$$$$$$$$$$$$$;.                    `!!!!!!!!!
       -!!!!!!!!!!!!    <$$$$$$$$$$$$$$$$$$$$$$$$$$;.                    `!!!!!!!!
       -!!!!!!!!!!!     $$$$$$$$$$$$$$$$$$$$$$$$$$$d;;.                   !!!!!!!!
       -!!!!!!!!!!'     $$$$$$$$$$$$$$$$$$$$$$$$$$$$$d;.                   !!!!!!!
       -!!!!!!!!!'     <$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$                   !!!!!!!
       -!!!!!!!!'      `$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$                   `!!!!!!
       -!!!!!!!!        c$$$$???$$$$$$$d""  """??????"                      !!!!!!
       -!!!!!!!         `"" .,.. "$$$$$    .,dcd                            !!!!!!
       -!!!!!!!         .  d!    .?$$$   .,cc,      .,d$d.                  !!!!!!
       -!!!!!!!!        <. $$c- <$d$$$   <$$$$---$"$$$$$$$                  !!!!!!
       -!!!!!!!         d$$$dcccd$$$$$   d$$$dcccd$$$$$$$$                  `!!!!!
       -!!!!!!         ,$$$$$$$$$$$$$$d d$$$$$$$$$$$$$$$$                   `!!!!!
       -!!!!!          `$$$$$$$$$$$$$$$<$$$$$$$$$$$$$$$$'                    !!!!!
       -!!!!!          `$$$$$$$$$$$$$$$$"$$$$$$$$$$$$$d>                     !!!!!
       -!!!!!           ?$$$$$$$$$$$$??$c`$$$$$$$$$$$?>'                     `!!!!
       -!!!!!           `?$$$$$$!>?""    ,$$$$$$$$$?>>'                       !!!!
       -!!!!!.           <<?$$$$$$c.    ,d$$?$$$$$$>>''                       `!!!
       -!!!!!!            <!?$d"??$$d--"?""  ,$$$$d;>''                       `!!!
       -!!!!!!             $$$dccccccccc- cc$$$$$$$>>'                         !!!
       -!!!!!              `?$$$$$$$""""  `"$$$$$>>>''                         `!!
       -!!!!!                "?$$$$$cccccc$$$$??>>>>'                           !!
       -!!!!>                  "$$$$$$$$$$$$$$>>>>''                            `!
       -!!!!!                    "$$$$$$$$???>'''                                !
       -!!!!!>                     `"""""                                        `
       +!!!!!!!!!!!!!!!!        .,!!!!!!!!!,,.                       `!!!!!!!!!!!!
       +!!!!!!!!!!!!!!!     .!!!!!!!!!!!!!!!!!!,                      `!!!!!!!!!!!
       +!!!!!!!!!!!!!!    ,!!!!!!!!!!!!!!!!!!!!!!,                     `!!!!!!!!!!
       +!!!!!!!!!!!!!    !!!!!!!!!!!!!!!!!!!!!!!!!;.                    `!!!!!!!!!
       +!!!!!!!!!!!!    <!!!!!!!!!!!!!!!!!!!!!!!!!!;.                    `!!!!!!!!
       +!!!!!!!!!!!     !!!!!!!!!!!!!!!!!!!!!!!!!!!!;;.                   !!!!!!!!
       +!!!!!!!!!!'     !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!;.                   !!!!!!!
       +!!!!!!!!!'     <!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!                   !!!!!!!
       +!!!!!!!!'      `!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!                   `!!!!!!
       +!!!!!!!!        !!!!!!!!!!!!!!!!!!  !!!!!!!!!!                      !!!!!!
       +!!!!!!!         `!! .,.. !!!!!!    .,!!!                            !!!!!!
       +!!!!!!!         .  !!    .!!!!   .,!!,      .,!!!.                  !!!!!!
       +!!!!!!!!        <. !!!! <!!!!!   <!!!!!!!!!!!!!!!!                  !!!!!!
       +!!!!!!!         !!!!!!!!!!!!!!   !!!!!!!!!!!!!!!!!                  `!!!!!
       +!!!!!!         ,!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!                   `!!!!!
       +!!!!!          `!!!!!!!!!!!!!!!<!!!!!!!!!!!!!!!!'                    !!!!!
       +!!!!!          `!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!>                     !!!!!
       +!!!!!           !!!!!!!!!!!!!!!!!`!!!!!!!!!!!!>'                     `!!!!
       +!!!!!           `!!!!!!!!>!!!    ,!!!!!!!!!!>>'                       !!!!
       +!!!!!.           <<!!!!!!!!.    ,!!!!!!!!!!>>''                       `!!!
       +!!!!!!            <!!!!!!!!!!!!!!!!  ,!!!!!;>''                       `!!!
       +!!!!!!             !!!!!!!!!!!!!! !!!!!!!!!>>'                         !!!
       +!!!!!              `!!!!!!!!!!!!  `!!!!!!>>>''                         `!!
       +!!!!!                !!!!!!!!!!!!!!!!!!!>>>>'                           !!
       +!!!!>                  !!!!!!!!!!!!!!!>>>>''                            `!
       +!!!!!                    !!!!!!!!!!!!>'''                                !
       +!!!!!>                     `!!!!!                                        `
        !!!!!!;                       .                                          `
       -!!!!!!!                       ?d.                                         
       -!!!!!!!!                       $$c,                                       
       -!!!!!!!!>                      ?$$$d.              .,c                    
       -!!!!!!!!!                       $$$$$$$$$dc,.,,cc$$$$$                    
       -!!!!!!!!!                  .,dcc$$$$$$$$$$$$$$$$$$$$$$                    
       -!!!!!!!!!               .d$$$$$$$$$$$$$$$$$$$$$$$$$$$$                    
       -!!!!!!!!!             ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$          .         
       -!!!!!!!!!           ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$         !!         
       -!!!!!!!!!         ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$        ,!'         
       -!!!!!!!!>        c$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$.       !'          
       -!!!!!!''       ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$>       '           
       -!!!''         d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$>                   
       -!'           ,$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$>             ..    
       -            d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$'           ;!!!!''`
       -            $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$       ,;;!'`'  .'' 
       -           <$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$>    ,;'`'  ,;       
       -           `$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$   -'   ,;!!'        
       -            "?$$$$$$$$$$?$$$$$$$$$$$$$$$$$$$$$$$$$$$     .<!!!'''       <!
       -         !>    ""??$$$?<?$$$$$$$$$$$$$$$$$$$$$$$$""     ;!'''          !!!
       -       ;!!!!;,      `"''""????$$$$$$$$$$$$$$$$""   ,;-''               ',!
       -      ;!!!!<!!!; .                `"""""""""""    `'                  ' ' 
       +!!!!!!!                       !!.                                         
       +!!!!!!!!                       !!!,                                       
       +!!!!!!!!>                      !!!!!.              .,!                    
       +!!!!!!!!!                       !!!!!!!!!!!,.,,!!!!!!!                    
       +!!!!!!!!!                  .,!!!!!!!!!!!!!!!!!!!!!!!!!                    
       +!!!!!!!!!               .!!!!!!!!!!!!!!!!!!!!!!!!!!!!!                    
       +!!!!!!!!!             ,!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!          .         
       +!!!!!!!!!           ,!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!         !!         
       +!!!!!!!!!         ,!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!        ,!'         
       +!!!!!!!!>        !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!.       !'          
       +!!!!!!''       ,!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!>       '           
       +!!!''         !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!>                   
       +!'           ,!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!>             ..    
       +            !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'           ;!!!!''`
       +            !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!       ,;;!'`'  .'' 
       +           <!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!>    ,;'`'  ,;       
       +           `!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!   !'   ,;!!'        
       +            !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!     .<!!!'''       <!
       +         !>    !!!!!!!!<!!!!!!!!!!!!!!!!!!!!!!!!!!!     ;!'''          !!!
       +       ;!!!!;,      `!''!!!!!!!!!!!!!!!!!!!!!!!!   ,;!''               ',!
       +      ;!!!!<!!!; .                `!!!!!!!!!!!    `'                  ' ' 
              !!!! ;!!! ;!!!!>;,;, ..                  ' .                   '  ' 
             !!' ,;!!! ;'`!!!!!!!!;!!!!!;  .        >' .''                 ;      
       -    !!' ;!!'!';! !! !!!!!!!!!!!!!  '         -'                           
       +    !!' ;!!'!';! !! !!!!!!!!!!!!!  '         !'                           
           <!!  !! `!;! `!' !!!!!!!!!!<!       .                                  
           `!  ;!  ;!!! <' <!!!! `!!! <       !                                   
          `;   !>  <!! ;'  !!!!'  !!';!     ;'                                    
     # /tmp/d20131110-20795-1g32t7r/spec.rb:105:in `block (2 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

Finished in 0.03782 seconds
5 examples, 1 failure

Failed examples:

rspec /tmp/d20131110-20795-1g32t7r/spec.rb:31 # Bitmap renders La Gioconda
Цани Проданов
  • Коректно
  • 5 успешни тест(а)
  • 0 неуспешни тест(а)
Цани Проданов
class Bitmap
attr_accessor :bitmap_enum
def initialize(numbers_array, bytes_per_row = 0)
bytes_per_row = numbers_array.length if bytes_per_row == 0
@bitmap_enum = numbers_array.each_slice(bytes_per_row)
end
def render palette = ['.', '#']
bits_per_pixel = Math::log2(palette.length).to_i
sub_bits_regex = /\d{#{bits_per_pixel}}/
#Don't hate me because I'm beautiful
bitmap_enum.reduce(""){|rendered, line_byte_array| rendered += line_byte_array.reduce(""){|bitstring, byte| bitstring += "%08d"%byte.to_s(2)}.gsub(sub_bits_regex){|palette_index| palette[palette_index.to_i(2)]} + "\n"}.chomp
#We can reduce to a bitmap in the initialize method
#(thus gaining some performance on bitmaps
# that get drawn with different palettes),
#but I already did it this way and I can't be bothered
end
end
.....

Finished in 0.03636 seconds
5 examples, 0 failures
Ангел Цанев
  • Коректно
  • 5 успешни тест(а)
  • 0 неуспешни тест(а)
Ангел Цанев
class Bitmap
attr_reader :bytes, :bytes_on_row, :palette
def initialize(bytes, bytes_on_row = bytes.size)
@bytes, @bytes_on_row = bytes, bytes_on_row
end
def render(palette = ['.','#'])
@palette = palette
bytes_string = ""
@bytes.each{ |byte| bytes_string << ("%08d" % byte.to_s(2)) }
number_of_bits_to_read = (@palette.size - 1).to_s(2).size
binary_array = bytes_string.scan(/.{#{number_of_bits_to_read}}/)
result = ''
binary_array.each{ |elem| result << palette[Integer("0b" + elem)] }
step = 8 / number_of_bits_to_read * @bytes_on_row
result = result.scan(/.{#{step}}|.+/).join("\n")
end
end
.....

Finished in 0.03693 seconds
5 examples, 0 failures
Давид Петров
  • Коректно
  • 5 успешни тест(а)
  • 0 неуспешни тест(а)
Давид Петров
class Bitmap
def initialize(byte_list,rows=byte_list.size)
@byte_list=byte_list
@rows=rows
end
def render(palette=['.','#'])
hex_hash={'a'=> 10,'b'=> 11,'c'=> 12, 'd'=> 13 ,'e'=> 14,'f'=> 15}
bitmap=@byte_list.map {|b| b.to_s(palette.size).chars.map {|x| hex_hash.has_key?(x) ? hex_hash[x] : x.to_i}}
bitmap=bitmap.map{|b| b=Array.new(8/Math.log2(palette.size)-b.size,0)+b}.map{|b| b.map{|x| palette[x]}}
bitmap.each_with_index.map { |b, i| (i+1)%@rows==0 ? b<<"\n" : b}.map{|b| b.join}.join.chomp
end
end
.....

Finished in 0.04009 seconds
5 examples, 0 failures
Антонио Николов
  • Коректно
  • 5 успешни тест(а)
  • 0 неуспешни тест(а)
Антонио Николов
class Bitmap
def initialize(bytes, bytes_in_line = nil)
@bytes = bytes.reduce("") { |matrix, byte| matrix + "0"*(8 - byte.to_s(2).length) + byte.to_s(2) }
@bytes_in_line = bytes_in_line
end
def render(palette = ['.', '#'])
separeted_colors = @bytes.chars.each_slice(Math.sqrt(palette.size).to_i).map(&:join).map { |color| palette[color.to_i(2)] }
if @bytes_in_line then
separeted_colors.each_slice((8 / Math.sqrt(palette.size).to_i) * @bytes_in_line).map { |byte| byte.join + "\n" }.join.chomp
else
separeted_colors.reduce(&:+)
end
end
end
.....

Finished in 0.11097 seconds
5 examples, 0 failures
Христо Хърсев
  • Коректно
  • 5 успешни тест(а)
  • 0 неуспешни тест(а)
Христо Хърсев
class Bitmap
def initialize(numbers, bytes_per_line=numbers.size)
@bits = numbers.map { |number| number.to_s(2).rjust(8, '0') }
@bytes_per_line = bytes_per_line
end
def render(palette=['.', '#'])
transform_map = transform_map palette
mapped_bits = Math::log(palette.size, 2).to_i
rendered_bits = @bits.map { |byte| byte.gsub(/(1|0){#{mapped_bits}}/, transform_map) }
new_lines = (1...@bits.size).map { |x| x % @bytes_per_line == 0 ? ["\n"] : [""] }
rendered_bits.zip(new_lines << '').flatten.join
end
private
def transform_map(palette)
transform_map = {}
0.upto(palette.size - 1).each do |digit|
mapped_bits = digit.to_s(2).rjust(Math::log(palette.size, 2), '0')
transform_map[mapped_bits] = palette[digit]
end
transform_map
end
end
.....

Finished in 0.09234 seconds
5 examples, 0 failures
Ясен Трифонов
  • Коректно
  • 5 успешни тест(а)
  • 0 неуспешни тест(а)
Ясен Трифонов
#!/usr/local/bin/ruby -w
class Bitmap
def initialize(bytes, bytes_per_row = 999999)
@bytes = bytes
@bytes_per_row = bytes_per_row
end
def render(colors = ['.', '#'])
bits_per_symbol = (colors.size - 1).to_s(2).size
image = ''
step = 0
@bytes.each { |byte|
image_for_byte = ''
byte.to_s(2).rjust(8, '0').each_char.each_slice(bits_per_symbol) { |slice|
image_for_byte += colors[ slice.reduce(&:+).to_i(2) ]
}
image += image_for_byte
image += "\n" if (step += 1) % @bytes_per_row == 0
}
image.chomp
end
end
.....

Finished in 0.08515 seconds
5 examples, 0 failures
Красимира Божанова
  • Коректно
  • 5 успешни тест(а)
  • 0 неуспешни тест(а)
Красимира Божанова
class Bitmap
def initialize(array, lines = array.size)
@bytes = array.map { |number| number.to_s(2).rjust(8, '0') }.join
@lines = lines
end
def render(palette = nil)
palette ||= ['.', '#']
slice_length = Math.sqrt(palette.size).floor
new_symbols = split(slice_length).map { |group| palette.at group.to_i(2) }
new_symbols.each_slice(@lines * 8 / slice_length).map(&:join).join("\n")
end
def split(length)
@bytes.chars.each_slice(length).map(&:join)
end
private :split
end
.....

Finished in 0.04074 seconds
5 examples, 0 failures
Любомир Георгиев
  • Коректно
  • 5 успешни тест(а)
  • 0 неуспешни тест(а)
Любомир Георгиев
class Bitmap
attr_accessor :bytes_list
attr_accessor :bytes_per_line
def initialize(bytes_list, bytes_per_line = 0)
@bytes_list = bytes_list
@bytes_per_line = bytes_per_line == 0 ? bytes_list.size : bytes_per_line
end
def render(palette = ['.', '#'])
pixels = ""
binary_list = @bytes_list.map { |n| "%08d" % n.to_s(2) }.each_slice(@bytes_per_line).to_a
binary_list.each_with_index do |byte, i|
pixels += "\n" if i > 0
color_size = Math.sqrt(palette.size).to_i
colors = byte.reduce("", :+).scan(/.{#{color_size}}/).map { |c| palette[c.to_i(2)] }.reduce("", :+)
pixels +=colors
end
pixels
end
end
.....

Finished in 0.04303 seconds
5 examples, 0 failures
Кристиан Ташков
  • Некоректно
  • 4 успешни тест(а)
  • 1 неуспешни тест(а)
Кристиан Ташков
class Bitmap
def initialize(bytes, rows = 1)
@bytes = bytes
@rows = rows
end
def render(colors = ['.', '#'])
per_row = @rows * 8 / Math.log2(colors.size)
bitmap = @bytes.map { |byte| byte.to_s(2) }.map { |byte| ('0' * (8 - byte.size) + byte).chars}.flatten
bitmap = bitmap.each_slice(Math.log2(colors.size)).map { |color| colors[color.join.to_i(2)] }.join
bitmap.chars.each_slice(per_row).to_a.map(&:join).join("\n")
end
end
F....

Failures:

  1) Bitmap renders bytes
     Failure/Error: expect(Bitmap.new([9, 32, 7]).render).to eq <<-ASCII.strip
       
       expected: "....#..#..#..........###"
            got: "....#..#\n..#.....\n.....###"
       
       (compared using ==)
       
       Diff:
       @@ -1,2 +1,4 @@
       -....#..#..#..........###
       +....#..#
       +..#.....
       +.....###
     # /tmp/d20131110-20795-ac9ykq/spec.rb:3:in `block (2 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

Finished in 0.06173 seconds
5 examples, 1 failure

Failed examples:

rspec /tmp/d20131110-20795-ac9ykq/spec.rb:2 # Bitmap renders bytes
Валентин Ейткен
  • Некоректно
  • 2 успешни тест(а)
  • 3 неуспешни тест(а)
Валентин Ейткен
class Bitmap
def initialize(bitmap, rows = bit_array.length)
@bitmap, @rows = bitmap, rows
end
def render(palette = ['.', '#'])
@bitmap.each_slice(@rows).map do |bytes|
bytes.map do |byte|
bits = Math.log(256, palette.length).to_i
bits = bits == 8 ? 1 : bits
("%08b" % byte).chars.each_slice(bits).to_a.map do |number|
palette[number.join.to_i(2)]
end.join
end.join
end.join "\n"
end
end
F..FF

Failures:

  1) Bitmap renders bytes
     Failure/Error: expect(Bitmap.new([9, 32, 7]).render).to eq <<-ASCII.strip
     NameError:
       undefined local variable or method `bit_array' for #<Bitmap:0xb87aeec4>
     # /tmp/d20131110-20795-1mfbg64/solution.rb:2:in `initialize'
     # /tmp/d20131110-20795-1mfbg64/spec.rb:3:in `new'
     # /tmp/d20131110-20795-1mfbg64/spec.rb:3:in `block (2 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  2) Bitmap supports different palettes
     Failure/Error: expect(Bitmap.new([13, 2, 5, 1], 2).render(%w(. * x #))).to eq <<-ASCII.strip
       
       expected: "..#*...x\n..**...*"
            got: "..x\n..*"
       
       (compared using ==)
       
       Diff:
       @@ -1,3 +1,3 @@
       -..#*...x
       -..**...*
       +..x
       +..*
     # /tmp/d20131110-20795-1mfbg64/spec.rb:25:in `block (2 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  3) Bitmap renders La Gioconda
     Failure/Error: Bitmap.new(the_bitmap, 37).render(["!", "\n", ">", "'", "<", "`", " ", ".", ";", ",", "c", "d", "-", "\"", "?", "$"]).should eq expectation
       
       expected: "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!>''''''<!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!'''''`             ``'!!!!!!!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!!!!!!''`          .....         `'!!!!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!!!'`      .      ;;;;;'            `'!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!'     .   '     .;;;;'                `!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!'      ;          `````                   `!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!        .,ccdcccccc,,.                       `!!!!!!!!!!!!\n!!!!!!!!!!!!!!!     .-\"?$$$$$$$$$$$$$$c,                      `!!!!!!!!!!!\n!!!!!!!!!!!!!!    ,ccc$$$$$$$$$$$$$$$$$$$,                     `!!!!!!!!!!\n!!!!!!!!!!!!!    d$$$$$$$$$$$$$$$$$$$$$$$$;.                    `!!!!!!!!!\n!!!!!!!!!!!!    <$$$$$$$$$$$$$$$$$$$$$$$$$$;.                    `!!!!!!!!\n!!!!!!!!!!!     $$$$$$$$$$$$$$$$$$$$$$$$$$$d;;.                   !!!!!!!!\n!!!!!!!!!!'     $$$$$$$$$$$$$$$$$$$$$$$$$$$$$d;.                   !!!!!!!\n!!!!!!!!!'     <$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$                   !!!!!!!\n!!!!!!!!'      `$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$                   `!!!!!!\n!!!!!!!!        c$$$$???$$$$$$$d\"\"  \"\"\"??????\"                      !!!!!!\n!!!!!!!         `\"\" .,.. \"$$$$$    .,dcd                            !!!!!!\n!!!!!!!         .  d!    .?$$$   .,cc,      .,d$d.                  !!!!!!\n!!!!!!!!        <. $$c- <$d$$$   <$$$$---$\"$$$$$$$                  !!!!!!\n!!!!!!!         d$$$dcccd$$$$$   d$$$dcccd$$$$$$$$                  `!!!!!\n!!!!!!         ,$$$$$$$$$$$$$$d d$$$$$$$$$$$$$$$$                   `!!!!!\n!!!!!          `$$$$$$$$$$$$$$$<$$$$$$$$$$$$$$$$'                    !!!!!\n!!!!!          `$$$$$$$$$$$$$$$$\"$$$$$$$$$$$$$d>                     !!!!!\n!!!!!           ?$$$$$$$$$$$$??$c`$$$$$$$$$$$?>'                     `!!!!\n!!!!!           `?$$$$$$!>?\"\"    ,$$$$$$$$$?>>'                       !!!!\n!!!!!.           <<?$$$$$$c.    ,d$$?$$$$$$>>''                       `!!!\n!!!!!!            <!?$d\"??$$d--\"?\"\"  ,$$$$d;>''                       `!!!\n!!!!!!             $$$dccccccccc- cc$$$$$$$>>'                         !!!\n!!!!!              `?$$$$$$$\"\"\"\"  `\"$$$$$>>>''                         `!!\n!!!!!                \"?$$$$$cccccc$$$$??>>>>'                           !!\n!!!!>                  \"$$$$$$$$$$$$$$>>>>''                            `!\n!!!!!                    \"$$$$$$$$???>'''                                !\n!!!!!>                     `\"\"\"\"\"                                        `\n!!!!!!;                       .                                          `\n!!!!!!!                       ?d.                                         \n!!!!!!!!                       $$c,                                       \n!!!!!!!!>                      ?$$$d.              .,c                    \n!!!!!!!!!                       $$$$$$$$$dc,.,,cc$$$$$                    \n!!!!!!!!!                  .,dcc$$$$$$$$$$$$$$$$$$$$$$                    \n!!!!!!!!!               .d$$$$$$$$$$$$$$$$$$$$$$$$$$$$                    \n!!!!!!!!!             ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$          .         \n!!!!!!!!!           ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$         !!         \n!!!!!!!!!         ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$        ,!'         \n!!!!!!!!>        c$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$.       !'          \n!!!!!!''       ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$>       '           \n!!!''         d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$>                   \n!'           ,$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$>             ..    \n            d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$'           ;!!!!''`\n            $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$       ,;;!'`'  .'' \n           <$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$>    ,;'`'  ,;       \n           `$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$   -'   ,;!!'        \n            \"?$$$$$$$$$$?$$$$$$$$$$$$$$$$$$$$$$$$$$$     .<!!!'''       <!\n         !>    \"\"??$$$?<?$$$$$$$$$$$$$$$$$$$$$$$$\"\"     ;!'''          !!!\n       ;!!!!;,      `\"''\"\"????$$$$$$$$$$$$$$$$\"\"   ,;-''               ',!\n      ;!!!!<!!!; .                `\"\"\"\"\"\"\"\"\"\"\"    `'                  ' ' \n      !!!! ;!!! ;!!!!>;,;, ..                  ' .                   '  ' \n     !!' ,;!!! ;'`!!!!!!!!;!!!!!;  .        >' .''                 ;      \n    !!' ;!!'!';! !! !!!!!!!!!!!!!  '         -'                           \n   <!!  !! `!;! `!' !!!!!!!!!!<!       .                                  \n   `!  ;!  ;!!! <' <!!!! `!!! <       !                                   \n  `;   !>  <!! ;'  !!!!'  !!';!     ;'                                    \n   !   !   !!! !   `!!!  ;!! !      '  '                                  \n  ;   `!  `!! ,'    !'   ;!'                                              \n      '   !`! !    <     !! <      '                                      \n           ! ;!        >;! ;>                                             \n             !'       ; !! '                                              \n          ' ;!        > ! '                                               \n            '                                                             "
            got: "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!>!'!'!'!'!'!'\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'!'!'!'!'\n\n\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n\n\n\n!'!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'!'\n\n\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n'\n'\n'\n'\n'\n>\n>\n>\n>\n>\n>\n>\n>\n>\n\n!'!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'\n\n\n>\n>\n>\n>\n>\n>\n'\n>\n>\n>\n>\n>\n>>!>!>!>!>!!'\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n\n!'!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'\n>\n>\n>\n>\n>\n'\n>\n>\n>!'\n>\n>\n>\n>\n>\n'>!>!>!>!!'\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'\n>\n>\n>\n>\n>\n>>!\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n\n\n\n\n\n\n\n\n\n\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n>\n>\n>\n>\n>\n>\n>\n>\n'>\n>>>>>'>>>>>>>>>>>>>\n>\n\n'\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n\n!!!!!!!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n>\n>\n>\n>\n>\n''!'\n'>''''''''''''''''''''''''''''>>>\n\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n\n!!!!!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n>\n>\n>\n>>\n>>>>>>''''''''''''''''''''''''''''''''''''''>\n\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n\n!!!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!!!!!!!!\n>\n>\n>\n>>'''''''''''''''''''''''''''''''''''''''''''''''''>!\n'\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n\n!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!!!!!!\n>\n>\n>\n>\n!''''''''''''''''''''''''''''''''''''''''''''''''''''>!\n'\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n\n!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!!!!\n>\n>\n>\n>\n>''''''''''''''''''''''''''''''''''''''''''''''''''''''>'>!>!\n'\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!!!'\n>\n>\n>\n>\n>''''''''''''''''''''''''''''''''''''''''''''''''''''''''''>'>!\n'\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!'\n>\n>\n>\n>\n>\n!''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!'\n>\n>\n>\n>\n>\n>\n\n''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n\n!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!\n>\n>\n>\n>\n>\n>\n>\n>>>'''''''''>'>'>''''''''''''''>''\n'\n\n>\n>'\n'\n'\n'>'>'>'>'>'>'\n\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>!!!!!!!!!!!!\n!!!!!!!!!!!!!!\n>\n>\n>\n>\n>\n>\n>\n>\n>\n\n'\n'\n\n>\n'>\n\n'\n'\n>'\n''''''''''\n>\n>\n>\n>\n'>\n>'>>>'\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>!!!!!!!!!!!!\n!!!!!!!!!!!!!!\n>\n>\n>\n>\n>\n>\n>\n>\n>\n'\n>\n>>'!!\n>\n>\n>\n>\n''>''''''\n>\n>\n>\n'>\n>>>>>\n\n>\n>\n>\n>\n>\n>\n'>\n>'''>'\n'\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!\n>\n>\n>\n>\n>\n>\n>\n>\n!\n'\n>''''>>'!\n>\n!''>'''''''\n>\n>\n>\n!'''''''''!'!'!'''\n''''''''''''''\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>!!!!!!!!!!!!\n!!!!!!!!!!!!!!\n>\n>\n>\n>\n>\n>\n>\n>\n>>'''''''>'>>>>>>>'''''''''''\n>\n>\n>>'''''''>'>>>>>>>'''''''''''''''''\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n\n!!!!!!!!!!\n!!!!!!!!!!!!\n>\n>\n>\n>\n>\n>\n>\n>\n>>\n''''''''''''''''''''''''''''>'\n>>'''''''''''''''''''''''''''''''''\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n\n!!!!!!!!!!\n!!!!!!!!!!\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n\n''''''''''''''''''''''''''''''\n!''''''''''''''''''''''''''''''''!'\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>!!!!!!!!!!\n!!!!!!!!!!\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n\n'''''''''''''''''''''''''''''''''\n''''''''''''''''''''''''''>'!>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>!!!!!!!!!!\n!!!!!!!!!!\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>'>'''''''''''''''''''''''''>'>''>>\n\n'''''''''''''''''''''''>!>!'\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n\n!!!!!!!!\n!!!!!!!!!!\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n\n'>''''''''''''!!!>'>'\n'\n\n>\n>\n>\n>>\n'''''''''''''''''''>!>!>!'\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>!!!!!!!!\n!!!!!!!!!!\n'\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n!\n!'>''''''''''''>>\n'\n>\n>\n>\n>>\n>''''''>''''''''''''!>!>!'!'\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n\n!!!!!!\n!!!!!!!!!!!!\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n!!!'>''>''\n'>'>''''>''!'!'\n'>'\n'\n\n>\n>>\n''''''''>'>!!>!'!'\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n\n!!!!!!\n!!!!!!!!!!!!\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>''''''>'>>>>>>>>>>>>>>>>>>'!\n>>>>>''''''''''''''!>!>!'\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>!!!!!!\n!!!!!!!!!!\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n\n'>'''''''''''''''\n'\n'\n'\n\n>\n>\n\n'\n''''''''''!>!>!>!'!'\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n\n!!!!\n!!!!!!!!!!\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>'\n'>''''''''''>>>>>>>>>>>>'''''''''>'>!>!>!>!>!'\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>!!!!\n!!!!!!!!!>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>'\n''''''''''''''''''''''''''''!>!>!>!>!'!'\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n\n!!\n!!!!!!!!!!\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>'\n'''''''''''''''''>'>'>!>!'!'!'\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>!!\n!!!!!!!!!!!>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n\n'\n'\n'\n'\n'\n\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n\n\n!!!!!!!!!!!!>!\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n'\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n\n\n!!!!!!!!!!!!!!\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>'>>'\n'\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n!!!!!!!!!!!!!!!!\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>''''>>>\n\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n!!!!!!!!!!!!!!!!!>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>'>''''''>'\n'\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n'>\n>>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n!!!!!!!!!!!!!!!!!!\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>''''''''''''''''''>'>>>\n\n'>\n>\n>>>>''''''''''\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n!!!!!!!!!!!!!!!!!!\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n'>\n>'>>>>''''''''''''''''''''''''''''''''''''''''''''\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n!!!!!!!!!!!!!!!!!!\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n'>'''''''''''''''''''''''''''''''''''''''''''''''''''''''''\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n!!!!!!!!!!!!!!!!!!\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>>\n>'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n'\n>\n>\n>\n>\n>\n>\n>\n>\n>\n!!!!!!!!!!!!!!!!!!\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>>\n>'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''\n>\n>\n>\n>\n>\n>\n>\n>\n>!!!!\n>\n>\n>\n>\n>\n>\n>\n>\n>\n!!!!!!!!!!!!!!!!!!\n>\n>\n>\n>\n>\n>\n>\n>\n>>\n>'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''\n>\n>\n>\n>\n>\n>\n>\n>>\n!!!'\n>\n>\n>\n>\n>\n>\n>\n>\n>\n!!!!!!!!!!!!!!!!!>\n>\n>\n>\n>\n>\n>\n>\n>>>''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''\n'\n>\n>\n>\n>\n>\n>\n>!!!'\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n!!!!!!!!!!!!!'!'\n>\n>\n>\n>\n>\n>\n>>\n>'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''!>\n>\n>\n>\n>\n>\n>\n>!'\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n!!!!!!!'!'\n>\n>\n>\n>\n>\n>\n>\n>\n>>'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''!>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n!!!'\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>>\n''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''!>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n'\n'\n>\n>\n>\n>\n\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>>'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''!'\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>>!!!!!!!!!!'!'\n\n\n\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''\n>\n>\n>\n>\n>\n>\n>>\n>!>!!!!'\n\n!'\n>\n>\n'!'!'\n>\n\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n!''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''!>\n>\n>\n>\n>>\n>!!'\n\n!'\n>\n>>\n>!\n>\n>\n>\n>\n>\n>\n>\n\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n\n''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''\n>\n>\n>'!!'\n>\n>\n>>\n>!!!!!!'\n>\n>\n>\n>\n>\n>\n>\n>\n\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>'\n'>'''''''''''''''''''''>''''''''''''''''''''''''''''''''''''''''''''''''''''''\n>\n>\n>\n>\n>\n'\n!!!!!!!!'!'!'\n>\n>\n>\n>\n>\n>\n>\n!!!\n\n>\n>\n>\n>\n>\n>\n>\n>\n>!!!>\n>\n>\n>\n>'\n'\n'>'>'''''''>\n!'>'''''''''''''''''''''''''''''''''''''''''''''''''\n'\n\n>\n>\n>\n>\n>>!!!!'!'!'\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>!!!!!!\n\n>\n>\n>\n>\n>\n>\n>>!!!!!!!!!>!>\n\n>\n>\n>\n>\n>\n>\n\n'\n!'!''\n'\n'>'>'>'>'''''''''''''''''''''''''''''''''\n'\n\n>\n>\n>>\n>!'!!'!'\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>!'>\n!!\n\n>\n>\n>\n>\n>\n>>!!!!!!!!!\n!!!!!!!>!\n>\n'\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n\n'\n'\n'\n'\n'\n'\n'\n'\n'\n'\n'\n\n>\n>\n>\n>\n\n!'\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>!'\n>!'\n>\n\n>\n>\n>\n>\n>\n>!!!!!!!!\n>>!!!!!!!\n>>!!!!!!!!!!>>!>\n>!>\n\n>\n'\n'\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>!'\n>\n'\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>!'\n>\n>!'\n>\n\n>\n>\n>\n>\n>!!!!!'\n>>\n>!!!!!!!\n>>!!'\n\n!!!!!!!!!!!!!!!!>!!!!!!!!!!!>!\n>\n>\n'\n>\n>\n>\n>\n>\n>\n>\n>!>!'\n>\n'!'!'\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>>!\n>\n>\n>\n>\n>\n>\n\n>\n>\n>\n>!!!!!'\n>>!!!!!!'!!!'>!!!\n>!!!!\n>!!!!!!!!!!!!!!!!!!!!!!!!!!\n>\n>!'\n>\n>\n>\n>\n>\n>\n>\n>\n>'!!'\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n\n>\n>\n>\n!!!!!\n>\n>!!!!\n>\n\n!!>!!!\n>\n\n!!!'\n>!!!!!!!!!!!!!!!!!!!!\n!!!\n>\n>\n>\n>\n>\n>\n>\n'\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n\n>\n>\n>\n\n!!\n>\n>>!!!\n>\n>>!!!!!!!\n>\n!!'\n>\n!!!!!!!!!\n>\n\n!!!!!!\n>\n!\n>\n>\n>\n>\n>\n>\n>!!\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n\n>\n>\n\n>!\n>\n>\n>!!!>\n>\n>\n!!!!!\n>>!!'\n>\n>!!!!!!!!!'\n>\n>!!!!!'>!!!\n>\n>\n>\n>\n>>!!'\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n\n>\n>\n>!!\n>\n>\n>!!\n>\n>\n>!!!!!!\n>!!\n>\n>\n>\n\n!!!!!!\n>\n>>!!!!!\n>!!\n>\n>\n>\n>\n>\n>!'\n>\n>!'\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n\n>\n>>!\n>\n>\n>\n\n!!\n>\n>\n\n!!!!\n>>\n!'\n>\n>\n>\n>!!!'\n>\n>\n>>!!!!'\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n\n>\n>\n>\n>\n>\n>!'\n>\n>\n>!!\n\n!!\n>!!\n>\n>\n>\n>\n!\n>\n>\n>\n>\n>!!!!\n>\n!\n>\n>\n>\n>\n>\n>!'\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>!!\n>>!!!\n>\n>\n>\n>\n>\n>\n>\n>!>>!!!\n>>!!>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>!!!'\n>\n>\n>\n>\n>\n>\n>>!\n>!!!!\n>!'\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>!'\n>>!!!\n>\n>\n>\n>\n>\n>\n>\n>!>\n>!!\n>!'\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>!'\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>\n>"
       
       (compared using ==)
       
       Diff:
       @@ -1,71 +1,2913 @@
       -!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
       -!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
       -!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!>''''''<!!!!!!!!!!!!!!!!!!!!!!!!!!!!
       -!!!!!!!!!!!!!!!!!!!!!!!!!!!!'''''`             ``'!!!!!!!!!!!!!!!!!!!!!!!!
       -!!!!!!!!!!!!!!!!!!!!!!!!''`          .....         `'!!!!!!!!!!!!!!!!!!!!!
       -!!!!!!!!!!!!!!!!!!!!!'`      .      ;;;;;'            `'!!!!!!!!!!!!!!!!!!
       -!!!!!!!!!!!!!!!!!!!'     .   '     .;;;;'                `!!!!!!!!!!!!!!!!
       -!!!!!!!!!!!!!!!!!'      ;          `````                   `!!!!!!!!!!!!!!
       -!!!!!!!!!!!!!!!!        .,ccdcccccc,,.                       `!!!!!!!!!!!!
       -!!!!!!!!!!!!!!!     .-"?$$$$$$$$$$$$$$c,                      `!!!!!!!!!!!
       -!!!!!!!!!!!!!!    ,ccc$$$$$$$$$$$$$$$$$$$,                     `!!!!!!!!!!
       -!!!!!!!!!!!!!    d$$$$$$$$$$$$$$$$$$$$$$$$;.                    `!!!!!!!!!
       -!!!!!!!!!!!!    <$$$$$$$$$$$$$$$$$$$$$$$$$$;.                    `!!!!!!!!
       -!!!!!!!!!!!     $$$$$$$$$$$$$$$$$$$$$$$$$$$d;;.                   !!!!!!!!
       -!!!!!!!!!!'     $$$$$$$$$$$$$$$$$$$$$$$$$$$$$d;.                   !!!!!!!
       -!!!!!!!!!'     <$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$                   !!!!!!!
       -!!!!!!!!'      `$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$                   `!!!!!!
       -!!!!!!!!        c$$$$???$$$$$$$d""  """??????"                      !!!!!!
       -!!!!!!!         `"" .,.. "$$$$$    .,dcd                            !!!!!!
       -!!!!!!!         .  d!    .?$$$   .,cc,      .,d$d.                  !!!!!!
       -!!!!!!!!        <. $$c- <$d$$$   <$$$$---$"$$$$$$$                  !!!!!!
       -!!!!!!!         d$$$dcccd$$$$$   d$$$dcccd$$$$$$$$                  `!!!!!
       -!!!!!!         ,$$$$$$$$$$$$$$d d$$$$$$$$$$$$$$$$                   `!!!!!
       -!!!!!          `$$$$$$$$$$$$$$$<$$$$$$$$$$$$$$$$'                    !!!!!
       -!!!!!          `$$$$$$$$$$$$$$$$"$$$$$$$$$$$$$d>                     !!!!!
       -!!!!!           ?$$$$$$$$$$$$??$c`$$$$$$$$$$$?>'                     `!!!!
       -!!!!!           `?$$$$$$!>?""    ,$$$$$$$$$?>>'                       !!!!
       -!!!!!.           <<?$$$$$$c.    ,d$$?$$$$$$>>''                       `!!!
       -!!!!!!            <!?$d"??$$d--"?""  ,$$$$d;>''                       `!!!
       -!!!!!!             $$$dccccccccc- cc$$$$$$$>>'                         !!!
       -!!!!!              `?$$$$$$$""""  `"$$$$$>>>''                         `!!
       -!!!!!                "?$$$$$cccccc$$$$??>>>>'                           !!
       -!!!!>                  "$$$$$$$$$$$$$$>>>>''                            `!
       -!!!!!                    "$$$$$$$$???>'''                                !
       -!!!!!>                     `"""""                                        `
       -!!!!!!;                       .                                          `
       -!!!!!!!                       ?d.                                         
       -!!!!!!!!                       $$c,                                       
       -!!!!!!!!>                      ?$$$d.              .,c                    
       -!!!!!!!!!                       $$$$$$$$$dc,.,,cc$$$$$                    
       -!!!!!!!!!                  .,dcc$$$$$$$$$$$$$$$$$$$$$$                    
       -!!!!!!!!!               .d$$$$$$$$$$$$$$$$$$$$$$$$$$$$                    
       -!!!!!!!!!             ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$          .         
       -!!!!!!!!!           ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$         !!         
       -!!!!!!!!!         ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$        ,!'         
       -!!!!!!!!>        c$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$.       !'          
       -!!!!!!''       ,d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$>       '           
       -!!!''         d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$>                   
       -!'           ,$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$>             ..    
       -            d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$'           ;!!!!''`
       -            $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$       ,;;!'`'  .'' 
       -           <$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$>    ,;'`'  ,;       
       -           `$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$   -'   ,;!!'        
       -            "?$$$$$$$$$$?$$$$$$$$$$$$$$$$$$$$$$$$$$$     .<!!!'''       <!
       -         !>    ""??$$$?<?$$$$$$$$$$$$$$$$$$$$$$$$""     ;!'''          !!!
       -       ;!!!!;,      `"''""????$$$$$$$$$$$$$$$$""   ,;-''               ',!
       -      ;!!!!<!!!; .                `"""""""""""    `'                  ' ' 
       -      !!!! ;!!! ;!!!!>;,;, ..                  ' .                   '  ' 
       -     !!' ,;!!! ;'`!!!!!!!!;!!!!!;  .        >' .''                 ;      
       -    !!' ;!!'!';! !! !!!!!!!!!!!!!  '         -'                           
       -   <!!  !! `!;! `!' !!!!!!!!!!<!       .                                  
       -   `!  ;!  ;!!! <' <!!!! `!!! <       !                                   
       -  `;   !>  <!! ;'  !!!!'  !!';!     ;'                                    
       -   !   !   !!! !   `!!!  ;!! !      '  '                                  
       -  ;   `!  `!! ,'    !'   ;!'                                              
       -      '   !`! !    <     !! <      '                                      
       -           ! ;!        >;! ;>                                             
       -             !'       ; !! '                                              
       -          ' ;!        > ! '                                               
       -            '                                                             
       +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
       +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
       +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!>!'!'!'!'!'!'
       +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
       +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'!'!'!'!'
       +
       +
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +
       +
       +
       +!'!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
       +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'!'
       +
       +
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +'
       +'
       +'
       +'
       +'
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +
       +!'!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
       +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'
       +
       +
       +>
       +>
       +>
       +>
       +>
       +>
       +'
       +>
       +>
       +>
       +>
       +>
       +>>!>!>!>!>!!'
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +
       +!'!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
       +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'
       +>
       +>
       +>
       +>
       +>
       +'
       +>
       +>
       +>!'
       +>
       +>
       +>
       +>
       +>
       +'>!>!>!>!!'
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +
       +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
       +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'
       +>
       +>
       +>
       +>
       +>
       +>>!
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +
       +
       +
       +
       +
       +
       +
       +
       +
       +
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +
       +!!!!!!!!!!!!!!!!!!!!!!!!!!!!
       +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +'>
       +>>>>>'>>>>>>>>>>>>>
       +>
       +
       +'
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +
       +!!!!!!!!!!!!!!!!!!!!!!!!
       +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
       +>
       +>
       +>
       +>
       +>
       +''!'
       +'>''''''''''''''''''''''''''''>>>
       +
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +
       +!!!!!!!!!!!!!!!!!!!!!!
       +!!!!!!!!!!!!!!!!!!!!!!!!!!!!
       +>
       +>
       +>
       +>>
       +>>>>>>''''''''''''''''''''''''''''''''''''''>
       +
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +
       +!!!!!!!!!!!!!!!!!!!!
       +!!!!!!!!!!!!!!!!!!!!!!!!!!
       +>
       +>
       +>
       +>>'''''''''''''''''''''''''''''''''''''''''''''''''>!
       +'
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +
       +!!!!!!!!!!!!!!!!!!
       +!!!!!!!!!!!!!!!!!!!!!!!!
       +>
       +>
       +>
       +>
       +!''''''''''''''''''''''''''''''''''''''''''''''''''''>!
       +'
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +
       +!!!!!!!!!!!!!!!!
       +!!!!!!!!!!!!!!!!!!!!!!
       +>
       +>
       +>
       +>
       +>''''''''''''''''''''''''''''''''''''''''''''''''''''''>'>!>!
       +'
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>!!!!!!!!!!!!!!!!
       +!!!!!!!!!!!!!!!!!!!!!'
       +>
       +>
       +>
       +>
       +>''''''''''''''''''''''''''''''''''''''''''''''''''''''''''>'>!
       +'
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>!!!!!!!!!!!!!!
       +!!!!!!!!!!!!!!!!!!!'
       +>
       +>
       +>
       +>
       +>
       +!''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>!!!!!!!!!!!!!!
       +!!!!!!!!!!!!!!!!!'
       +>
       +>
       +>
       +>
       +>
       +>
       +
       +''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +
       +!!!!!!!!!!!!
       +!!!!!!!!!!!!!!!!
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>>>'''''''''>'>'>''''''''''''''>''
       +'
       +
       +>
       +>'
       +'
       +'
       +'>'>'>'>'>'>'
       +
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>!!!!!!!!!!!!
       +!!!!!!!!!!!!!!
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +
       +'
       +'
       +
       +>
       +'>
       +
       +'
       +'
       +>'
       +''''''''''
       +>
       +>
       +>
       +>
       +'>
       +>'>>>'
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>!!!!!!!!!!!!
       +!!!!!!!!!!!!!!
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +'
       +>
       +>>'!!
       +>
       +>
       +>
       +>
       +''>''''''
       +>
       +>
       +>
       +'>
       +>>>>>
       +
       +>
       +>
       +>
       +>
       +>
       +>
       +'>
       +>'''>'
       +'
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>!!!!!!!!!!!!
       +!!!!!!!!!!!!!!!!
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +!
       +'
       +>''''>>'!
       +>
       +!''>'''''''
       +>
       +>
       +>
       +!'''''''''!'!'!'''
       +''''''''''''''
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>!!!!!!!!!!!!
       +!!!!!!!!!!!!!!
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>>'''''''>'>>>>>>>'''''''''''
       +>
       +>
       +>>'''''''>'>>>>>>>'''''''''''''''''
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +
       +!!!!!!!!!!
       +!!!!!!!!!!!!
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>>
       +''''''''''''''''''''''''''''>'
       +>>'''''''''''''''''''''''''''''''''
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +
       +!!!!!!!!!!
       +!!!!!!!!!!
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +
       +''''''''''''''''''''''''''''''
       +!''''''''''''''''''''''''''''''''!'
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>!!!!!!!!!!
       +!!!!!!!!!!
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +
       +'''''''''''''''''''''''''''''''''
       +''''''''''''''''''''''''''>'!>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>!!!!!!!!!!
       +!!!!!!!!!!
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>'>'''''''''''''''''''''''''>'>''>>
       +
       +'''''''''''''''''''''''>!>!'
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +
       +!!!!!!!!
       +!!!!!!!!!!
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +
       +'>''''''''''''!!!>'>'
       +'
       +
       +>
       +>
       +>
       +>>
       +'''''''''''''''''''>!>!>!'
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>!!!!!!!!
       +!!!!!!!!!!
       +'
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +!
       +!'>''''''''''''>>
       +'
       +>
       +>
       +>
       +>>
       +>''''''>''''''''''''!>!>!'!'
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +
       +!!!!!!
       +!!!!!!!!!!!!
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +!!!'>''>''
       +'>'>''''>''!'!'
       +'>'
       +'
       +
       +>
       +>>
       +''''''''>'>!!>!'!'
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +
       +!!!!!!
       +!!!!!!!!!!!!
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>''''''>'>>>>>>>>>>>>>>>>>>'!
       +>>>>>''''''''''''''!>!>!'
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>!!!!!!
       +!!!!!!!!!!
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +
       +'>'''''''''''''''
       +'
       +'
       +'
       +
       +>
       +>
       +
       +'
       +''''''''''!>!>!>!'!'
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +
       +!!!!
       +!!!!!!!!!!
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>'
       +'>''''''''''>>>>>>>>>>>>'''''''''>'>!>!>!>!>!'
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>!!!!
       +!!!!!!!!!>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>'
       +''''''''''''''''''''''''''''!>!>!>!>!'!'
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +
       +!!
       +!!!!!!!!!!
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>'
       +'''''''''''''''''>'>'>!>!'!'!'
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>!!
       +!!!!!!!!!!!>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +
       +'
       +'
       +'
       +'
       +'
       +
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +
       +
       +!!!!!!!!!!!!>!
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +'
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +
       +
       +!!!!!!!!!!!!!!
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>'>>'
       +'
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +!!!!!!!!!!!!!!!!
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>''''>>>
       +
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +!!!!!!!!!!!!!!!!!>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>'>''''''>'
       +'
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +'>
       +>>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +!!!!!!!!!!!!!!!!!!
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>''''''''''''''''''>'>>>
       +
       +'>
       +>
       +>>>>''''''''''
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +!!!!!!!!!!!!!!!!!!
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +'>
       +>'>>>>''''''''''''''''''''''''''''''''''''''''''''
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +!!!!!!!!!!!!!!!!!!
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +'>'''''''''''''''''''''''''''''''''''''''''''''''''''''''''
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +!!!!!!!!!!!!!!!!!!
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>>
       +>'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +'
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +!!!!!!!!!!!!!!!!!!
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>>
       +>'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>!!!!
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +!!!!!!!!!!!!!!!!!!
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>>
       +>'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>>
       +!!!'
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +!!!!!!!!!!!!!!!!!>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>>>''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
       +'
       +>
       +>
       +>
       +>
       +>
       +>
       +>!!!'
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +!!!!!!!!!!!!!'!'
       +>
       +>
       +>
       +>
       +>
       +>
       +>>
       +>'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''!>
       +>
       +>
       +>
       +>
       +>
       +>
       +>!'
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +!!!!!!!'!'
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>>'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''!>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +!!!'
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>>
       +''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''!>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +'
       +'
       +>
       +>
       +>
       +>
       +
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>>'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''!'
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>>!!!!!!!!!!'!'
       +
       +
       +
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
       +>
       +>
       +>
       +>
       +>
       +>
       +>>
       +>!>!!!!'
       +
       +!'
       +>
       +>
       +'!'!'
       +>
       +
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +!''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''!>
       +>
       +>
       +>
       +>>
       +>!!'
       +
       +!'
       +>
       +>>
       +>!
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +
       +''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
       +>
       +>
       +>'!!'
       +>
       +>
       +>>
       +>!!!!!!'
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>'
       +'>'''''''''''''''''''''>''''''''''''''''''''''''''''''''''''''''''''''''''''''
       +>
       +>
       +>
       +>
       +>
       +'
       +!!!!!!!!'!'!'
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +!!!
       +
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>!!!>
       +>
       +>
       +>
       +>'
       +'
       +'>'>'''''''>
       +!'>'''''''''''''''''''''''''''''''''''''''''''''''''
       +'
       +
       +>
       +>
       +>
       +>
       +>>!!!!'!'!'
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>!!!!!!
       +
       +>
       +>
       +>
       +>
       +>
       +>
       +>>!!!!!!!!!>!>
       +
       +>
       +>
       +>
       +>
       +>
       +>
       +
       +'
       +!'!''
       +'
       +'>'>'>'>'''''''''''''''''''''''''''''''''
       +'
       +
       +>
       +>
       +>>
       +>!'!!'!'
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>!'>
       +!!
       +
       +>
       +>
       +>
       +>
       +>
       +>>!!!!!!!!!
       +!!!!!!!>!
       +>
       +'
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +
       +'
       +'
       +'
       +'
       +'
       +'
       +'
       +'
       +'
       +'
       +'
       +
       +>
       +>
       +>
       +>
       +
       +!'
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>!'
       +>!'
       +>
       +
       +>
       +>
       +>
       +>
       +>
       +>!!!!!!!!
       +>>!!!!!!!
       +>>!!!!!!!!!!>>!>
       +>!>
       +
       +>
       +'
       +'
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>!'
       +>
       +'
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>!'
       +>
       +>!'
       +>
       +
       +>
       +>
       +>
       +>
       +>!!!!!'
       +>>
       +>!!!!!!!
       +>>!!'
       +
       +!!!!!!!!!!!!!!!!>!!!!!!!!!!!>!
       +>
       +>
       +'
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>!>!'
       +>
       +'!'!'
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>>!
       +>
       +>
       +>
       +>
       +>
       +>
       +
       +>
       +>
       +>
       +>!!!!!'
       +>>!!!!!!'!!!'>!!!
       +>!!!!
       +>!!!!!!!!!!!!!!!!!!!!!!!!!!
       +>
       +>!'
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>'!!'
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +
       +>
       +>
       +>
       +!!!!!
       +>
       +>!!!!
       +>
       +
       +!!>!!!
       +>
       +
       +!!!'
       +>!!!!!!!!!!!!!!!!!!!!
       +!!!
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +'
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +
       +>
       +>
       +>
       +
       +!!
       +>
       +>>!!!
       +>
       +>>!!!!!!!
       +>
       +!!'
       +>
       +!!!!!!!!!
       +>
       +
       +!!!!!!
       +>
       +!
       +>
       +>
       +>
       +>
       +>
       +>
       +>!!
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +
       +>
       +>
       +
       +>!
       +>
       +>
       +>!!!>
       +>
       +>
       +!!!!!
       +>>!!'
       +>
       +>!!!!!!!!!'
       +>
       +>!!!!!'>!!!
       +>
       +>
       +>
       +>
       +>>!!'
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +
       +>
       +>
       +>!!
       +>
       +>
       +>!!
       +>
       +>
       +>!!!!!!
       +>!!
       +>
       +>
       +>
       +
       +!!!!!!
       +>
       +>>!!!!!
       +>!!
       +>
       +>
       +>
       +>
       +>
       +>!'
       +>
       +>!'
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +
       +>
       +>>!
       +>
       +>
       +>
       +
       +!!
       +>
       +>
       +
       +!!!!
       +>>
       +!'
       +>
       +>
       +>
       +>!!!'
       +>
       +>
       +>>!!!!'
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +
       +>
       +>
       +>
       +>
       +>
       +>!'
       +>
       +>
       +>!!
       +
       +!!
       +>!!
       +>
       +>
       +>
       +>
       +!
       +>
       +>
       +>
       +>
       +>!!!!
       +>
       +!
       +>
       +>
       +>
       +>
       +>
       +>!'
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>!!
       +>>!!!
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>!>>!!!
       +>>!!>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>!!!'
       +>
       +>
       +>
       +>
       +>
       +>
       +>>!
       +>!!!!
       +>!'
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>!'
       +>>!!!
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>!>
       +>!!
       +>!'
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>!'
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
       +>
     # /tmp/d20131110-20795-1mfbg64/spec.rb:105:in `block (2 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

Finished in 0.15418 seconds
5 examples, 3 failures

Failed examples:

rspec /tmp/d20131110-20795-1mfbg64/spec.rb:2 # Bitmap renders bytes
rspec /tmp/d20131110-20795-1mfbg64/spec.rb:24 # Bitmap supports different palettes
rspec /tmp/d20131110-20795-1mfbg64/spec.rb:31 # Bitmap renders La Gioconda