Problem:


	MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});

jfen

H &times; W の盤面で遊ぶ一人用ゲームがある．このゲームはそれぞれのセルに 0 か 1 個のボールがあるのでそれを移動させるゲームである．あなたはこのゲームで遊んでいたが，ボールは非常に丸いため，セルからセルへ正確にボールを移動させるのが難しいことに気づいた．そこであなたは，命令通りにボールを動かしてくれるロボットを作ることにした．ここで，セルを表す表記として (y, x) という表記を用いる．これは y 行目の x 列目のセルを表す．

ロボットへの命令は 4 つの整数 a, b, c, d で与えられる．これは (a, b) にあるボールを (c, d) に移動することを表す．このとき，(a, b) にボールが存在し， (c, d) にボールが存在しないことが保証される．

盤面の状態は，"jfen" と呼ばれる次の記法で表される．

[1 行目のデータ]/[2 行目のデータ]/.../[H 行目のデータ] 

この記法は盤面の各行を表すデータをスラッシュ区切りで連結したものである．各行のデータは文字列で表され，1 列目からW列目にあるセルの状態を左から順に記述している．この文字列は数字と文字 'b' で表され，数字が表す整数は連続した空白のセル数を，'b' はボールが存在するセルを表している．ここで，各行のデータで整数が連続してはならない．また，各行のデータに書かれている整数の総和と 'b' の個数の和は必ず W になる．

例として，次のような盤面状態を考える．空白のセルを '.' で表し，ボールが存在するセルを 'b' で表現している．この例の i 行目の左から j 文字目は盤面の i 行目の j 列目のセルの状態を表す．

....
.b.b
....

上記の盤面を jfen で表記すると次のようになる．

4/1b1b/4

ロボットに現在の盤面の状態と 1 つのボールを動かす命令を与えた時に，ロボットがボールを動かした後の盤面を出力するプログラムを作成せよ．このとき，出力する盤面は jfen 記法で出力せよ．

Input

入力は複数データセットからなる．
各データセットは以下の形式からなる．

S
a b c d

各データセットは 2 行からなり，最初の行には盤面の状態を表す jfen 形式の文字列 S が与えられる．ここで， 盤面のサイズは 2 ≤ W, H ≤ 9 を満たす．続く行にはロボットへの命令が与えられる．これは (a, b) にあるボールを (c, d) に移動させる命令を表す．また，入力の終わりは # で表される．

Output

出力は各データセットごとに命令を実行したあとの盤面の状態を  jfen 記法で表した文字列 1 行である．出力行には他の文字があってはならない．

Sample Input

b1/1b
1 1 1 2
b5/bbbbbb
2 4 1 4
b2b2b/7
1 4 2 4
#

Output for Sample Input

1b/1b
b2b2/bbb1bb
b5b/3b3

1番目の入力の初期状態は次のようになる．

b．
.b

(1,1) のボールを (1,2) に移動させるので命令後の盤面は次のようになる．

.b
.b



Sample input:
b1/1b
1 1 1 2
b5/bbbbbb
2 4 1 4
b2b2b/7
1 4 2 4
#


Sample output:
1b/1b
b2b2/bbb1bb
b5b/3b3

Submission status: Wrong Answer

Solution code:
while 1:
    s=input()
    if '#' in s:break
    p=0
    e=[[]*2 for _ in range(10)]
    for x in s:
        if x=='b':e[p]+=['b']
        elif x=='/':p+=1
        else:e[p]+='.'*int(x)
    ans=''
    a,b,c,d=map(int,input().split())
    e[a-1][b-1],e[c-1][d-1]=e[c-1][d-1],e[a-1][b-1]
    for i in range(2):
        if i:ans+='/'
        a=0
        for j in e[i]:
            if j=='b':
                if a:ans+=str(a)
                ans+='b'
                a=0
            else:a+=1
        if a:ans+=str(a)
    print(ans)

Submission status: Accepted

Solution code:
while 1:
    s=input()
    if '#' in s:break
    p=0
    e=[[]*2 for _ in range(10)]
    for x in s:
        if x=='b':e[p]+=['b']
        elif x=='/':p+=1
        else:e[p]+='.'*int(x)
    ans=''
    a,b,c,d=map(int,input().split())
    e[a-1][b-1],e[c-1][d-1]=e[c-1][d-1],e[a-1][b-1]
    for i in range(p+1):
        if i:ans+='/'
        a=0
        for j in e[i]:
            if j=='b':
                if a:ans+=str(a)
                ans+='b'
                a=0
            else:a+=1
        if a:ans+=str(a)
    print(ans)

