This tutorial will teach us how to create a Crowd Simulation animation using HTML, CSS & Javascript. This animation will have multiple people moving their bodies around each other as they walk, dance, or run. You can download the final animation here. Crowd Simulator Animation Tutorial – CSS Animation – HTML CSS JavaScript
Halting problem
Are all math or computer science problems solvable? We know that it is not possible to know whether problems of the NP category can be solved in polynomial time, but NP problems can also be solved in exponential time if the input size is small enough or if you have infinite time and memory. But there are some problems that no matter how big a supercomputer you have, you can’t solve them. Here I assume our computers are Turing machine computable. (If you don’t remember Turing machine, read my article first)
Halting problem is a problem that has no solution. You need to say whether the program will stop in finite time for that input or get stuck in an infinite or infinity loop?
In the above code you have x=−10
Input will never stop the program (code written in Python, no fear of integer overflow)
Your job is to write a program that can tell any other program and input whether the program will get stuck in an infinity loop or not. This is Halting Problem.
Now we will prove with the help of “Proof by Contradiction” method that Halting problem is not solvable. We will first assume that the problem has a solution and then prove that the solution cannot exist.
Suppose we have a program that solves the halting problem. The program might look like this:
This is a fictitious code. The parameters of the code are a program P and an input I to be passed to P as a parameter. The code can tell in some way whether or not program P will stop at a finite time given input I .
Crowd Simulator Animation Tutorial – CSS Animation – HTML CSS JavaScript
This type of code is called an Oracle Machine. Oracle literally means an Ojha who can solve problems with psychic powers. Our will_it_halt code can also magically solve the halting problem. Now if we can prove that there is no Oracle Machine that can solve the halting problem then we are done.
Now we will write another program, think the name of the program is Paradox.
Paradox accepts a program as input. A program is a string of instructions. So we can pass the Paradox program as a parameter if we want!
Now in the second line we are asking the oracle machine if we send the paradox program as input to the paradox program, will it get stuck in the infinity loop or not. If the oracle says it can’t be stuck in an infinity loop, we’ll stick it in an infinity loop on line 3! And if the oracle says that it will get stuck in an infinity loop, we will exit the program. That means what the oracle says is not true, rather the opposite is happening. This is a contradiction, from which we can say that the oracle machine called will_it_halt cannot exist!
This is proof that the halting problem is not solvable.
When some apps are launched on the mobile phone, the screen freezes due to some bug, then there is no option but to open the battery and restart the phone. Can you write an app that will tell you which app will freeze the screen? It is a variation of the halting problem which is nicely explained in this article, if you are interested you can read it.
What would happen if the halting problem was solved? Then debugging the code would be much easier, without running the code we could tell if the code would loop into infinity or not. More importantly, many mathematical problems could be solved with this will_it_halt program. Let me give an example. A mathematician named Goldbach said many years ago that “any even number greater than 2 can be written as the sum of two prime numbers”. No one has yet proved that the conjecture is true or false. Now I wrote a program to prove:
This program will try to brute force every even number starting from k=4 as the sum of two prime numbers. If ok = false for any k then the program terminates, proving that the conjecture is false. And if the conjecture is true then the program will run indefinitely. If the will_it_halt program existed, I could tell whether the conjecture was true or false by looking at the output of will_it_halt(goldback, null)!
If you can find a mathematical model that can solve the Halting problem, then we can get a hyper-computation or super-Turing computation model, then we can solve problems that cannot be solved by a Turing machine.
The halting problem has also given rise to many philosophical questions. Like can we ever know 100% about our brain? Or because of some theoretical limitations we will not be able to know the many mysteries of the brain?
Crowd Simulator Animation Tutorial – CSS Animation – HTML CSS JavaScript
That’s it for today, happy coding!
Backtracking: Permutation Generator
Backtracking is a brute force technique. Like bruteforce, it returns results from all possible arrays. For example, suppose you are asked to find the shortest route from Dhaka to Chittagong. If you find all possible paths without using Dijkstra’s algorithm and then find the shortest one, this is brute force or complete search.
You must have a good understanding of recursion before reading this article.
This is a very effective method when the size of the searchspace is small. The search space is the extent to which your solution can exist. For example if you are asked to find out with two sets of size 10 whether the 2nd set is a subset of the 1st then you can easily backtrack 210=1024
You can find t sets and match them all, but if the size of the set is 100, this lifetime is not enough for you to find the solution!
Problems for which we do not yet know any polynomial solution ie NP or NP-hard category problems have to be solved by backtracking. Be very careful about complexity before writing backtracking code.
Now we will see how to backtrack to 0
Every permutation of the numbers from to n−1 can be derived. If n=2 then the permutations are:
Before Download
You must Join our Facebook Group and Subscribe YouTube Channel
All Links in Below:
Join Our FreeWebsiteCreate Facebook Group to get an instant update for projects, templates, design resources, and solutions.
Join Our YouTube Channel & Subscribe with Bell Icon for New Video:
Join Our Official Facebook Page For the Latest updates All Code Projects are Free:
Visit our service page to get premium services.
Free Website Create – HTML CSS, PHP, JavaScript Programming Projects For Free
Follow Us
Thank You,
Before Download
You must Join our Facebook Group and Subscribe YouTube Channel
FreeWebsiteCreate.net tries to provide HTML, CSS, SCSS, JavaScript, React, Android Studio, Java, PHP, Laravel, Python, Django, C#(C Sharp), and ASP.net-related projects 100% free. We try to make learning easier. Free Website Create always tries to give free projects to those who are new learners. Free projects and source code will help to learn easily. They can save time and learn more. In this post, we share a free portfolio project website code with HTML and CSS. This free code portfolio contains a single landing page with a responsive design. In this post, we get a free best carpenter and craftsman service website designed by FreeWebsiteCreate with HTML, CSS, Bootstrap, and JavaScript.