15 Oct
Posted by admin as Announcements, PHP Scripts and Tools
Students who are interested to try this problem can earn and extra points or exemption for finals. Solve the problem using PHP scripting language.
Show your codes on October 19, 2008 (9:00) to your instructor for checking and evaluation.
The problem was excerpt from HP CodeWars 2009.
Redundant Acronym Syndrome Syndrome
Task Description
From Wikipedia, the free encyclopedia:
The term RAS syndrome refers to the use of one of the words that make up an acronym as well as the abbreviation itself, thus in effect repeating that word. It stands for “Redundant Acronym Syndrome syndrome,” and is itself a humorous example of a redundant acronym.
Write a program that generates RAS syndrome acronyms.
Program Input
Each line of the input contains one or more words. The line of text will be no longer than 80 letters, spaces, and/or punctuation. The last line of the input is the word END.
automated teller machine
random access memory
alternating current
scholastic aptitude test
international standard book number
END
Program Output
The program must print the acronyms in RAS syndrome format. For this program you can assume that the repeated word is always the last word of the input line. Acronyms must be upper-case, regardless of the case of the input.
ATM machine
RAM memory
AC current
SAT test
ISBN number
4 Responses
domingo cristina
October 18th, 2009 at 1:35 am
1sir gud pm is it dynamic?
admin
October 18th, 2009 at 5:29 pm
2anything will do.
kathrina
October 19th, 2009 at 3:52 am
3<?php
$str = 'automated teller machine
random acess
alternating curr
end’;
$e=”;
$end=’end’;
if(stripos($str,$end) === false) {
echo ‘the word end is not yet used’;
}
else{
if(strlen($str) <=80){
$newstr = array();
$str = split(' ',$str);
foreach ($str as $val) {
if(strpos($val,$e)!==true){
$newstr[] = substr(strtoupper($val), 0, 1);
}
$newstr[] = substr($val, 0, strpos($val, $e));
$newstr[] = substr('’, ”, strpos($val, $e));
}
$x=implode(” “, $newstr);
echo strtoupper($x);
}
else{
echo ‘it is already ‘. strlen($str).’words’;
echo “it should not be more than 80 words “;
}
}
?>
kathrina
October 19th, 2009 at 3:54 am
4<?php
$str = 'automated teller machine
random acess
alternating curr
end
‘;
$e=”;
$end=’end’;
if(stripos($str,$end) === false) {
echo ‘the word end is not yet used’;
}
else{
if(strlen($str) <=80){
$newstr = array();
$str = split(' ',$str);
foreach ($str as $val) {
if(strpos($val,$e)!==true){
$newstr[] = substr(strtoupper($val), 0, 1);
}
$newstr[] = substr($val, 0, strpos($val, $e));
$newstr[] = substr('’, ”, strpos($val, $e));
}
$x=implode(” “, $newstr);
echo strtoupper($x);
}
else{
echo ‘it is already ‘. strlen($str).’words’;
echo “it should not be more than 80 words “;
}
}
?>
RSS feed for comments on this post · TrackBack URI
Leave a reply
Categories
Archives
Links
Meta
Calendar
Recent Entries
Recent Comments
Most Commented
ICT News and Updates is proudly powered by WordPress - BloggingPro theme by: DesignDisease, Bikes Brands