Write a method that finds each occurrence of abc_ in a String input (where _ is a single character) and prints bc_ for each such occurrence. For example, find Abc(abcdefg) should print:

Example 1: javascript create a function that counts the number of syllables a word has. each syllable is separated with a dash -.

function new_count(word) {
  word = word.toLowerCase();                                     //word.downcase!
  if(word.length <= 3) { return 1; }                             //return 1 if word.length <= 3
    word = word.replace(/(?:[^laeiouy]es|ed|[^laeiouy]e)$/, '');   //word.sub!(/(?:[^laeiouy]es|ed|[^laeiouy]e)$/, '')
    word = word.replace(/^y/, '');                                 //word.sub!(/^y/, '')
    return word.match(/[aeiouy]{1,2}/g).length;                    //word.scan(/[aeiouy]{1,2}/).size
}

console.log(new_count('she'));
console.log(new_count('spain'))
console.log(new_count('softball'))
console.log(new_count('contagion'))

Example 2: Write a JAVA method that expands a given binomial (ax + by)n, where integers a, b, n are user inputs. For example, if a = 2, b = -12, n = 4 are entered the method should print or return

Write a JAVA method that expands a given binomial (ax + by)n, where integers a, b, n are user inputs.  For example, if a = 2, b = -12, n = 4 are entered the method should print or return

Example 3: write a bash script that accepts a text file as argument and calculates number of occurrences of each words in it and return them as key value pairs

file=/home/stefan/ooxml1.txt
for word in $(sed 's/[^A-Za-z]/ /g' $file | tr " " "\n" | sort -u)
do
  echo -n "$word "
  grep -c $word $file
done | sort -k2 -n

Tags:

Java Example