Week 7
This week I didn't do to much coding I did a couple of the intermediate "basic programming" problems. What I did do was look at the competitive programming playlist. First couple videos were about reversing a list and the algorithm for doing so. But what I really found interesting was the video "numbers game" where they go through this problem where 2 people play a game where there are two numbers, A and B, you can subtract A-xB or B -xA, but the first player to get <=0 is the loser. So the video goes through cases like what threshold would mean that (A,B) would be losing or winning for player 1. We looked at examples like (12, 15) where player one can take 15- (1)12 and get (12,3) and player two can make player one lose by 12-(3)3 which gives us (3,3) meaning that that player one will lose no matter what. we then look at if (b<a<2b,b) so if a is more than b but less than 2b and we try to figure out if this is winning. We find out that we don't have enough information but this particular situation gives a forced move from player one because anything other then taking a single b from a would lose the game. Looking at another example (a>=2b,b) meaning that a is 2b or more we can transform it into( rb+c, b) where r is a coefficient and c is a remainder because when we transformed it we divided by a and from here we can force a winning position where we take r-1b away from rb and we get( b+c, b) and the player has to take b from b+c and (c,b) where c is less than b is a winning position. We do a couple more definitions and we find out that we eventually arrive at that player one is winning if (A,B) and A is greater or equal to phi(golden ratio) times b and losing other wise. We also notice that the ratios between winning and losing configurations use Fibonacci numbers like A =b is wining for player two, A>=2B is winning for player one. 2A<=3B is winning for player 2, 3A>=5B is winning for player one and so on. She says in the video not to be discouraged by not knowing Fibonacci or golden ratio because its possible to find the answer without it because all you need to know is that there is a threshold that can be met and you can find it using something like a binary search which will be covered later. Plus the more exposure the better you become.
The pictures are in reverse order but the first one is a visual to the Fibonacci(arya is p1 and bran is p2).
pictures 2-4 are visuals to the example (12,15) for the introduction to the game
At the very bottom I thought I show the little bit of code I did. Pretty easy stuff this week was mostly on wrapping my head around the number video.( also one of the codes is a redo but I did it again because the same problem was in the basic programming set)
YouTube. (2021, July 23). MOD01LEC03 - number game. YouTube. Retrieved October 21, 2022, from https://www.youtube.com/watch?v=EDOf-q_Z0Bs&list=PLyqSpQzTE6M9p9pKxFGpskf4voY45T2DZ&index=5
link for the playlist: https://www.youtube.com/playlist?list=PLyqSpQzTE6M9p9pKxFGpskf4voY45T2DZ
.png)
.png)
.png)
.png)


I found this interesting. This looks like a fun little game. This encouraged me to find the game and even code it for myself to see how it works and just for fun!
ReplyDeleteNice work this week, Ronin. Despite the exercises feeling easy, the repetition will help make these solutions more second nature to you.
ReplyDelete