To transfer google play balance, opinion rewards or gift cards to PayPal, Paytm, PhonePe, Google Pay or any UPI ID linked bank account , you can use QxCredit :Rewards Convertor app which is available on google play store: You will get back 80% of the google play balance. App link: https://play.google.com/store/apps/details?id=qxcoding.qx_credit_reboot Follow these steps to transfer your play balance to paypal or UPI: 1) download app from play store. 2) login with your google account and phone number. 3) choose a token amount which you want to convert/transfer. 4) Enter your payout details.(UPI ID or PayPal Email) 5) wait for an acknowledgement mail form qxcredit containing information about your purchased token. 6) you will receive the amount within 3 days. 7) if you face any issues you can raise a query on website: https://qx-credit.web.app/#/contact_support About app: Introducing QxCredit : Rewards Converter Convert /Transfer or Exchange your Google Play Balance and opini...
Tower of hanoi is a mathematical game or puzzle. It consists of three rods and a number of disks of different sizes, which can slide onto any rod. The puzzle starts with the disks in a neat stack in ascending order of size on one rod, the smallest at the top, thus making a conical shape.
The objective of the puzzle is to move the entire stack to another rod, obeying the following simple rules:
- Only one disk can be moved at a time.
- Each move consists of taking the upper disk from one of the stacks and placing it on top of another stack or on an empty rod.
- No larger disk may be placed on top of a smaller disk.
With 3 disks, the puzzle can be solved in 7 moves. The minimal number of moves required to solve a Tower of Hanoi puzzle is 2n − 1, where n is the number of disks.
For example consider 3 disks ,it can be solved in 23 -1 steps :
Steps required to be performed for solving tower of hanoi problem :
The universal way (steps ) to solve this type of problem are:
N=number of disks :
A,B,C are rods :
1) move N-1 disks from A to B using C
2) move the remaining single disk in A to C
3) move N-1 disks from B to C using A
The Recursive Function based on the above steps is defined below
void TOH(int n,char a,char b,char c){
if(n>0){
TOH(n-1,a,c,b);
printf("%d from %c to %c\n",n,a,c);
TOH(n-1,b,a,c);
s++;
}
}
Output :
For N=3:
For N=7
C / C++ Source Code :
#include <stdio.h>
#include<conio.h>
#include<time.h>
#include<direct.h>
#include<dos.h>
#include<unistd.h>
#include<windows.h>
static int s=0;
void TOH(int n,char a,char b,char c);
int main(int argc, char *argv[]) {
int n;
time_t t1=time(NULL);
printf("Enter number of discs ");
scanf("%d",&n);
TOH(n,'A','B','C');
time_t t2=time(NULL);
time_t t=t2-t1;
printf("\n\nsteps=%d time elapsed=%d seconds ",s,t);
getch();
return 0;
}
void TOH(int n,char a,char b,char c){
if(n>0){
TOH(n-1,a,c,b);
printf("%d from %c to %c\n",n,a,c);
TOH(n-1,b,a,c);
s++;
}
}
Python Source code :
s = 0
def TOH(n, a, b, c):
global s
if n > 0:
TOH(n - 1, a, c, b)
print("Move %d from %s to %s\n" % (n, a, c))
TOH(n - 1, b, a, c)
s += 1
if __name__ == '__main__':
n = int(input("Enter number of discs : "))
TOH(n, "A", "B", "C")
print("\n\nsteps=%d \n" % s)
if any doubts or queries please comment
Nice brief.
ReplyDelete