So, within the latest patch to power world, they buffed Dig Toys and his ability to farm that ore. To a point now where the Dig Toys I created and actually meant to share with you guys last week is unreal in regards to farming ore for that metal. Top 2 in the game without a shadow of a doubt. And in this video guys I'm going to showcase to you how you can create the ultimate Dig Toys. How's it going people? My name is DPJ and before we go any further I'm giving away a couple of copies of this game or any game of your choice. To be in the chance of winning, simply drop a like on this video, leave a comment down below and make sure you are subbed with those notifications turned on, good luck everybody. So Dig Toys when this game first released was considered the best early game power for farming ore. It was then quickly realised in fact Dig Toys was far from the best, as when set as a base power it was actually quite slow and did minimal damage to those rocks. But I wanted to test something out to see if Dig Toys can be made better and while the outcome I created even before the latest patch was a Dig Toys that just ate through rocks like unbelievably. Now the latest patch has seen a set improvement to Dig Toys' partner skill but actually guys I think as a whole even without using his partner skill he is a much much better power than it was previously at farming those rocks. In this video guys I will show you the simple way to create yourself the ultimate Dig Toys with the best passives and how to get them actually very easily. Ok so the end Dig Toys we want passives are Legend, Earth, Emperor, Morselhead and Ferocious. So let's start people and firstly you want to get yourself a Dire Howl which has both Ferocious and Morselhead on it.  And now the end goal is one Dire Howl with both passives on and nothing else. This will mean you have to breed Dire Howls to get said passives.  Then I just bred said Dire Howls until I got that one Dire Howl with both passives on Morselhead and Ferocious with no other passives on. These are the only two you want on that Dire Howl baby so keep breeding guys until you get these. Ok so from here guys now we have that Dire Howl with Ferocious and Morselhead on. We need to get ourselves the Legend Passive. This means you need to go out guys and get either Jet Ragon, Palladius or Necromus. These are obviously the legendary level 50 world bosses but we need that Legend Passive and we need it on our Dig Toys and these are the three I do recommend you go on that and get in because when we breed these with Dire Howl it gets us to that next level and this is the easiest way of doing this. Me personally out of these three I think Jet Ragon is the easiest to catch, Palladius and Necromus come as a pair so you have to fight them both at the same time. Jet Ragon is an easy catch in my opinion I mean a lot of people struggle with this dude but hey get either of these guys you need one of these three because we need to breed these to get that Legend Passive and Passive on. So once you have said legendary pal you now guys want to breed this pal with that Dire Howl we created earlier. Now the baby is a guaranteed Anubis but what we actually want here guys is a baby Anubis with Legend, Ferocious and Morselhead. We don't want any other passives on that Anubis. Now as of right now there is a bog on the game that certain powers that have been bred after the latest patch will drop with sometimes a guaranteed Passive and Anubis is one of them. Anubis will now be bred and guaranteed I believe with Earth Emperor. Now they did say that they're going to actually revert this change they're going to revert this bog so they're calling it a bog but to be honest the Earth Emperor Passive is what we want an Anubis baby but if you watch this video and have already reverted this change where you won't get a guaranteed of Earth Emperor on your Anubis baby what you want to do from this point guys is go out and catch the world boss the Alpha Anubis team right here on the map and once you catch this guy he's guaranteed to have that Earth Emperor on so once you have this world boss Alpha Anubis you want to breed this with the Anubis you just created which would have Legend, Morselhead and Ferocious on breed these two together guys until you get that Anubis baby with all four passives on Earth Emperor Legend, Ferocious and Morselhead that is the outcome we want guys so once you have this Anubis baby put him to decide for a quick second now what you want to do next is just three choices here you can either go out and catch a Roshor, a Leespunk or a Leespunk Ignis now it doesn't matter which one you go out and catch but you need to get one of these three with zero passives on it obviously I went for Roshor it's so easy spine absolute clear mile these are found all over the early parts of the map and like a level three to a level six so you can get these at super super low levels but yeah you want to get one of these any of these three powers with zero passives on so keep capturing these guys until you get one with zero passives on that is our main goal right here people but once you have that said power with zero passives on again Roshor, Leespunk or Leespunk Ignis you now want to breed this with your Anubis we created earlier this guarantees you a Dig Toys baby but obviously you want that Dig Toys baby with all four passives on it and they are Legend, Earth Emperor, Moserhead and Ferocious these all in one way or another will affect the attack power of your Dig Toys meaning when it comes to farming those rocks people it terrorizes them breaking them down in seconds minimal seconds now as you're seeing unscrew now this Dig Toys I created for the most part doesn't even need or require that partner skill active to break down these rocks in seconds guys with the partner skill active is even crazier now obviously my Dig Toys is a level 4 in that condensation machine mean I've condensed another 160 Dig Toys into him which I definitely recommend you doing guys this will considerably make him a much much better power performing them rocks for you I mean you can simply just carry on breeding your Roshor and your Anubis for that for that Dig Toys keep doing this over and over then when you get baby pairs of mating pairs let's breed them together too so you have in total 116 we need 116 spare Dig Toys to condense into our main farming Dig Toys and then guys obviously you want to be using those power souls at the statue of power and level up a minimum of your Dig Toys is a attack this will see your Dig Toys being an otter monster now what I will see is obviously there's powers in the game which will buff your earth power your ground power upon having them in the same party as your Dig Toys this really isn't necessary you don't need this I mean as you can see I don't have any of these in my party and my Dig Toys absolutely terrorizes rocks and actually guys increase the health of my rocks in my world settings so it actually even destroyed its rocks even quicker than what you'll see mine do on screen now so yeah keep that in mind but yeah guys this dig toys right now is up there with the best mining powers in the game it isn't as good as the gun but when I made and made a video on with that lightning strike because it would take out like 10 rocks in a second but basically he's probably the second or third best mining power in this game especially guys if you run around with him in your party and just throwing him at his rocks he's unbelievable so yes if you want the best dig toys for farming in this game do what you got to do and follow this guide but on that note at the end of the video has arrived if you enjoyed it leaving a like really helps out if you like what you see and want to see more power world be sure to subscribe and hopefully guys I will see you on that next one