Submission status: Accepted

Solution code:
def j2b(S):
    rows = S.split("/")
    for i, row in enumerate(rows):
        cand = []
        for s in row:
            if s == "b":
                cand.append(s)
            else:
                cand.extend(["."] * int(s))
        rows[i] = cand
    return rows


def b2j(rows):
    ret = []
    for row in rows:
        r = []
        c = 0
        for s in row:
            if s == "b":
                if c:
                    r.append(str(c))
                r.append(s)
                c = 0
            else:
                c += 1
        if c:
            r.append(str(c))
        ret.append(''.join(r))
    return '/'.join(ret)


while True:
    S = input()
    if S == "#":
        break
    rows = j2b(S)
    a, b, c, d = [int(x) - 1 for x in input().split()]
    rows[a][b], rows[c][d] = rows[c][d], rows[a][b]
    print(b2j(rows))

Submission status: Accepted

Solution code:
def decode(s):
    ret = []
    for line in s.split('/'):
        a = ''
        for c in line:
            if c == 'b':
                a += 'b'
            else:
                a += '.'*(ord(c)-ord('0'))
        ret.append(list(a))
    return ret

def encode(s):
    ret = []
    for line in s:
        x = ''.join(line)
        x = x.split('b')
        a = ''
        for i in range(len(x)-1):
            if len(x[i])>0:
                a += str(len(x[i]))
            a += 'b'

        if len(x[len(x)-1])>0:
            a += str(len(x[len(x)-1]))
        ret.append(a)

    return '/'.join(ret)

def main():
    while True:
        s = input()
        if s == '#':
            break
        a,b,c,d = map(int,input().split())

        f = decode(s)
        f[a-1][b-1] = '.'
        f[c-1][d-1] = 'b'
        print(encode(f))

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
while 1:
    s = input()
    if s == '#':
        break
    M = []
    for l in s.split('/'):
        num = 0
        tmp = []
        for c in l:
            if c == 'b':
                if num > 0:
                    tmp.extend([0]*num)
                tmp.append(1)
                num = 0
            else:
                num = 10*num + int(c)
        if num > 0:
            tmp.extend([0]*num)
        M.append(tmp)
    a, b, c, d = map(int, input().split())
    assert M[a-1][b-1] == 1
    M[a-1][b-1] = 0
    assert M[c-1][d-1] == 0
    M[c-1][d-1] = 1
    ans = []
    for l in M:
        tmp = ""
        cnt = 0
        for c in l:
            if c:
                if cnt > 0:
                    tmp += str(cnt)
                cnt = 0
                tmp += 'b'
            else:
                cnt += 1
        if cnt > 0:
            tmp += str(cnt)
        ans.append(tmp)
    print("/".join(ans))

Submission status: Accepted

Solution code:
while True:
    s = input()
    if s == "#":break
    s = s.split("/")
    area = [0] * len(s)
    for i in range(len(s)):
        t = []
        while True:
            if s[i][0] == "b":
                t.append(1)
                s[i] = s[i][1:]
            else:
                if "b" in s[i]:
                    t += [0] * int(s[i][:s[i].index("b")])
                    s[i] = s[i][s[i].index("b"):]
                else:
                    t += [0] * int(s[i])
                    break
            if s[i] == "":
                break
        area[i] = t
    a, b, c, d = map(int, input().split())
    area[a - 1][b - 1] = 0
    area[c - 1][d - 1] = 1
    t = ""
    for i in range(len(area)):
        j = 0
        while True:
            if area[i][j] == 1:
                t += "b"
                j += 1
            else:
                k = 0
                while j < len(area[i]) and area[i][j] == 0:
                    k += 1
                    j += 1
                t += str(k)
            if j == len(area[i]):break
        if i < len(area) - 1:
            t += "/"
    print(t)

Submission status: Accepted

Solution code:
now=input()

