mirror of
https://github.com/kuhyx/testsAndMisc.git
synced 2026-11-24 14:26:17 +01:00
Adding custom number of plates functionality
This commit is contained in:
parent
5f83266812
commit
85fa783409
@ -99,7 +99,7 @@ void onlyLegalMove(std::deque<int> &firstRod, std::deque<int> &secondRod)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void doTheThingEven(std::deque<int> &firstRod, std::deque<int> &secondRod, std::deque<int> &thirdRod)
|
void doTheThingEven(std::deque<int> &firstRod, std::deque<int> &secondRod, std::deque<int> &thirdRod, const unsigned int numberOfPlates)
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
do{
|
do{
|
||||||
@ -109,14 +109,14 @@ void doTheThingEven(std::deque<int> &firstRod, std::deque<int> &secondRod, std::
|
|||||||
i++;
|
i++;
|
||||||
onlyLegalMove(secondRod, thirdRod);
|
onlyLegalMove(secondRod, thirdRod);
|
||||||
i++;
|
i++;
|
||||||
}while(thirdRod.size() != 6);
|
}while(thirdRod.size() != numberOfPlates);
|
||||||
printDeque(firstRod);
|
printDeque(firstRod);
|
||||||
printDeque(secondRod);
|
printDeque(secondRod);
|
||||||
printDeque(thirdRod);
|
printDeque(thirdRod);
|
||||||
std::cout << i << std::endl;
|
std::cout << i << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void doTheThingOdd(std::deque<int> &firstRod, std::deque<int> &secondRod, std::deque<int> &thirdRod)
|
void doTheThingOdd(std::deque<int> &firstRod, std::deque<int> &secondRod, std::deque<int> &thirdRod, const unsigned int numberOfPlates)
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
do{
|
do{
|
||||||
@ -126,7 +126,7 @@ void doTheThingOdd(std::deque<int> &firstRod, std::deque<int> &secondRod, std::d
|
|||||||
i++;
|
i++;
|
||||||
onlyLegalMove(secondRod, thirdRod);
|
onlyLegalMove(secondRod, thirdRod);
|
||||||
i++;
|
i++;
|
||||||
}while(thirdRod.size() != 6);
|
}while(thirdRod.size() != numberOfPlates);
|
||||||
printDeque(firstRod);
|
printDeque(firstRod);
|
||||||
printDeque(secondRod);
|
printDeque(secondRod);
|
||||||
printDeque(thirdRod);
|
printDeque(thirdRod);
|
||||||
@ -140,17 +140,27 @@ odd:
|
|||||||
AC AB BC
|
AC AB BC
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
std::deque <int> fillDeque(const int maxNumber)
|
||||||
|
{
|
||||||
|
std::deque <int> deque;
|
||||||
|
for(int i = 1; i <= maxNumber; i++ )
|
||||||
|
{
|
||||||
|
deque.push_back(i);
|
||||||
|
}
|
||||||
|
return deque;
|
||||||
|
}
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
//int numberOfPlates = 6;
|
unsigned int numberOfPlates;
|
||||||
|
std::cout << "Enter number of plates: " << std::endl;
|
||||||
|
std::cin >> numberOfPlates;
|
||||||
std::deque<int> firstRod, secondRod, thirdRod;
|
std::deque<int> firstRod, secondRod, thirdRod;
|
||||||
firstRod = {1, 2, 3, 4, 5, 6};
|
firstRod = fillDeque(numberOfPlates);
|
||||||
secondRod = {};
|
secondRod = {};
|
||||||
thirdRod = {};
|
thirdRod = {};
|
||||||
if(firstRod.size() % 2 == 0) doTheThingEven(firstRod, secondRod, thirdRod);
|
if(firstRod.size() % 2 == 0) doTheThingEven(firstRod, secondRod, thirdRod, numberOfPlates);
|
||||||
else doTheThingOdd(firstRod, secondRod, thirdRod);
|
else doTheThingOdd(firstRod, secondRod, thirdRod, numberOfPlates);
|
||||||
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user