CJam、70 64バイト
切断するための@Peterテイラーに感謝{"789":I}{"76:":I}?
します"789""76"?:I
"67":Iq:A{AI#:B){AB<7+A{BI,+}~>+s:A];}{"76"I={"789":I}{"76":I}?];}?}/A
"67":Iq:A{AI#:B){AB<7+A{BI,+}~>+s:A];}{"76"I="789""76"?:I];}?}/A
これはおそらくもっともっとゴルフができ、あなたの助けが大いに感謝されることを知っていますが、率直に言って答えを得ることができただけで幸せです。これは、CJamを書く最初の試みでした。
説明:
"67":I e# Assign the value of 67 to I
q:A e# Read the input and assign to A
{ e# Opening brackets for loop
AI#:B) e# Get the index of I inside A and assign to B. The increment value by 1 to use for if condition (do not want to process if the index was -1)
{ e# Open brackets for true result of if statement
AB< e# Slice A to get everything before index B
7+ e# Append 7 to slice
A{BI,+}~> e# Slice A to get everything after index B plus the length of string I (this will remove I entirely)
+s:A e# Append both slices, convert to string, and assign back to A
]; e# Clear the stack
} e# Closing brackets for the if condition
{ e# Open brackets for false result of if statement
"76"I= e# Check if I is equal to 76
"789" e# If I is 76, make I 789
"76"?:I e# If I is not 76, make I 76
]; e# Clear the stack if I does not exist inside A
}? e# Closing brackets for false result of if statement
}/ e# Loop
A e# Output A