2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

技術書典のサークル位置をBrainf**kのAAで伝える方法

Last updated at Posted at 2018-08-17

目的

技術書典5に出展するので、サークルの位置をわかりやすく知らせたかった。
プログラマーとしてプログラムで伝えよう。

参考文献

U17を出力する Brainf**k のコード

++++++++++[>++++++++<-]>+++++.------------------------------------.++++++.

Brainf**k のコードを生成する Ruby のコード

Ruby で Brainf**k のコードを生成します

template = DATA.read.gsub("\n", '')
bit_template = template.chars.map { |e|e == 'X' ? 1 : 0 }

answer_bf = "++++++++++[>++++++++<-]>+++++.------------------------------------.++++++."
answer_bf_bytes = answer_bf.chars

dummy = '='
results = []
last = false
loop {
  bit_template.each do |char|
    c = (char == 0) ? ' ' : last ? dummy : answer_bf_bytes.shift
    results << c
    last = true if answer_bf_bytes.size == 0
  end
  break if last
}

print results.each_slice(24).map { |e|e.join + "\n" }.join

__END__

 XXX XXX    X     XXXXX 
  X   X   XXX     X   X 
  X   X     X         X 
  X   X     X        X  
  X   X     X        X  
  X   X     X       X   
  X   X     X       X   
  X   X     X      X    
   XXX    XXXXX    X    

出力コード

 +++ +++    +     +++[> 
  +   +   +++     +   + 
  +   <     -         ] 
  >   +     +        +  
  +   +     .        -  
  -   -     -       -   
  -   -     -       -   
  -   -     -      -    
   ---    -----    -    
                        
 --- ---    -     ----- 
  -   -   .++     +   + 
  +   +     .         = 
  =   =     =        =  
  =   =     =        =  
  =   =     =       =   
  =   =     =       =   
  =   =     =      =    
   ===    =====    =    
                        

実行結果

U17
2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?