7 kyu
Cats and shelves
957 of 13,421RealSup
Description:
Description
An infinite number of shelves are arranged one above the other in a staggered fashion.
The cat can jump either one or three shelves at a time: from shelf i
to shelf i+1
or i+3
(the cat cannot climb on the shelf directly above its head), according to the illustration:
┌────────┐
│-6------│
└────────┘
┌────────┐
│------5-│
└────────┘ ┌─────► OK!
│ ┌────────┐
│ │-4------│
│ └────────┘
┌────────┐ │
│------3-│ │
BANG!────┘ ├─────► OK!
▲ |\_/| │ ┌────────┐
│ ("^-^) │ │-2------│
│ ) ( │ └────────┘
┌─┴─┴───┴┬──┘
│------1-│
└────────┘
Input
Start and finish shelf numbers (always positive integers, finish no smaller than start)
Task
Find the minimum number of jumps to go from start to finish
Example
Start 1
, finish 5
, then answer is 2
(1 => 4 => 5 or 1 => 2 => 5)
Inspirers
Algorithms
Similar Kata:
Stats:
Created | Jul 9, 2022 |
Published | Jul 10, 2022 |
Warriors Trained | 28026 |
Total Skips | 808 |
Total Code Submissions | 66897 |
Total Times Completed | 13421 |
C# Completions | 957 |
JavaScript Completions | 4041 |
Python Completions | 4046 |
Ruby Completions | 166 |
Java Completions | 1608 |
Go Completions | 377 |
PHP Completions | 343 |
TypeScript Completions | 336 |
C Completions | 396 |
COBOL Completions | 23 |
Scala Completions | 65 |
SQL Completions | 549 |
Rust Completions | 222 |
Groovy Completions | 33 |
C++ Completions | 813 |
PowerShell Completions | 47 |
CoffeeScript Completions | 18 |
Raku Completions | 14 |
Prolog Completions | 15 |
Haskell Completions | 59 |
VB Completions | 36 |
Crystal Completions | 14 |
CFML Completions | 9 |
Lua Completions | 41 |
Pascal Completions | 16 |
NASM Completions | 11 |
Kotlin Completions | 80 |
Dart Completions | 48 |
Shell Completions | 29 |
Total Stars | 344 |
% of votes with a positive feedback rating | 93% of 1141 |
Total "Very Satisfied" Votes | 1006 |
Total "Somewhat Satisfied" Votes | 116 |
Total "Not Satisfied" Votes | 19 |
Total Rank Assessments | 10 |
Average Assessed Rank | 7 kyu |
Highest Assessed Rank | 6 kyu |
Lowest Assessed Rank | 7 kyu |