Day 2 Answer Key
Day 2 Answer Key
#!/bin/python3
import math
import os
import random
import re
import sys
#
# Complete the 'camelcase' function below.
#
# The function is expected to return an INTEGER.
# The function accepts STRING s as parameter.
#
def camelcase(s):
count=0 #initial value of count
for i in s:
if i.isupper():
count=count+1
count=count+1 #adding count of the first word which starts with small letter
return count
if __name__ == '__main__':
fptr = open(os.environ['OUTPUT_PATH'], 'w')
s = input()
result = camelcase(s)
fptr.write(str(result) + '\n')
fptr.close()
USING JAVA 8
class Result {
/*
* Complete the 'camelcase' function below.
*
* The function is expected to return an INTEGER.
* The function accepts STRING s as parameter.
*/
USING C
#include <assert.h>
#include <ctype.h>
#include <limits.h>
#include <math.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
char* readline();
/*
* Complete the 'camelcase' function below.
*
* The function is expected to return an INTEGER.
* The function accepts STRING s as parameter.
*/
int camelcase(char* s) {
int count = 1; // First word is lowercase
return count;
}
int main()
{
FILE* fptr = fopen(getenv("OUTPUT_PATH"), "w");
char* s = readline();
fclose(fptr);
return 0;
}
char* readline() {
size_t alloc_length = 1024;
size_t data_length = 0;
while (true) {
char* cursor = data + data_length;
char* line = fgets(cursor, alloc_length - data_length, stdin);
if (!line) {
break;
}
data_length += strlen(cursor);
alloc_length <<= 1;
data = realloc(data, alloc_length);
if (!data) {
data = '\0';
break;
}
}
if (data[data_length - 1] == '\n') {
data[data_length - 1] = '\0';
if (!data) {
data = '\0';
}
} else {
data = realloc(data, data_length + 1);
if (!data) {
data = '\0';
} else {
data[data_length] = '\0';
}
}
return data;
}