]
function process(){
for(i=0; i< input.length; i++){
var x = input.substring(i,3)
if ( x === 'ABC'){
console.log('match ABC');
}
if ( x ==='CDX'){
console.log('match CDX');
}
}
// alert('hello');
] CODE BLANK
process.stdin.resume();
process.stdin.setEncoding('utf8');
fullInput = ''
process.stdin.on('data', function(chunk) {
if (chunk !== null)
{
fullInput += chunk;
}
});
process.stdin.on('end', function() {
solveProblem(fullInput);
});
function solveProblem(input)
{
// Your code goes here. Replace "output" with what you need to print.
// You can use multiple write statements.
var output, match;
for(i=0; i<input.length; i++){
output = input.substring(i,3);
if (output === 'FIZ' || 'BAZ'){
match = true;
output = 'BBFF';
}
// i++;
}
//output = '';
process.stdout.write(output);
}
] CUT
if (output === 'FIZ' || 'BAR'|| 'BAZ'|| 'ZIF' || 'RAB' || 'ZAB'){
match = true;
output = 'BBFF';
}
]
http://stackoverflow.com/questions/21895233/how-in-node-to-split-string-by-newline-n
] // EX 4
var input = 'BFIZBRAFBF';
var output = 'ABC';
var f,b,r,x,y,z ;
var cuts = [];
function process(){
for(i=0; i<input.length; i++){
output = input.substring(i,3);
// test for each set chars to find, if match save index of
if (output === 'FIZ' ) {
cuts.push(i);
}
if (output === 'BAR'){
cuts.push(i);
}
if (output === 'BAZ'){
cuts.push(i);
}
if (output === 'BAR'){
cuts.push(i);
}
if (output === 'ZIF'){
cuts.push(i);
}
if (output === 'RAB'){
cuts.push(i);
}
if (output === 'BAZ'){
cuts.push(i);
}
}
// walk through each of the matched char sets, remove matched chars from original string
if ( cuts.length > 0){
for (i=0; i< cuts.length; i++){
// index value of a matched item
var startCut = cuts[i];
var tempStr1, tempStr2;
// characters to remove // 10
// last part of string
tempStr1 = input.substring( input.length - ( startCut + 3) );
tempStr2 = input.substring(0, startCut);
output = tempStr1 + tempStr2;
// input.substring( (input.length - startcut), 3) input.substring(startCut,3);
//
console.log(output);
}
}
console.log(output);
}
process();