Algorithm
Problem Name: beecrowd | 2165
Problem Link: https://www.beecrowd.com.br/judge/en/problems/view/2165
Twitting
By M.C. Pinto, UNILA Brazil
Timelimit: 1
Twitter microblog is known for restricting its posts at 140 characters. Your task is to check if a text will fit in a tweet.
Input
Input is a text line T (1 ≤ |T| ≤ 500).
Output
The output is given in a single line. It must be "TWEET" (without quotes) if the text line T is up to 140 characters long. If T has more than 140 characters, the output must be "MUTE".
Input Sample | Output Sample |
RT @TheEllenShow: If only Bradley's arm was longer. Best photo ever. #oscars pic.twitter.com/C9U5NOtGap |
TWEET |
Code Examples
#1 Code Example with C Programming
Code -
C Programming
#include <stdio.h>
#include <string.h>
int main(void)
{
char str[500];
int i;
scanf("%[^\n\r]", str);
i=strlen(str);
if (i>140)
printf("MUTE\n");
else
printf("TWEET\n");
return 0;
}
Copy The Code &
Try With Live Editor
Input
Output
#2 Code Example with C++ Programming
Code -
C++ Programming
#include <iostream>
#include <string>
int main(){
std::string tweet;
std::getline(std::cin, tweet);
if (tweet.size() < = 140) {
std::cout << "TWEET" << std::endl;
}else {
std::cout << "MUTE" << std::endl;
}
return 0;
}
Copy The Code &
Try With Live Editor
Input
Output
#3 Code Example with Javascript Programming
Code -
Javascript Programming
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var lines = input.split('\n');
var prompt = function(texto) { return lines.shift();};
const tweet = prompt();
if (tweet.length > 140) {
console.log("MUTE");
} else {
console.log("TWEET");
}
Copy The Code &
Try With Live Editor
Input
Output