John and Ann sign up for Codewars
Description:
John and his wife Ann have decided to go to Codewars. On the first day Ann will do one kata and John - he wants to know how it is working - 0 kata.
Let us call a(n)
- and j(n)
- the number of katas done by Ann - and John - at day n
. We have a(0) = 1
and in the same manner j(0) = 0
.
They have chosen the following rules:
On day
n
the number of katas done by Ann should ben
minus the number of katas done by John at dayt
,t
being equal to the number of katas done by Ann herself at dayn - 1
On day
n
the number of katas done by John should ben
minus the number of katas done by Ann at dayt
,t
being equal to the number of katas done by John himself at dayn - 1
Whoops! I think they need to lay out a little clearer exactly what there're getting themselves into!
Could you write:
- functions
ann(n)
andjohn(n)
that return the list of the number of katas Ann/John does on the firstn
days; - functions
sum_ann(n)
andsum_john(n)
that return the total number of katas done by Ann/John on the firstn
days
Examples:
john(11) --> [0, 0, 1, 2, 2, 3, 4, 4, 5, 6, 6]
ann(6) --> [1, 1, 2, 2, 3, 3]
sum_john(75) --> 1720
sum_ann(150) --> 6930
Note:
Keep an eye on performance.
Similar Kata:
Stats:
Created | Jun 9, 2016 |
Published | Jun 9, 2016 |
Warriors Trained | 22593 |
Total Skips | 7741 |
Total Code Submissions | 22312 |
Total Times Completed | 3899 |
Ruby Completions | 115 |
Python Completions | 771 |
JavaScript Completions | 522 |
CoffeeScript Completions | 7 |
TypeScript Completions | 110 |
Java Completions | 561 |
C# Completions | 297 |
Haskell Completions | 61 |
Clojure Completions | 33 |
Elixir Completions | 35 |
C++ Completions | 394 |
PHP Completions | 137 |
Crystal Completions | 8 |
F# Completions | 29 |
C Completions | 186 |
OCaml Completions | 25 |
Rust Completions | 292 |
Swift Completions | 73 |
Go Completions | 165 |
R Completions | 32 |
Shell Completions | 8 |
Kotlin Completions | 85 |
Fortran Completions | 8 |
Julia Completions | 18 |
NASM Completions | 6 |
Groovy Completions | 10 |
Scala Completions | 45 |
PowerShell Completions | 7 |
Nim Completions | 4 |
Reason Completions | 3 |
Racket Completions | 12 |
VB Completions | 9 |
Dart Completions | 55 |
Pascal Completions | 5 |
Lua Completions | 30 |
Perl Completions | 4 |
Elm Completions | 2 |
D Completions | 4 |
Erlang Completions | 3 |
Total Stars | 478 |
% of votes with a positive feedback rating | 85% of 616 |
Total "Very Satisfied" Votes | 459 |
Total "Somewhat Satisfied" Votes | 135 |
Total "Not Satisfied" Votes | 22 |