Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
It's not that the second 30 takes precedence exactly, it's that the team that scored 40 must be higher than both of its neighbours - and the second 30 can be deduced to have a value of 3... but as you've discovered, not by taking into account only the information on its left hand side.
How might we figure that out?
However, i am missing the point on this testcase
[20, 30, 40, 30, 20, 10]), 13
13 would result from this
[1 2 4 3 2 1]
is tht right?
if that is so, then 20 has no visibility, so it will get a 1
30 can see 20, so it will be 1+1 = 2
40 can see 30 on its left and 30 on its right
However it seems that the 30 on its right takes precedence.... why? is there still something i am
not seeing?
Thanks again and regards
Marco
your explanation is v clear. by adjacent i inferred only the team before..not the team before and the one after.my bad.rhanks for following up
As said in description:
This means the first team (team who scored 30) will know the bonus amount of the second team (team who scored 20), the second team will know the amount of bonus from the third team (team who scored 10). Also said in description that:
First we know that the third team knew none of the other teams' score, therefore they get the lowest of
1
bonus. Secondly, the second team knew the score of third team (which means second team have a higher amount of score), therefore they needed a bonus amount higher than 1, which is2
. We can also use the same logic to get the amount of bonus for the first team, they needed a bonus higher than 2, which is3
. Then we add all the bonuses together to get:1+2+3=6k, so the answer is 6 for minimum bonus. Sorry if my explaination isn't clear enough :)
HI guys
sorry, for this testcase [30, 20, 10] why should the minimum bonus be 6?
the first team does not know, so it gets 1k, the second team does not know, so it gets 1k
and the third team does not know, so it should get 1k.
Where does the 6 come from ? nobody in this sequence will know the amout of the adjacent?
Kind regarsd
marco
This comment is hidden because it contains spoiler information about the solution
sorry guys i dont undestand. I am given a query function,but i dont know N at all. where do i get N from?
Kind regards
Marco
Hi all
uhm i am seeking some hints here as my code runs out of time
So i take it i'd need to use an efficient algo to find the prime factors, and once i have the prime factors i can then generate divisors out of prime factors,.
Sort of two loops,where the first one is 'expensive' and the second one should be a 'small one'
Giving my code is runnign out of time i am guessing my prime factorization code is deficient...
is there a formula somewhere to find prime factors?
Kind regars
Marco
Great! thanks! i think i figured it out on paper by just observing relationship between runs of the algo for 1..10 and it looks like another well known series .
I cant believe this is pure coincidence.. would you mind sending me some useful links on this
to my private email mmistroni@gmail.com ?
Many thanks for putting me on the right track!
moderator feel free to ban this comment if it gives the solution away
kind regards
You're on the right track thinking about recursive algorithms and your deductions so far are almost correct. If
permutations(5)
is made up of(5-1) == 4
branches as you say, each having 11 leaves, how might we derive that number 11? You say it'spermutation(n-1) - <something>
butpermutations(5-1) == permutations(4) == 9
as you say, which is smaller than 11... so something is being added, not subtracted.Hi all
am a little bit rusty on math and i need a starting point
Have kicked off a brute force algo, can see that for
n=4 we have 9 possible permutations, 3 starting with 2, 3 starting with 3 and 3 starting with 4
n=5 we have 44 possibilties, 11 starting with 2, 11 starting with 3, 11 starting with 4, and 11 starting with 5
so the number of permutations are always the same for 1 < i <=n, which seems to be
permutation(n-1) - "something which i can figure out"
Could anyone give me a trace without exposing to much?
Kind regars
Marco
I believe this is the 2kyu kata for anyone interested https://www.codewars.com/kata/evaluate-mathematical-expression/
Duplicate of a 2 kyu kata, except without parentheses. I can literally copy-paste my JS or Python solution from the 2 kyu one and paste here and it will immediately pass.
This comment is hidden because it contains spoiler information about the solution
Many thanks, understood!
kind regards
Loading more items...