Algorithm
Problem Name: 2 AD-HOC - beecrowd | 1845
Problem Link: https://www.beecrowd.com.br/judge/en/problems/view/1845
Efilogue
By Leandro Fatefko, UF Frafil
Timelimit: 1
Fo, hafe you enfoyed our afternoon together? Far fetter than going to the foo, ifn't it? The IF UF Frogramming Conteft if unfortunately coming to an end, fut we hofe that thif end meanf to you, who knowf, a new feginning: a feginning of a career flenty of fuccef! And the formula of fuccef if not too hard: do whatefer you really enfoy doing, fomething with which you hafe fun and keef motifated. After all, what if fuccef fut feeling fulfilled and hafy with yourfelf?
To end thif conteft, write one little frogram more, fuft ‘one for the road’. Write a frogram that confertf teftf to the Dinofaur Language. In the Dinofaur Language, firft we efchange fome confonantf for the letter F (cafital or not defending on the cafe) and after that we eliminate efery occurrence of confecutife refetitionf of the letter. We are not going to fay which confonantf are thefe. You are fufofed to guef them (or deduce them).
Infut
The infut confiftf of feferal linef of teft. We are not going to refeal the fofitife numfer of linef not efen the limit of characterf fy line of teft.
Outfut
Frint the teft of the infut conferted to the Dinofaur Language.
Infut Famflef | Outfut Famflef |
Hey, little train! We are all jumping on Hey, little train! Wait for me! Hey, little train! Wait for me! Hey, little train! We are all jumping on |
Hey, little train! We are all fumfing on Hey, little train! Wait for me! Hey, little train! Wait for me! Hey, little train! We are all fumfing on |
Code Examples
#1 Code Example with C++ Programming
Code -
C++ Programming
#include <iostream>
using namespace std;
int main(void) {
char x, y = '\0';
while ((x = getchar()) != EOF) {
x = (x == 'b' || x == 'j' || x == 'p' || x == 's' || x == 'v' || x == 'x' || x == 'z') ? 'f' : x;
x = (x == 'B' || x == 'J' || x == 'P' || x == 'S' || x == 'V' || x == 'X' || x == 'Z') ? 'F' : x;
if ((x != 'f' && x != 'F') || (y != 'f' && y != 'F')) cout << x;
y = x;
}
return 0;
}
Copy The Code &
Try With Live Editor
Input
The train that goes to the kingdom.
We're happy, ma, we're having fun,
And the train ain't even left the station.
Hey, little train! Wait for me!
I once was blind but now I see.
Have you left a seat for me?
Is that such a stretch of the imagination?
Hey, little train! Wait for me!
I was held in chains but now I'm free. I'm hanging in there, don't you see,
In this process of elimination.
Hey, little train! We are all jumping on
The train that goes to the kingdom.
We're happy, ma, we're having fun.
It's beyond my wildest expectation.
Output
The train that goef to the kingdom.
We're hafy, ma, we're hafing fun,
And the train ain't efen left the ftation.
Hey, little train! Wait for me!
I once waf flind fut now I fee.
Hafe you left a feat for me?
If that fuch a ftretch of the imagination?
Hey, little train! Wait for me!
I waf held in chainf fut now I'm free.
I'm hanging in there, don't you fee,
In thif frocef of elimination.
Hey, little train! We are all fumfing on
The train that goef to the kingdom.
We're hafy, ma, we're hafing fun.
It'f feyond my wildeft efectation.
#2 Code Example with Python Programming
Code -
Python Programming
while True:
try: e = input()
except EOFError: break
y = ''
for x in e:
x = x if x != 'b' and x != 'j' and x != 'p' and x != 's' and x != 'v' and x != 'x' and x != 'z' else 'f'
x = x if x != 'B' and x != 'J' and x != 'P' and x != 'S' and x != 'V' and x != 'X' and x != 'Z' else 'F'
if (x != 'f' and x != 'F') or (y != 'f' and y != 'F'): print(x, end='')
y = x
print()
Copy The Code &
Try With Live Editor
Input
The train that goes to the kingdom.
We're happy, ma, we're having fun,
And the train ain't even left the station.
Hey, little train! Wait for me!
I once was blind but now I see.
Have you left a seat for me?
Is that such a stretch of the imagination?
Hey, little train! Wait for me!
I was held in chains but now I'm free. I'm hanging in there, don't you see,
In this process of elimination.
Hey, little train! We are all jumping on
The train that goes to the kingdom.
We're happy, ma, we're having fun.
It's beyond my wildest expectation.
Output
The train that goef to the kingdom.
We're hafy, ma, we're hafing fun,
And the train ain't efen left the ftation.
Hey, little train! Wait for me!
I once waf flind fut now I fee.
Hafe you left a feat for me?
If that fuch a ftretch of the imagination?
Hey, little train! Wait for me!
I waf held in chainf fut now I'm free.
I'm hanging in there, don't you fee,
In thif frocef of elimination.
Hey, little train! We are all fumfing on
The train that goef to the kingdom.
We're hafy, ma, we're hafing fun.
It'f feyond my wildeft efectation.