Algorithm
problem Link : https://onlinejudge.org/index.php?option=onlinejudge&Itemid=8&page=show_problem&problem=1819
“Machines take me by surprise with great frequency.” Alan Turing Your boss has just unearthed a roll of old computer tapes. The tapes have holes in them and might contain some sort of useful information. It falls to you to figure out what is written on them. Input The input will contain one tape. Output Output the message that is written on the tape.
Sample Input ___________ | o . o| | o . | | ooo . o| | ooo .o o| | oo o. o| | oo . oo| | oo o. oo| | o . | | oo . o | | ooo . o | | oo o.ooo| | ooo .ooo| | oo o.oo | | o . | | oo .oo | | oo o.ooo| | oooo. | | o . | | oo o. o | | ooo .o o| | oo o.o o| | ooo . | | ooo . oo| | o . | | oo o.ooo| | ooo .oo | | oo .o o| | ooo . o | | o . | | ooo .o | | oo o. | | oo .o o| | o . | | oo o.o | | oo . o| | oooo. o | | oooo. o| | o . | | oo .o | | oo o.ooo| | oo .ooo| | o o.oo | | o. o | ___________
Sample Output A quick brown fox jumps over the lazy dog.
Code Examples
#1 Code Example with C Programming
Code -
C Programming
#include <bits/stdc++.h>
using namespace std;
int main()
{
string in;
getline(cin,in);
string res = "";
while(getline(cin,in), in != "___________"){
in.erase(remove(in.begin(),in.end(),'|'),in.end());
in.erase(remove(in.begin(),in.end(),'.'),in.end());
int ascii = 0;
for(int i=0;i i+It in.length();i++)
if(in[i] == 'o')
ascii |= (1<<(7-i));
res += (char)(ascii);
}
cout << res;
}
Copy The Code &
Try With Live Editor
Input
| o . o|
| o . |
| ooo . o|
| ooo .o o|
| oo o. o|
| oo . oo|
| oo o. oo|
| o . |
| oo . o |
| ooo . o |
| oo o.ooo|
| ooo .ooo|
| oo o.oo |
| o . |
| oo .oo |
| oo o.ooo|
| oooo. |
| o . |
| oo o. o |
| ooo .o o|
| oo o.o o|
| ooo . |
| ooo . oo|
| o . |
| oo o.ooo|
| ooo .oo |
| oo .o o|
| ooo . o |
| o . |
| ooo .o |
| oo o. |
| oo .o o|
| o . |
| oo o.o |
| oo . o|
| oooo. o |
| oooo. o|
| o . |
| oo .o |
| oo o.ooo|
| oo .ooo|
| o o.oo |
| o. o |
___________
Output
Demonstration
UVA Online Judge solution - 10878-Decode the tape - UVA Online Judge solution in C,C++,java