LoginSignup
0
0

More than 5 years have passed since last update.

「異星の電光掲示板」をsedで(横へな15)

Last updated at Posted at 2013-11-18

異星の電光掲示板」をやってみました。他の実装は 第15回オフラインリアルタイムどう書くの問題 から辿れます。

「あれ、これ置換だけでできるんじゃね?」と思ったのでsedで書いてみました。

elebubo.sed
# 16進数→2進数
s/0/0000/g
s/1/0001/g
s/2/0010/g
s/3/0011/g
s/4/0100/g
s/5/0101/g
s/6/0110/g
s/7/0111/g
s/8/1000/g
s/9/1001/g
s/a/1010/g
s/b/1011/g
s/c/1100/g
s/d/1101/g
s/e/1110/g
s/f/1111/g

# 前半(上段)の1を2に置換
:LOOP
s/1\(.*\)\//2\1\//
t LOOP

# 前半(上段)と後半(下段)のビットを並べる
s/$/:/
:LOOP2
s/^\(.\)\(.*\)\/\(.\)\(.*\):\(.*\)/\2\/\4:\5\1\3/
t LOOP2

# 文字に置換
s/202120/T/g
s/210121/U/g
s/212021/N/g
s/012120/S/g
s/202101/Z/g
s/2101/L/g
s/2120/R/g
s/0121/J/g

# ごみ掃除
s/[0:\/]//g
0
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
0
0