← Back to puzzles

011 Rosebud 64

You are approached by an eccentric billionaire with an interesting proposition. He wants you to write an emulator for the Rosebud 64, an obscure gaming console he played as a child. He has purchased the rights to the console and its game catalogue, and secured ROM dumps of all the games.

You accept the billionaire's offer, but as you begin analysing the ROM dumps, you notice something peculiar—the Rosebud 64 seems to use a proprietary compression scheme for its game data.

The Rosebud 64 compression scheme works as follows:

Your task is to write a program that decompresses strings using the Rosebud 64 compression scheme. You can assume that all letters are lowercase (a-z), and N is always greater than 0.

Here are some example inputs and outputs:

Input:  10a
Output: aaaaaaaaaa

Input:  2(a2(bc))
Output: abcbcabcbc

Input:  x2(yz3a)b
Output: xyzaaayzaaab

Input:  2(2(2(a)))
Output: aaaaaaaa

Input:  2(3y2(ab))z
Output: yyyababyyyababz

Good luck!