← Questions
Compress URL path segments under token limits
0
I was asked this
No reports yet. Sign in to say where you were asked it.
A path such as alpha.beta.gamma/delta.echo has major parts separated by / and minor parts separated by .. A word is compressed by keeping its first and last letters and replacing the middle with the count of letters removed (alpha becomes a3a).
- Compress every minor part.
- Each major part may produce at most
mtokens: compress its first minor parts one by one and merge the rest into one final token, compressed from the original letters. - The whole path may produce at most
ttokens: every major part keeps at least one, and the remaining budget is handed out from left to right.
No official answer yet. Write yours on the right and run it.
Nothing published yet.
Sign in to submit your code; every attempt is kept here.
Write and test your solution herePython in your browser, the question's tests level by level, every submission kept for you.Sign in to start coding