It's noiseless, fly repellent fan, chemical free, and hangable. You can also hang this thing, so it just says fly repellent, but I was reading on the website where it's supposed to be repellent mosquitoes. But what it is, it's mostly for flies if you're sitting outside and we all know it's like to have a picnic right and you're sitting at the picnic table or what not you got your flies flying around you're always gonna like that we all hate that so it's packaged nice very nice little phone okay we're gonna open this up and you can hang it as well like that okay then you can put it down there where you can put it down there goes up here like that you can put essential oils down in here that also help repel bugs there it is you can feel click into place when you turn them here's where the batteries go right here okay so let's put the batteries in here we're going to open the bottom up raise it up a little bit here like that let's turn it on just turn it on set it down there and the flies should stay away from this thing and if you need more and turn the turn another one on that's hitting the tripod let me back up and there you go


In April 2022, MPs sent a fact-finding mission to document civilian protection challenges in Lviv, Kiev, Nipro, Zaparyja, Odessa, Mikolayev, Kharkiv and Tuhuv. Our teams prioritized identifying civilian protection needs and priorities, specifically in the hard-to-reach and frontline areas with the focus on civilians' exposed to vulnerabilities, namely the elderly and people with special needs. Christina, I am here with Nonviolent Peace Force. We are an international humanitarian organization that provides protection, unarmed protection to civilians in conflict zones. Today we are in Kharkiv, one of the cities that has been affected by the violent conflict in Ukraine most. Behind me you see a damaged apartment block, a huge building that has been hit by a missile. We've spent this afternoon talking with some residents that were able to escape most of the fire and are now sheltering in accommodation nearby. Ongoing violence, reluctance or inability of older people and those with disabilities or health concerns to evacuate, closures of public transport and essential businesses and socioeconomic disadvantage have compounded and create situations in which people with special needs are isolated and unable to access services. Where these populations have been identified, the majority burden of providing support has been placed on the self-organized local volunteers. During the mission assessment period MP engaged with a variety of local stakeholders, including women's centers, human rights activists, religious leaders, representatives of the Ukrainian government, volunteer collectives, civil society organizations, national and non-governmental organizations and emergency response teams. It became quickly clear that these groups are leading the humanitarian response in Ukraine. The Ukrainian machine moving into Ukraine is very hierarchical and the response that is most effective is coming from local organizations and civilian-led volunteer mechanisms. MP's unique responsibility in this is to be the bridge, being the bridge to fill the gap between the on-the-ground local organizations and then the humanitarian structures that would be able to provide the much needed service provision. Despite the leading role of local actors in frontline efforts, the vast majority of resources remain concentrated with international agencies. Although some of the local humanitarian organizations interviewed by MP have partnered with international actors to receive funding to conduct such operations, more support is needed. Frontline efforts are further hampered as a result of damaged civilian infrastructures. The Russian forces are continuously targeting Ukraine's power stations, causing massive blackouts across the country. Residents are being urged and in some cases forced by circumstances to conserve water and energy. Destruction of houses and lack of access to fuel and electricity due to damaged infrastructure could become a matter of life or death. To support self-protection strategies already adopted by local organizations and help them better observe safeguarding and do-know-how principles while implementing humanitarian activities, MP has began delivering trainings on unarmed civilian protection. Programme contents have included introduction to unarmed civilian protection methods, at MP's values and principles, namely non-violence, primacy of local actors. In anticipation of the fast approaching winter months, MP aims to continue to support the hyper-local response structures, focus on civilian protection and the delivery of aid. Ukrainian women's networks have been central to the humanitarian aid response here in Ukraine. There are a number of women's networks who are running shelters, who are running evacuation networks, moving women and children from the east and the south areas that have been occupied or under threat by the Russian forces, and moving them into Western Ukraine and into Europe as well, so the humanitarian response has been incredibly women-led, incredibly youth-led, and it's been such a privilege to see.


