President Lincoln opened his now-legendary Gettysburg Address with the famous words "Four score and seven years ago...". Given that a score is 20, he meant 87 years ago. (The Declaration of Independence was 1776. The Gettysburg Address was 1863, 87 years later.)
In 1863, the Patriot & Union newspaper in Harrisburg, Pennsylvania, wrote a scathing editorial about Lincoln's speech. In 2013, now as the Patriot-News, they published a retraction which, in a fitting display of self-awareness, began with "Seven score and ten years ago...".
Given two equal-length vectors of years, y1 and y2, return two vectors s and y such that y1(k) is "s(k) score and y(k) years ago" from y2(k), for every k. That is, y2(k) = y1(k) + 20*s(k) + y(k). The values of s should be as large as possible, so that every element of y will be in the range [0 19].
[s,y] = sscoreandy(1776,1863)
s =
4
y =
7
[s,y] = sscoreandy([1776;1863],[1863;2013])
s =
4
7
y =
7
10
You can assume y1 and y2 will be equal-length (non-empty) vectors of positive integers, and each element of y2 will be greater than the corresponding element of y1. Although it would be weird to say "0 score and y years" (or, indeed, "s score and 0 years"), it is possible that elements of s and y will be 0.

Solution Stats

11 Solutions

9 Solvers

Last Solution submitted on Mar 16, 2026

Last 200 Solutions

Solution Comments

Show comments
Loading...