while now!="#":
    order_raw = input()
    order = [int(s)-1 for s in order_raw.split(' ')]

    box = [[]]
    for n in now:
        if n=='/':
            box.append([])
        elif n=='b':
            box[-1].append('b')
        else:
            for _ in range(int(n)):
                box[-1].append('.')

    box[order[0]][order[1]] = '.'
    box[order[2]][order[3]] = 'b'

    res=""
    index=0
    for bo in box:
        for b in bo:
            if b=='b':
                if index>0:
                    res+=str(index)
                    index=0
                res+="b"
            else:
                index+=1
        if index>0:
            res+=str(index)
            index=0
        res+="/"

    print(res[:-1])

    now=input()

Submission status: Accepted

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 998244353
dd = [(0,-1),(1,0),(0,1),(-1,0)]
ddn = [(0,-1),(1,-1),(1,0),(1,1),(0,1),(-1,-1),(-1,0),(-1,1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    rr = []

    st = string.digits + string.ascii_uppercase

    def decode(s):
        t = s.split('/')
        a = []
        for c in t:
            b = []
            for k in c:
                if k == 'b':
                    b.append(1)
                else:
                    for _ in range(int(k)):
                        b.append(0)
            a.append(b)
        return a

    def encode(a):
        t = []
        for c in a:
            k = ''
            tc = 0
            for b in c:
                if b == 0:
                    tc += 1
                else:
                    if tc > 0:
                        k += str(tc)
                        tc = 0
                    k += 'b'
            if tc > 0:
                k += str(tc)
            t.append(k)
        return '/'.join(t)

    while True:
        s = S()
        if s == '#':
            break

        a,b,c,d = LI()
        t = decode(s)
        t[a-1][b-1] = 0
        t[c-1][d-1] = 1

        rr.append(encode(t))

    return '\n'.join(map(str, rr))


print(main())

Submission status: Accepted

Solution code:
def main():
	S = input().split("/")
	if S[0] == "#":
		return
	for s in range(len(S)):
		for i in range(10):
			S[s]= S[s].replace(str(i),"."*i)
	a,b,c,d = map(int,input().split())
	S[a-1] = S[a-1][:b-1]+"."+S[a-1][b:]
	S[c-1] = S[c-1][:d-1]+"b"+S[c-1][d:]
	for s in range(len(S)):
		ref = ""
		temp = 0
		for i in S[s]:
			if i == ".":
				temp += 1
			else:
				ref += (str(temp) if temp is not 0 else "") + "b"
				temp = 0
		S[s] = ref + (str(temp) if temp is not 0 else "")
	print("/".join(S))
	main()
	return
main()

Submission status: Accepted

Solution code:

while True:
    s = input()
    if s == '#':
        break
    rows = s.split('/')

    a, b, c, d = map(int, input().split())
    a -= 1
    b -= 1
    c -= 1
    d -= 1
    grid = ['' for _ in rows]
    for i, row in enumerate(rows):
        for kk in row:
            if kk == 'b':
                grid[i] += 'b'
            else:
                grid[i] += '.' * int(kk)
    
    grid[a] = grid[a][:b] + '.' + grid[a][b + 1:]
    grid[c] = grid[c][:d] + 'b' + grid[c][d + 1:]

    ans = []

    # for row in grid:
    #     print(row)
    for row in grid:
        s = ''
        tmp = 0
        for kk in row:
            if kk == 'b':
                if tmp != 0:
                    s += str(tmp)
                    tmp = 0
                s += 'b'
            else:
                tmp += 1
        if tmp != 0:
            s += str(tmp)
            tmp = 0
        ans.append(s)
    print('/'.join(ans))

Submission status: Accepted

Solution code:
while True:
    st = list(input().split("/"))
    if st == ["#"]:
        break
    a, b, c, d = map(int, input().split())

    s=[]
    for i in range(len(st)):
        str=[]
        for ele in st[i]:
            if ele=="b":
                str.append("b")
            else:
                for _ in range(int(ele)):
                    str.append(".")
        s.append(str)

    s[a-1][b-1] = "."
    s[c-1][d-1] = "b"

    '''
    print(s)
    ans=""
    for i in range(len(s)):
        count = 0
        for ele in s[i]:
            if ele=="b":
                sr="{}".format(count)
                ans=ans+sr
                ans+="b"
            else:
                count+=1
        ans+="/"
    print(ans)
    '''


    ans = []
    for i in range(len(s)):
        sr = ""
        c = 0
        for j in range(len(s[i])):
            if s[i][j] == 'b':
                if c != 0:
                    sr += "{}".format(c)
                sr += "b"
                c=0
            elif s[i][j] == '.':
                c += 1
            '''
            if j==len(s[i])-1:
                if s[i][j] == '.' and c != 0:
                    sr += "{}".format(c)
            '''
        if c!=0:
            sr+="{}".format(c)
        ans.append(sr)
    ass = "/".join(ans)
    print(ass[:])

Submission status: Accepted

Solution code:
import copy

while 1:
    S = input()
    if S == '#':
        break
    a, b, c, d = map(lambda x : int(x)-1, input().split())
    F = list(S.split('/'))
    if a != c:
        f1 = list(F[a])
        f2 = list(F[c])
        F[a] = []
        for x in f1:
            if x == 'b':
                F[a].append('b')
            else:
                F[a] += [0]*int(x)
        F[c] = []
        for x in f2:
            if x == 'b':
                F[c].append('b')
            else:
                F[c] += [0]*int(x)
        F[a][b] = 0
        F[c][d] = 'b'
        l = 0
        y = ''
        for x in F[a]:
            if x == 'b':
                if l > 0:
                    y += str(l)
                    l = 0
                y += 'b'
            else:
                l += 1
        if l > 0:
            y += str(l)
        F[a] = y
        l = 0
        y = ''
        for x in F[c]:
            if x == 'b':
                if l > 0:
                    y += str(l)
                    l = 0
                y += 'b'
            else:
                l += 1
        if l > 0:
            y += str(l)
        F[c] = y
        print(*F, sep = '/')
    else:
        f1 = list(F[a])
        F[a] = []
        for x in f1:
            if x == 'b':
                F[a].append('b')
            else:
                F[a] += [0]*int(x)
        F[a][b] = 0
        F[c][d] = 'b'
        l = 0
        y = ''
        for x in F[a]:
            if x == 'b':
                if l > 0:
                    y += str(l)
                    l = 0
                y += 'b'
            else:
                l += 1
        if l > 0:
            y += str(l)
        F[a] = y
        print(*F, sep = '/')

Submission status: Accepted

Solution code:

while True:
     
    Y = input().split("/")
    if Y[0] == "#":
        break
    L = [[False for i in range(9)]for i in range(9)]

    MX = 1
    MY = len(Y)

    for i in range(len(Y)):
        p = 0
        for str_ in Y[i]:
            #print(i,str_)

            if str_ == "b":
                L[i][p] = True
                p += 1
            else:
                p += int(str_)
            MX = max(MX,p)

    #print(L)

    y1,x1,y2,x2 = map(int,input().split(" "))

    #print(y1,x1,y2,x2)

    L[y1-1][x1-1] = False
    L[y2-1][x2-1] = True

    #print(L)

    #print(MX,MY)

    ans = ""
    f = False

    for y in range(MY):
        ans_ = ""
        cnt = 0
        for x in range(MX):
            if L[y][x]:#b
                if cnt > 0:
                    ans_ += str(cnt)
                ans_ += "b"
                cnt = 0
            else:#
                cnt += 1
        if cnt > 0:
            ans_ += str(cnt)
        if y != MY-1:
            ans_ += "/"
        ans += ans_
    print(ans)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
while True:
    s = input()
    if s == '#':
        break
    a, b, c, d = map(lambda x: int(x) - 1, input().split())
    cell = []
    for i, x in enumerate(s.split('/')):
        cell.append([])
        for ch in x:
            if ch == 'b':
                cell[i].append('b')
            else:
                cell[i] += list('.' * int(ch))
    cell[a][b] = '.'
    cell[c][d] = 'b'
    ans = []
    for i in range(len(cell)):
        jfen = ''
        cnt = 0
        for j in range(len(cell[i])):
            if cell[i][j] == 'b':
                if cnt > 0:
                    jfen += str(cnt)
                cnt = 0
                jfen += 'b'
            else:
                cnt += 1
        if cnt > 0:
            jfen += str(cnt)
        ans.append(jfen)
    print('/'.join(ans))

Submission status: Accepted

Solution code:
while True:
    S = input()
    if S == "#":
        break

    a, b, c, d = map(int, input().split())

    hasBall = [[False for _ in range(10)] for _ in range(10)]

    rows = S.split('/')
    H = len(rows)
    for h, row in enumerate(rows, start=1):
        cur = 1
        colsize = 0
        for ch in row:
            if ch == 'b':
                hasBall[h][cur] = True
                colsize += 1
                cur += 1
            else:
                colsize += int(ch)
                cur += int(ch)
        W = colsize

    # for h in range(H+2):
    #     for w in range(W+2):
    #         print(hasBall[h][w], end="")
    #     print()

    hasBall[a][b] = False
    hasBall[c][d] = True

    rows = []
    for h in range(1, H+1):
        streak = 0
        row = ""
        for w in range(1, W+1):
            if hasBall[h][w]:
                if streak:
                    row += str(streak)
                    streak = 0
                row += 'b'
            else:
                streak += 1
        if streak:
            row += str(streak)

        rows.append(row)

    # for h in range(H+2):
    #     for w in range(W+2):
    #         print(hasBall[h][w], end="")
    #     print()

    print("/".join(rows))

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
while True:
    s = input()
    if s == '#':
        break
    a, b, c, d = map(lambda x: int(x) - 1, input().split())
    tb = []
    for i, x in enumerate(s.split('/')):
        tb.append([])
        for ch in x:
            if ch == 'b':
                tb[i].append('b')
            else:
                tb[i] += list('.' * int(ch))
    tb[a][b] = '.'
    tb[c][d] = 'b'
    ans = []
    for i in range(len(tb)):
        tmp = ''
        cnt = 0
        for j in range(len(tb[i])):
            if tb[i][j] == 'b':
                if cnt > 0:
                    tmp += str(cnt)
                cnt = 0
                tmp += 'b'
            else:
                cnt += 1
        if cnt > 0:
            tmp += str(cnt)
        ans.append(tmp)
    print('/'.join(ans))

Submission status: Accepted

Solution code:
while True:
    S = input()
    if S=="#":
        exit()
    B = []
    W = 0
    for c in S:
        if c == "b":
            B.append(1)
        elif c != "/":
            B.extend([0] * int(c))
        elif W==0:
            W = len(B)
    assert len(B) % W == 0
    H = len(B) // W
    a,b,c,d = map(lambda x: int(x)-1, input().split())
    B[a*W+b] = 0
    B[c*W+d] = 1
    ans = ""
    cnt = 0
    for y in range(H):
        for x in range(W):
            if B[y*W+x] == 0:
                cnt += 1
            else:
                if cnt>0:
                    ans+=str(cnt)
                cnt = 0
                ans += "b"
        if cnt>0:
            ans += str(cnt)
        cnt = 0
        ans += "/"
    print(ans[:-1])

Submission status: Accepted

Solution code:
def parse_line(line):
  ret = []
  for c in line:
    if c == "b":
      ret.append("b")
    else:
      for _ in range(int(c)):
        ret.append(".")
  return ret

def parse_jfen(s):
  return list(map(parse_line, s.split("/")))

def to_jfen(mp):
  ret = ""
  cnt = 0
  for line in mp:
    cnt = 0
    for c in line:
      if c == "b":
        if cnt != 0:
          ret += str(cnt)
          cnt = 0
        ret += "b"
      else:
        cnt += 1
    if cnt != 0:
      ret += str(cnt)
    ret += "/"
  return ret[:-1] 

while True:
  s = input()
  if s == "#":break
  mp = parse_jfen(s)
  a, b, c, d = map(int, input().split())
  mp[a - 1][b - 1] = "."
  mp[c - 1][d - 1] = "b"
  print(to_jfen(mp))

Submission status: Accepted

Solution code:
while 1:
    S = input()
    if S == "#":
        break

    S = S.split("/")
    board = []
    for S_row in S:
        row = []
        for s in S_row:
            if s == "b":
                row.append("b")
            else:
                for _ in range(int(s)):
                    row.append(".")
        board.append(row)

    a, b, c, d = map(int, input().split())
    board[a-1][b-1], board[c-1][d-1] = board[c-1][d-1], board[a-1][b-1]

    ans = ""
    for b_row in board:
        cnt = 0
        for b in b_row:
            if b == ".":
                cnt += 1
            else:
                if cnt != 0:
                    ans += str(cnt)
                    cnt = 0
                ans += "b"
        if cnt != 0:
            ans += str(cnt)
        ans += "/"

    print(ans[:-1])

Submission status: Accepted

Solution code:
# coding: utf-8
while 1:
    s=input()
    if s=='#':
        break
    s=s.split('/')
    field=[list(''.join(['b' if c=='b' else '.'*int(c) for c in s[i]]))  for i in range(len(s))]
    a,b,c,d=map(int,input().split())
    field[a-1][b-1],field[c-1][d-1]='.','b'
    print('/'.join(['b'.join('' if len(c)==0 else str(len(c)) for c in ''.join(field[i]).split('b') ) for i in range(len(field))]))

Submission status: Accepted

Solution code:
while True:
    s = input()
    if s == '#':
        break
    else:
        a, b, c, d = map(int, input().split())
        s_list = s.split('/')
        a_str = ''
        if a == c:
            for i in s_list[a-1]:
                if i == 'b':
                    a_str += 'b'
                else:
                    a_str += '.' * int(i)
            a_tmp = a_str[min(b, d)-1]
            c_tmp = a_str[max(b, d)-1]
            a_rep = a_str[:min(b, d)-1] + c_tmp + a_str[min(b, d):max(b, d)-1] + a_tmp + a_str[max(b, d):]
            a_s = ''
            count = 0
            flag = 0
            for i in a_rep:
                if i == '.':
                    flag = 1
                    count += 1
                elif flag == 1:
                    a_s += str(count)
                    a_s += str('b')
                    flag = 0
                    count = 0
                else:
                    a_s += str('b')
                    flag = 0
                    count = 0
            if flag == 1:
                a_s += str(count)
                flag = 0
            s_list[a-1] = a_s
        else:
            for i in s_list[a-1]:
                if i == 'b':
                    a_str += 'b'
                else:
                    a_str += '.' * int(i)
            a_tmp = a_str[b-1]
            c_str = ''
            for i in s_list[c-1]:
                if i == 'b':
                    c_str += 'b'
                else:
                    c_str += '.' * int(i)
            c_tmp = c_str[d-1]
            a_rep = a_str[:b-1] + c_tmp + a_str[b:]
            c_rep = c_str[:d-1] + a_tmp + c_str[d:]
            flag = 0
            count = 0
            a_s = ''
            for i in a_rep:
                if i == '.':
                    flag = 1
                    count += 1
                elif flag == 1:
                    a_s += str(count)
                    a_s += str('b')
                    flag = 0
                    count = 0
                else:
                    a_s += str('b')
                    flag = 0
                    count = 0
            if flag == 1:
                a_s += str(count)
                flag = 0
            count = 0
            c_s = ''
            for i in c_rep:
                if i == '.':
                    flag = 1
                    count += 1
                elif flag == 1:
                    c_s += str(count)
                    c_s += str('b')
                    flag = 0
                    count = 0
                else:
                    c_s += str('b')
                    flag = 0
                    count = 0
            if flag == 1:
                c_s += str(count)
            s_list[a-1] = a_s
            s_list[c-1] = c_s
        out = ''
        for i in range(len(s_list)):
            out += s_list[i]
            if i < len(s_list) - 1:
                out += '/'
        print(out)

Submission status: Runtime Error

Solution code:
while 1:
    s=input()
    if s=='#':break
    p=0
    e=[[],[]]
    for x in s:
        if x=='b':e[p]+=['b']
        elif x=='/':p+=1
        else:
            for j in range(int(x)):e[p]+=['.']
    ans=''
    a,b,c,d=map(int,input().split())
    e[a-1][b-1],e[c-1][d-1]=e[c-1][d-1],e[a-1][b-1]
    for i in range(2):
        if i: ans += '/'
        a=0
        for j in e[i]:
            if j=='b':
                if a:ans+=str(a)
                ans+='b'
                a=0
            else:a+=1
        if a:ans+=str(a)
    print(ans)

Submission status: Runtime Error

Solution code:
while 1:
    s=input()
    if s=='#':break
    p=0
    e=[[],[]]
    for x in s:
        if x=='b':e[p]+=['b']
        elif x=='/':p+=1
        else:
            for j in range(int(x)):e[p]+=['.']
    ans=''
    a,b,c,d=map(int,input().split())
    e[a-1][b-1]='.'
    e[c-1][d-1]='b'
    for i in range(2):
        if i:ans+='/'
        a=0
        for j in e[i]:
            if j=='b':
                if a:ans+=str(a)
                ans+='b'
                a=0
            else:a+=1
        if a:ans+=str(a)
    print(ans)