Files

32 lines
825 B
Java
Raw Permalink Normal View History

2017-02-12 00:31:12 -08:00
// Author: Rodney Shaghoulian
2018-07-27 16:45:56 -07:00
// Github: github.com/RodneyShag
// HackerRank: hackerrank.com/RodneyShag
2017-02-12 00:31:12 -08:00
2017-02-09 02:12:38 -08:00
import java.util.Scanner;
public class Solution {
public static void main(String[] args) {
/* Read input */
Scanner scan = new Scanner(System.in);
String s = scan.nextLine();
scan.close();
2017-02-21 00:05:09 -06:00
s = s.trim(); // so that .split() works properly
2017-02-09 02:12:38 -08:00
/* Check special cases */
if (s.length() == 0) {
System.out.println(0);
return;
}
/* Split on all non-alphabetic characters */
String [] words = s.split("[^a-zA-Z]+");
/* Print output */
System.out.println(words.length);
for (String word : words) {
System.out.println(word);
}
}
}