int64_t Problem17::solve() { int letterCount = 0; for(int i = 1; i <= PROBLEM_SIZE; ++i) letterCount += getLetterCount(i); return letterCount; }
const char* ofxTextAlign::drawLine(const char *str, float x, float y) { const char *ptr = str; int letter_count = getLetterCount(str, true); float extra_spacing = letter_count>1?(getDrawWidth(str, true)-getWidth(str, true))/(float)(letter_count-1):0; while(*ptr != '\0') { if(*ptr=='\n') { ++ptr; break; } float interval = getAdvance(*ptr) + getKerning(*(ptr+1), *ptr) + extra_spacing; ptr = drawChar(ptr, x, y); x += interval; } return ptr; }
float ofxTextAlign::getOffsetX(const char *str, unsigned int flags, bool single_line) { unsigned int flag = flags&HORIZONTAL_ALIGN_MASK; if(HORIZONTAL_ALIGN_LEFT == flag) { return 0; } else if(single_line && getLetterCount(str, true) < 2) { float width = getAdvance(*str); switch(flag) { case HORIZONTAL_ALIGN_CENTER: return -width/2.f; case HORIZONTAL_ALIGN_RIGHT: return -width; } } else { float width = getDrawWidth(str, single_line); switch(flag) { case HORIZONTAL_ALIGN_CENTER: return -width/2.f; case HORIZONTAL_ALIGN_RIGHT: return -width; } } return 0; }