6 kyu

Chaser's schedule

124 of 1,075RealSup

Description:

A runner, who runs with base speed s with duration t will cover a distances d: d = s * t
However, this runner can sprint for one unit of time with double speed s * 2
After sprinting, base speed s will permanently reduced by 1, and for next one unit of time runner will enter recovery phase and can't sprint again.

Your task, given base speed s and time t, is to find the maximum possible distance d.

Input:

1 <= s < 1000
1 <= t < 1000

Example:

Given s = 2 and t = 4.
We could schedule when runner should sprint so we could get these possible sequences:

Seq.: RRRR
=> s + s + s + s
=> 2 + 2 + 2 + 2 = 8
Seq.: RRRS
=> s + s + s + s*2
=> 2 + 2 + 2 + 2*2 = 10
Seq.: RRSR
=> s + s + s*2 + (s-1)
=> 2 + 2 + 2*2 + (2-1) = 9
Seq.: RSRR
=> s + s*2 + (s-1) + (s-1)
=> 2 + 2*2 + (2-1) + (2-1) = 8
Seq.: RSRS
=> s + s*2 + (s-1) + (s-1)*2
=> 2 + 2*2 + (2-1) + (2-1)*2 = 9
Seq.: SRRR
=> s*2 + (s-1) + (s-1) + (s-1)
=> 2*2 + (2-1) + (2-1) + (2-1) = 7
Seq.: SRRS
=> s*2 + (s-1) + (s-1) + (s-1)*2
=> 2*2 + (2-1) + (2-1) + (2-1)*2 = 8
Seq.: SRSR
=> s*2 + (s-1) + (s-1)*2 + (s-1-1)
=> 2*2 + (2-1) + (2-1)*2 + (2-1-1) = 7

Where:
- R: Normal Run / Recovery
- S: Sprint

Based on above sequences, the maximum possible distance d is 10.

Enjoy!

Logic
Algorithms

More By Author:

Check out these other kata created by RealSup

Stats:

CreatedMay 25, 2022
PublishedMay 25, 2022
Warriors Trained7693
Total Skips401
Total Code Submissions16829
Total Times Completed1075
C# Completions124
JavaScript Completions286
Python Completions337
Java Completions181
Ruby Completions34
Go Completions36
SQL Completions57
C Completions63
Rust Completions50
PowerShell Completions9
VB Completions6
Crystal Completions7
Lua Completions10
Pascal Completions4
Haskell Completions8
Total Stars236
% of votes with a positive feedback rating93% of 183
Total "Very Satisfied" Votes162
Total "Somewhat Satisfied" Votes16
Total "Not Satisfied" Votes5
Total Rank Assessments12
Average Assessed Rank
5 kyu
Highest Assessed Rank
5 kyu
Lowest Assessed Rank
7 kyu
Ad
Contributors
  • RealSup Avatar
  • Madjosz Avatar
  • rowcased Avatar
  • hobovsky Avatar
  • mohrizkyk Avatar
  • Kacarott Avatar
  • dfhwze Avatar
  • sid114 Avatar
Ad