Hi, I'm Simon. Thanks for joining me in this talk. I know there's a bunch of talk going on in parallel right now And I really appreciate your interest. I hope to make it interesting for you Today I'll talk about next-generation extension model for enterprise applications so what we'll look at is everything is moving into the cloud and Enterprise software is the next step exception. So It comes with a lot of problems when enterprise software is tuned to a customer's needs and he writes all sorts of extensions and Deploy to the cloud. We'll talk about how we solve that using serverless. I will introduce you to a new software called Kima Which is open source followed by a demo So again, my name is Simon. I'm a developer with SAP customer experience. We deal with end-to-end e-commerce solution in a rapidly scalable cloud landscape So cloud applications as they say make the big ship move This big ship which can be compared to enterprise software. It has a bunch of Features to it, right? That's there for the reason it's solving problems for big enterprises But in order to tune it to for specific customer needs customer right extensions and then moving this big ship gets There's a big hassle around it. So Let's dig deep So a bunch of our customers are using on-premise model So what happens is They write extensions they develop in their on-premise along with the extensions a typical extension development Lifecycle would be you write the extensions, of course, and then you test it and then you deploy so One advantage to this process is you have close connection to the code the developers had Closed connection with the code meaning if there is anything breaking during deployment A developer could take a look or fix it if needed This was all good, but then upgrades are the problem because up extensions were tightly coupled to the core and you couldn't upgrade easily And in the end what happened was customers Was running primitive versions of the enterprise software So this was not the way to go So Andrew came cloud model Let me set the context so in a cloud model what happens developers would write the extensions Give it to the operator operator will package with with the core of the enterprise software and then deploy it But there are two problems with this One would be the developer didn't have close contact with the code So as a result the operator would deploy in his own schedule. There can be time differences whatsoever so there is no immediate feedback and There's a long deploy time along with maintenance window because we are dealing with a beast of a software, right? And it's often bundled with other updates It's done that that way because This process is expensive. You don't want to do that too often and then The operator who is handling the core with extensions is having a varied set of Extensions, right? There's a bunch of customers with the different needs different sorts of extensions and that resulted in Snowflake deployments troubleshooting became a nightmare and it was really hard to update so We'll take a look what serverless is and then I'll try to connect the dots By solving the problem that I stated with Kima so As per Martin follower comm Who has all the definitions of the latest buzzwords? It service composed of three basic things The first is an ecosystem of third party services Which will work with client side logic and that all will be wired With remote procedure calls Which is hosted so you don't have to deal with servers But this is pretty obscure right now. Let's look at it pictorially Okay, so this that's a cloud in your left with a bunch of managed services There can be authentication service mail server or even database service Which is used by a client logic can be a Java JavaScript single-page application Imagine that a user needs to authenticate it so the client code can straight away use the authentication service from the cloud provider And then comes this lambda which is the function of the fast as a service. So function as a service There you would write all the back in code and mash them in order to serve the single page application and in turn It's gonna use this bunch of third party services in the cloud a Disclaimer here is fast is not the same as serverless. So fast is just your back-end service Back-end code running on service, which you don't have to take care, but serverless is the whole ecosystem of fast Third party services and your client code all wired up together So let me introduce you to chemo. This is open source And it's pronounced as chemo. It's a Greek word. It means waves as in wave of the sea so what happens in chemo is the hexagon is a chemo which is running on Kubernetes and The lambdas represent the functions in Circles and the hexagons are microservices. So what we are saying is we could extend enterprise software By writing either lambdas or microservices, which is running on Kubernetes and it's your place an important role Where it provides a service mesh around all the services Even it has a pluggable policy Layer which enables you to control rate limits or access control coders and With Kubernetes we get all the cloud native features like scalability or fault tolerance to name a few And these are all isolated from each other in Kubernetes world There is pods which is a group which is a collection of one or more containers and that way each lambda can be scaled or brought down without any impact to the surrounding and Now this enterprise software which gets hooked to chemo through applications connector An application connector is the secure channel from your enterprise software to chemo In a true serverless world, it's always even driven where some evens trigger your compute Stateless functions and do a certain job and that's the reason we have an even bus integrated with chemo it's based on that streaming and There we I try to show like the events flowing from the enterprise software to chemo to trigger these lambdas or microservices Solving a problem and next piece here, which is a service catalog So we said we need an ecosystem of third-party services, right? So that's what service catalog and a built in Kubernetes We'll take a look in the in detail the next slide So we have this console UI Which lets you manage all the resources in Kubernetes as well as chemo Like chemo uses a lot of custom resource definitions So custom resource definitions in Kubernetes is a way to extend Kubernetes API in order to do a custom functionality We use extensively to do a certain piece of function in chemo and You may use a graphical user as well as console CLI to do a certain job And this API gateway lets you control all the ingress egress into the cluster So service catalog service catalog It extends Kubernetes API in order to use the applications In order to make use of the third-party services in your applications running in Kubernetes And you could hook service brokers which are following open service broker API spec In order to list provision and bind the services to your functions or microservices and since it's well known With all the renowned cloud providers. So essentially you can use Most Common or the useful managed services in chemo to solve a problem So let's zoom into the fast in chemo a bit So right now in chemo we we are leveraging cube less to To work as a platform as a function as a service platform So what happens is you write a function and then it gets stored as a custom resource definition Inside chemo and there is cube less controller Manager which kicks in and it creates deployment pods and services for that function So a function again, it's a pod running inside Kubernetes Which is totally isolated from all other functions or microservices Now you may trigger the function in two different ways the first one would be through HTTPS You could expose the function outside the chemo cluster in a secured way with HTTPS In turn we use a CRD call API and bunch of Istio CRDs as well to achieve this Or There can be a trigger coming from outside landing into nets or the even bus It has few more components is the even bus is just based on nets and that's going to trigger the function to Work and finally we would set the context the context Using the service binding so using the service catalog We got instantiate a service instance, which we will Bind to a lambda or a microservice using service binding and what happens is the Connection details or the secrets gets injected to the lambda Function and the user can just use it without knowing much Like the details about it So a few aspects of operations inside Kima It comes with It is packaged with well-known solutions like Prometheus Grafana for monitoring for a logging We use ok log and for tracing Yeager and Under the hood it's all Kubernetes Istio, which is done. So what we are saying is the developer can Enjoy the cream, which is the built-in dashboards or the UI is to track and debug the microservices And we take care of the platform, which is running on Kubernetes Istio and open tracing Logspot is used to feed the logs to ok log so that it can be viewed in the UI So let's look at the demo scenario I were recording for the demo and I think that will never break for sure Okay, so What I have here, of course, I have a Kima cluster Lambda which is listening to an event and that's gonna Now this Kima cluster is in turn connected to the center for software in this case I'll be using SAP cloud Commerce cloud enterprise edition and lambda will be listening to an event called order created and once this even gets Triggered the lambda Is executed which in turn makes a call to the commerce cloud through OCC API and Get details more about the order and Then it calls a microservice called HTTP DB service, which will in turn Soar the details in Azure SQL That's a DB service provisioned in Azure Which will use Azure open service broker for that and this micro UI is used to view the order details Which will be fetching the records from Azure SQL using the microservice So let's see it in action Okay, so these are the environments here. We are working with CF summit EU. What this means is Right So environment is a namespace in Kima But with a few tweaks so we have resource coders and others enabled We'll be working with CF summit EU and here we can work with a bunch of Kubernetes resources as well as Kima resources through the UI Oh, this is really at the load. This is an administration tab Okay in the administration you could download the cube config and work in terminal These are the bunch of service brokers already provisioned. I have as your broker with me and some other brokers So here is the link to the graph on our dashboards, which we package So now let's see it in action. Okay, so we have a bunch of docs already integrated in the UI as well It's there in the website too great, so Now let's get into action. So remote environments once and Everybody software gets registered to Kima. We use a remote environment custom resource definitions to store the metadata of the connections So I've already registered in EC default the cloud commerce environment in order to use that I need to bind it to my namespace which is CF summit EU that's right and once it's bound I can use the service catalog Okay, so what happens here in the Once we register the enterprise software or the commerce cloud here It comes with two service in the service catalog The first one is events because we'll be listening to the events And reacting based on that. So We need to create a service instance To use it in our environment, that's what we are doing here We'll change the name just to make it short otherwise. It just generates a unique name every time Okay, and the next piece is This guy so what it does is the lambda when it gets triggered It's gonna make a few call to the enterprise software to get more details So in order to get the red API is from the enterprise commerce We need to create a service instance for that So this is the whole API and we'll be just using one endpoint to get the order details Here we are binding it to the environment that we're gonna use So essentially we are creating Two service instances Oh One for the events and other for the API in order to use it in our lambda. Okay move on Create awesome Okay, next comes the lambda. I've already created the lambda before I'll just explain what we do it here So first we are trying to subscribe to an event here order created Among this bunch of events which are available and in the lambda what we do is Yeah, I'm gonna explain once it moves on. Okay, so this request get will actually make a call to the enterprise software API to get more details That's the first call and the second call is to the ACDB DB service, which is a microservice deployed next to the function pod To add the record to Azure DB. That's what that's the call out here We said the URL the call is here the post and now what we're doing is we're binding to The service instance of that API in order to use it What happens in the background is a service binding gets created an event an environment variable called Gateway URL is Present to be used in order to reach the enterprise software API great, I Think we are set So finally there are three deployments in action here the first one is this guy it it contains the function and Then the HTTP DB service which inserts the record details to the Azure DB and finally the UI which pulls up the information from the Azure DB and The this Microservice is already exposed. This is the API section. This is exposed using The URL in here which we will access shortly So of course there are no orders right now. We will try to create an order in the enterprise commerce or the SAP cloud Platform and then we and then that order should be visible in the UI great the order is created which is 3109 and What happens in the background the lambda gets triggered and everything and we get to see it in the UI and Now a few more details On this chemo console We could expose a function using a CDPS in here and And This is an authentication service which is compatible with jwks And in out of the box chemo we do provide an authentication service, but technically you could have Any authentication service which is compatible with jwks hooked into chemo and that's gonna work in here There's a token part if you want to Take the token and make it a call by yourself Okay, so this is the whole service catalog in detail since we have azure broker enabled you see is a bunch of azure Managed services already available to be used in chemo But we use Azure SQL database 12.0 Which is used in HTTP DB service in here through this service instance. That's all we are saying Now this is the graph on a dashboard, which is already packaged with chemo This is a lambda dashboard. We see just one data point which was successful. It has response success rate response time And request rate and other stuff But we I have another function which is stress which has a lot more data points and hence That we can see some data coming in here But it's not just that we have a bunch of dashboards already packaged in chemo from Kubernetes overall monitoring to the Istio related network overview so and An user can create customized dashboards and save it. So this is the Kubernetes overall overview and then Pods or nodes or this is the nodes dashboard. So this is all packaged with chemo for now and now a Request is reaching a bunch of microservices inside chemo, right now debugging is a pretty big issue if we can't trust them That's the reason why we have Yeager already integrated with chemo and this is the Yeager UI So what we see here is the first call came to connector. So the application connector The event came through application connector to chemo So that's the reason we see connector out here followed by publish and push Those are the components of event bus Which in turn triggers the CF Yeah CF order service, which is the function Which in turn calls the EC gateway to fetch the orders So the first rest call to the enterprise software EC is a bit confusing term like EC term is going away. It's called enterprise commerce It used to be called now. It's called SAP cloud commerce. So we have still EC out here. That's It's the same thing Right, and this is the Lambda trigger followed by EC gateway and ACDB DB service and everything is part of service mesh because Istio is enabled and this is possible using Istio proxy, which is a sidecar to every deployments Hence we see Istio proxy in all the calls Great. So that's it Now, let me go back to my slides Okay, it's still on so what we want to take away from Today's talk I want to leave you with how we decoupled the enterprise software the Extensions developed in enterprise software in a different platform now agility is back in the business because you can experiment you can try out few things in a fearless manner in chemo and the extension developers are in control of the code that they write and SAP takes care of the core upgrades whenever possible. So in a way, we can move a lot faster than before and everything is characterized by highly cloud native features and We have deterministic deployments by that what I mean is A operator now doesn't need to deal with third-party code He knows his core if anything goes wrong that would be easier to debug than handling third-party code And of course it's secure with Istio and everything. So I encourage you to try this out today if not It's available in GitHub. There's chemo project at IO. We have a bunch of Documentation out there. We are pretty responsive in the community community snack channel and Active in Twitter peers are always welcome feedbacks comments. Just let us know Thanks for your attention and if you have questions I can take right now Yeah, grab me in the conference. I can answer a few more questions or You know discuss about Golang or distributed systems. Thanks


