aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--challenge-083/pkmnx/c/ch-1.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/challenge-083/pkmnx/c/ch-1.c b/challenge-083/pkmnx/c/ch-1.c
new file mode 100644
index 0000000000..837b5927d7
--- /dev/null
+++ b/challenge-083/pkmnx/c/ch-1.c
@@ -0,0 +1,37 @@
+#include <stdio.h>
+#include <ctype.h>
+
+int main() {
+
+ char c;
+ char state;
+
+ long tot = 0;
+ long acc = 0;
+ long c_cnt = 0;
+
+ while ( (c = getchar()) != EOF ) {
+
+ if ( isspace(c) ) {
+ state = 's';
+ } else {
+ state = state == 's' ?'c' :'w';
+ acc++;
+ }
+
+ if ( c_cnt >= 1 ) {
+ tot += state == 'c' ?acc : 0;
+ }
+
+ if ( state == 'c' ) {
+ c_cnt++;
+ acc = 0;
+ }
+
+ }
+
+ printf( "%ld\n", tot );
+
+ return 0;
+
+}