there we go oops so if we hit or sorry if we do 2 to the 4 well we would call exponent 2 4 that would go into our recursive case so it would go into that else statement and it would do return well 2 times exponent 2 to the power of 3 so before that function returns that called 2 to the 4 it has to actually compute 2 to the 3 so we would do another function call so this is another function call so I put it here on the stack to indicate that the other one is still active it's waiting for this one to complete so right here in the gray text that is what we're trying to compute and every box is a new function call that would have its own local variables in this case it would be b is 2 and n is 3 so to evaluate exponent 2 to the 3 that would go into the recursive case so we would get 2 times exponent 2 to the 2 okay well now we have to figure out what exponent 2 the 2 is that is another function call so we call exponent 2 to the 2 then that gets into the recursive case again so we get 2 times exponent 2 to the 1 then it gets kind of boring so then we do have another function call with exponent or 2 to the 1 and then well that is 2 times exponent 2 to the 1 so we would call that and then mercifully this is our base case so in this case n is equal to 0 so it would just get a 1 so it would return 1 so the function that called it gets a copy of 1 and this whole thing kind of unravels itself so then it would return and then in our 2 to the 1 function we would calculate 2 times 1 which is just 2 and then that is the result for 2 to the power of 1 so that would get returned for this function call then we have 2 times 2 so that would be 4 so that's 2 to the power of 2 and then it would get returned here and then all kind of unravels right so now here that 4 is returned it gets a copy of it so then we would do 2 times 4 which is equal to 8 which is thankfully to the power of 3 and then here well we would return 8 so then we would get 2 times 8 and then we'd get finally our final answer 16 so lots of steps it would be in that case what 5 function calls but we got the answer in this case a for loop would have probably been less confusing but is there any questions about how this work because it's going to get weird once we get Fibonacci going so we're all okay until it gets slightly more strange okay so let's go ahead and run it make sure it works so here's that exponent code so here I just have my base case and my recursive step oops and then if I go ahead and run it I could do to the power 4 something that I get 16 seems to work to the power 5 32 but if we implemented this with a loop I could probably do like 1 to the power of I don't know some large number and that would be fine it would just might take some time to execute right well let's see what happens here so if I run that I get a segmentation fault crap well I didn't even use malloc how in the blue hell do I have a segmentation fault so one of your steps might be okay well I'll use valgrind and then I'll see says okay I have no memory leaks I didn't allocate anything so what happened so you try and scroll up and then you get a bunch of random text that's probably not so readable the only thing that you have any hope of reading is this thing called a stack overflow so we know that kind of what a stack is it's where all the local variables are and in this case the stack overflow means basically it ran out of memory so this is a very common thing you can encounter once you do recursive functions because if there's too much recursion we essentially just run out of memory so I did what to the power of like a million or something like that so that would mean that you know a million called 999999 called 99998 called that called that called that called that and well every function that is active has a B and an N at least so it has two integers so I essentially just ran out of memory because every function call needs its own variables so that is what a stack overflow means basically just I ran out of memory so again like I said every time we call a function that function gets its own copy of the variables in C they store local variables on the stack so if there's many active functions at once so there I did one to the power of a lot so if I was to draw that on the slide I would run out of room because it would just call itself over and over and over again until it actually ran out of memory so running out of memory for local variables called stack overflow that is the name of the helpful website that you can get questions and answer to for programming questions so they named it that because well this is a common enough error that is really hard to go it means you have screwed something up because usually people get to recursion and then things start screwing up and then most programmers see stack overflow a lot when they are starting out so common cause for a stack overflow more likely than not is infinite recursion so it's similar to an infinite loop except in an infinite loop just takes a lot of time it doesn't actually need more memory each time you go through the loop for recursive functions it needs more memory essentially every iteration of the loop if we were thinking about loops so we can actually likely run out of memory before we run out of time so this is far beyond the scope of the course so don't worry about if this part doesn't make any sense but there are like certain forms of recursion that are more that can be optimized more easily so we can rewrite some functions to use what's called tail recursion so it's a special recursive function that just has a single recursive call in the return statement you do not need to practice actually rewriting this this is mostly for performance so if we modify exponent well we could create an exponent that takes three variables so before we just returned a number well like in a recursive case we did like two times the recursive function so if we want to be tail recursive we can't do that so we create another variable here that's local to the function called accumulator that just keeps track of the current value so in our base case instead of returning one we just return whatever the final value we have is so it would do like two to the two times two times two times two if we did to the power four then eventually it would be 16 and then we just return 16 at the end and this is our recursive case so we just do the calculation with the accumulator so we just multiply B by it and otherwise it looks the same as before so if we want to keep exponent looking the same well we have the base and the end and we can just return exponent written in this tail recursive manner by giving the accumulator one and then giving B at the end and the only reason why I show this to you is because compilers can optimize this function so if it's recursive a lot of people don't like writing recursive functions because well it wastes a lot of memory and you can get into the stack overflow issue where if you just wrote a while loop or for loop or something like that that would work better and you wouldn't have that memory issue so it's actually guaranteed that compilers and you'll learn this in like fourth year whenever you get to compilers but it's guaranteed that compilers will optimize this away so it will optimize away the recursive fall call and just convert that whole function into essentially a while loop so it would convert it to this for you so just start off in x equals accumulator so in our case we set it equal to one and then it would just go while n is not equal to zero and just do the recursive step over and over again so now our code doesn't have a stack overflow doesn't have that issue because we're not actually doing recursive function calls we let the compiler optimize it away for us and in this version maybe you can argue that the recursive one was more readable so you'd rather have it than this but for calculating an exponent probably just a while loop is going to be much much much easier to do but it's good to think of things recursively because well some solutions lend itself better to recursion than others so let's rewind a bit and see what happens when we call fib of four so this one is a bit different than the exponent where in our recursive step we return fib n minus two plus fib or fib n minus one plus fib n minus two so we do two function calls here so if we actually want to evaluate something like fib of four turns out it's going to be a lot of work to understand how your computer actually executes this code so gets a bit ugly so if we evaluate fib of four well we call fib of four and again I'll just write in the gray here what the function is supposed to be computing so it's supposed to be computing the fourth Fibonacci number so in order to compute fib of four well that's a recursive step right it should return fib three plus fib two so we have to do these function calls so C will go ahead and it does function calls in left to right order don't have to know that for the course but in order to figure out how this actually works on your computer it's important to know what happens first so we will do this function call for fib of three so we'll do that function call it'll get its own copy of n and we do fib of three well that goes into the recursive step so it would return fib of two plus one right then okay now we need to call fib of two okay so we call fib of two fib of two is equal to fib of one plus fib of zero mercifully when we call fib of one that is thankfully our base case right so it would immediately return one so that whole thing would evaluate to one and then it would return and give us the value one back for in this case fib of one so it returns and now oh no well we still have to find out what fib of zero is right so now we have to figure out what fib of zero is so that is another function call to figure out what fib of zero is that mercifully is another base case so that just gets the value zero so it returns and then we can finally figure out what the second Fibonacci number is so it's one plus zero so it would figure out that that is one okay great so that was figuring out what fib of two was so that would return the value one okay well now we have to do the other half of it now we have to do fib of one okay well that's another function call so we call fib of one mercifully that is another base case so that just returns one and then well that returns one so then we can figure out what the third Fibonacci number is so it's just one plus one so that's two so now that returns right so that is fib of three so that returns oh god but now we have to figure out what the second Fibonacci number is so that is another function call so this whole thing kind of goes again so we have fib of two okay well that's a function call oh that's our recursive case so we would return fib of one plus fib of zero whoa okay so then fib of one that's another function call mercifully that's our base case so that's just a one so then that would return okay yay so now we have to figure out what fib of zero is again so fib of zero okay that's another function call that goes to the base case mercifully we know it's a zero then it would return and now fib of two is done so we get one then that returns now we can finally figure out the fourth Fibonacci number which is two plus one which is three yay wasn't that fun so any questions about how that works other than it seems like it takes a long time to figure it out so let's see so here is that implementation and just as a review for the last one instead of just asking and doing scan F I'm just using that other version of main that takes another argument that I can type to it just because I don't feel like hitting enter two times so I checked that there's two arguments and then use AOTI to convert the first one to an int and I assume I'm being nice to it I'm just going to print the result of calling Fibonacci on whatever that number is so if I call fib of four it was a lot of work for us to figure out all the function calls and you know how they work and who calls what and what values and when do they stop but computers are fast so it just gets three quite readily and works so if we did computed 10 we get 55 turns out grows pretty fast 20 we get 6000 something like that seems to be pretty fast computers are quick but if we get 40 you might have noticed that took a little bit of time maybe 44 44 took a bit of time it was a bit slow and also for this one we could just write it in a for loop to and it would be way faster and way easier to actually compute but again we're just kind of practicing practicing recursion even though doesn't really make sense this would be a lot easier to just do in a for loop so any questions so far about evaluating that yeah so the question is do we know how much slower it will be depending on how many steps it will get so you can kind of guess it's going to get like in this case almost two times slower every time because well if I have to compute 44 that means it has to compute 43 and then 42 and then if I have to compute the next one well I have to compute 44 which is going to take as much as what I ran before plus of 43 so not quite two times slower every step but gets up there so if I do like 45 probably pretty slow yeah oh crap so oops so if I do 44 one Mississippi to Mississippi takes a bit of time if I do 45 one Mississippi to Mississippi three Mississippi for Mississippi okay so took about twice as long because essentially has to calculate everything it had to do before and then do it all again for the next number and then you might imagine this might be like exponential so I have to compute one side and then the other side and then I have to do it again and again and again and it's kind of a pain so that leads us to our next thing which is we can significant whoops wrong thing leads us to the next point of again so this part again is beyond the scope of the course for this course just writing recursive functions is good enough for us we'll get some more practice as it goes on but just so you know you can significantly speed this up without actually changing it from being recursive with something called memoization which is just a fancy word for caching and cat caching is just a fancy word for just saving values that you don't so you don't have to recompute them so even with fib of calculating fib of four well we had to calculate like fib of two a lot of times and we had to calculate fib of three once and fib of two a bunch of times and then a lot of well we didn't have to calculate the value for fib of one or fib of zero but we could change our program a little bit so we don't have to go ahead and recompute them over and over again so what optimization we could do that you could probably implement right now but you don't have to for this course it's just I could just remember some older value in an array and then if I've already calculated that value before I can reuse it again instead of recomputing it so this one took I almost counted like five Mississippi it was really really really really really really slow so I wrote another version of it that just that just saves the value that is computed already so it just reuses it over and over again instead of doing the whole recursive nonsense over and over again and if I run that whoops that is the same function so if I run my optimized version boom look how fast that was so there are some techniques you might employ that some problems will have to be recursive and they might be slow and this is one technique to speed it up again just something to think about don't have to do that in the context of this course at all but it will come up you know probably in your next programming course so recursive functions are basically just another tool some problems are easier to think about recursively especially if you're like more of a mathy person that likes proofs and all that stuff was never me so it took me a bit to figure out this recursive thing but some problems believe it or not are actually easier to solve recursively so it's good to get some practice trying to get yourself into that mindset so typically recursive functions they're going to take more space to execute tail recursive functions can be optimized again don't have to know that for this course but in your career that might be a good thing to know and try to write for so it's important to practice so you can go ahead identify these types of problems and be able to solve them and the main two things are given a problem you probably want to identify a base case so something you know a value for given one of the inputs and then you also want to create the recursive step so you want to solve the problem in terms of itself sorry you want to solve the problem in terms of a smaller version of itself so typically it'll be you do one thing like you just take one step and solve that so let's think about that for more practice can we write a recursive function to calculate factorials so sit think about it for a few minutes and then we will try and come up with the code ourselves together so we're trying to calculate factorials and like for an example well the like four factorial would be four times three times two times one so take a minute think about how you would solve that and write that as a recursive function so these are the types of things that would be on exams and stuff like that like for this course most of the problems you'll see you can probably solve with like a while loop or something like that because well you have to be able to write them during an exam and recursive stuff takes practice so generally you'll probably get some question the file will be like solve this problem with a recursive function all right I'll give you a few minutes for that and then we'll try and think about what these steps would be I can't hear you sorry okay so I'll take you first so you you you will start half of it so the first thing we need is a base case that's been answered up there so our base case would probably be well if we're computing like n less than two so if we're computing the factorial we'll assume no negative numbers if we're computing one factorial or zero factorial well they're defined as just being the value one so that is our base case so I'll get someone else for the recursive step so that is one thing we need so the other thing we need is our recursive step so anyone with the idea of what we should do in the recursive step so how do we solve factorial in terms of itself yeah yeah so my recursive step I could write in it else here a return doesn't really matter so in terms of solving in terms of itself well let's assume the number is four so in order to calculate four factorial well that's just the same as doing four times three factorial so if we wrote that in terms of c function calls our recursive step would be to return n times n minus one factorial which would just be factorial n minus one everyone agree with that so turns out this one might be easier to think about than doing all the four loop and everything like that so if we do I don't know four factorial 24 10 factorial some large number seems to work cool that was faster than I expected any questions about that yeah so the questions can I do a recursive macro I'm not sure if the c-pro pre-processor lets you define recursive macros I'm actually not sure I don't think so it's fairly straight forward and simple and I would probably complicate it so I don't think you can but can do recursive functions no problemo so any questions at all about factorial all right wow I did myself so here's the solution for you so same thing we developed so important things so we will get a much much much much more complicated example in the next lecture I even have fun toy props that I can bring in but for this one just to remember a recursive function just a function that calls itself in order to think about the problem while your solution needs two things so you need a base case so which is basically a simple solution you know so something you know how to do that you don't have to think very hard about and then the other one is your recursive step that you'll have to develop which just solves the problem in terms of a smaller version of itself so the idea here is since it's a smaller version of itself you're making progress each step you take eventually you will hit the base case and then you can just let your computer solve it for you so yeah we're really 13 minutes ahead all right cool I like it all right so all we'll just stick around for the remaining 13 minutes but just remember pulling for you we're all in this together