Finding number of nodes along a path - c++

I am trying to navigate through a ghetto map. I'm inputting my nodes from a .txt that has values like this:
3 -1
2 3 -1
1 -1
0 1 4 6 -1
3 5 7 -1
4 7 8 -1
3 7 -1
4 5 6 8 -1
5 7 -1
10 -1
9 -1
So:
node 0 will be connected to node 3
node 1 will be connected to nodes 2 and 3
node 2 will be connected to node 1
and so on... the '-1' is just to terminate the line
Currently, I am storing them in an array of size 11, where I've just used getline() to pull each line number into the matching array cell; this is to output to the screen. I will also put them into a 2d array where each value had its own cell. I'm going to ask the user for a starting node, and ending node, then I'll use a recursive function to calculate a path between the two (if there is one), and output how many nodes are along that path. I'm not even interested in the optimal path, any will do.
How would I go about this recursively?
The unfinished code thus far:
#include<iostream>
#include<fstream>
#include<string>
using namespace std;
const int ARRAY_SIZE = 11;
void toString(string network[ARRAY_SIZE]);
int numNodes(string network[], int start, int end);
int main()
{
int start;
int end;
// inputting network into array
string network[ARRAY_SIZE];
ifstream in;
in.open("network.txt");
if (in.is_open())
{
while (!in.eof())
{
for (int i = 0; i < ARRAY_SIZE; i++)
{
getline(in, network[i]);
}
}
}
in.close();
//start of user prompts
cout << "Welcome. " << endl << "Here is the network " << endl << endl;
toString(network);
// the loop for start val
do
{
cout << "Please enter a a starting node number (0-10), enter '-1' to quit" << endl;
cin >> start;
if (start == -1)
return 0;
} while (start < 0 && start > 10);
toString(network);
//loop for end value
do
{
cout << "Please enter an ending node number (0-10), enter '-1' to quit" << endl;
cin >> end;
if (start == -1)
return 0;
} while (end < 0 && end > 10);
//recursive stuffs
return 0;
}
int numNodes(string network[], int start, int end)
{
//unfinished function
int num;
//base case
if (start == end)
{
return 1;
}
//recursion
else
{
}
return num;
}
void toString(string network[ARRAY_SIZE])
{
cout << endl;
for (int i = 0; i < ARRAY_SIZE; i++)
{
cout << network[i] << endl;
}
cout << endl;
}

Not sure what you mean by 'ghetto map', I'm guessing you its just a joke.
What you are actually talking about is a concept in Computer Science/Discrete Mathematics called a Graph. There are many types of graphs, graphs that have only positive weights graphs that contain negative weights, graphs in which all paths are bidirectional, graphs which paths are uni directional graphs where edges must all be connected, graphs were edges have a certain wight, capacity and/or some other feature etc...
In this case what I think what you are dealing with is an unweighted (no weights assigned to edges) directed (a connection from A to B does not imply a connection from B to A) graph (unweighted directed graph) and where the graph may additional be unconnected or not.
You are additionally using a type of Adjacency List in order to represent the connections between graph nodes.
There are many algorithms to traverse a graph (such as Dijkstras for path finding or Uniform Cost Search), however most if not all these algorithms come from two basic search algorithms called Depth First Search and Breadth First Search
Depth first search is exactly what the name implies. If you have some structure to represent your graph (say, your adjacency list) you will continually search the right or left most node to the deepest point until you either hit your goal or a dead end. This might look like the following (note this is Python):
def DepthFirstSearch(adjacencylist, start, end):
traversallist = []
traversallist.push(start)
for edge in adjacencylist[start]:
if edge.connectsTo(end):
traversalstack.push(end)
return traversallist
else:
resursivelist = DepthFirstSearch(adjacencylist, edge.endNode(), end)
if resursive_list != []:
return traversallist.extend(recursivelist)
return []
if it returns an empty list ([]) there was no connection. If it didn't there was a connection and returned the first path found.
Breadth frist search is exaclty what its name implies. In the same scenario as before, instead of searching for the deepest node you search along each connecting edge first before going deeper. This might look like the following:
#note that queue starts with the start element
def BreadthFirstSearch(adjacencylist, queue, end):
start = queue.pop()
traversallist = []
traversallist.push(start)
for edge in adjacencylist[start]:
if edge.connectsTo(end):
traversalstack.push(end)
return traversallist
queue.push(adjacencylist[start])
if not queue.empty():
return traversallist.extend(BreadthFirstSearch(adjacencylist, queue, end))
else:
return []
Both of these methods, however, will run infinently in the case where you have a loop during traversal. To avoid this, you can setup a list (or for bettern runtime complexity, a hashtable) to see if you've already traversed something.
def DepthFirstSearch(adjacencylist, start, end, closedset):
...
if start not in closedset:
...
else:
return []
def BreadthFirstSearch(adjacencylist, queue, end, closedset):
...
if start not in closedset:
...
else:
return []
This should give you enough information to implement a graph path finder that will return a path (of which you can simply return the size of if you only need the number of nodes) in c++.

Related

C++ Find Frequency of a String in a Vector of Strings

I am currently working on a little mini program that will determine if a vector of 5 strings contains a full house. A full house in my program has a pair of cards and 3 of a kind.
For example: ["A", "A", "A", "K", "K"] would be a full house, while ["10", "J", "10", "10", "10"] would not be one.
I have written my main function such that a user can read the card values into a vector with this code below:
int main()
{
vector<string> hand;
string input;
for (int i = 0; i < 5; i++)
{
cout << "Card " << i + 1 << ": ";
cin >> input;
hand.push_back(input);
}
}
I would like to write a bool function that takes the vector as a parameter and returns true if the vector contains a full house, and false if it does not. My problem is that I am not sure of an efficient way of looping through the vector in the function and finding the frequency of each string to determine if the vector has a full house.
For example, I would like my function to be somewhat like the one below:
bool isFullHouse(vector<string> hand)
{
// loop through vector
// record instance of string in vector
// determine if the string has appeared either 2 times or 3 times in the vector
// if it contains a full house
return true
// else
return false
}
Does anyone have a decent way of achieving this task?
You can use standard algorithms to write the function like this:
bool isFullHouse(vector<string> hand)
{
// put all cards matching the first one at the beginning
auto p = std::partition(hand.begin(), hand.end(),
[first_card = hand[0]] (auto card) {
return first_card == card;
});
// count cards matching the first one
auto num = std::distance(hand.begin(), p);
return (p == 2 or p == 3) // 2 or 3 cards
&& std::equal(hand.begin() + 1, p, hand.begin()) // same card at the beginning
&& std::equal(p + 1, hand.end(), p); // same card at the end
}
Efficiency is not a major concern here since you are dealing with a vector of 5 short strings, but this is an O(n) algorithm. Not that the n is relevant since you only have 5 cards, but all the algorithms used here are O(n).
You can also make your life simple and count the cards . . .
#include <iostream>
#include <unordered_map>
#include <string>
int main() {
// Define container
std::unordered_map<std::string, unsigned int> hand{};
// Read all values and count them
int i{};
for (std::string card{}; (i < 5) and (std::cin >> card); hand[card]++, ++i);
// Show result
std::cout << (((hand.size() == 2) and ((hand.begin()->second == 2) or (hand.begin()->second == 3))) ? "Full House" : "");
}

3D Maze solving with BFS. How to get a full shortest path to the end point if found in C++?

I am trying to implement the BFS algorithm to check if a goal is reachable in a 3D maze given a starting position. The maze was imported from a txt file. My solution seems to find the goal however I am not able to display just the path that was taken. My issue: I am able to find the goal but I have no idea how to get the shortest path and print it out. I was thinking about using parents/children concept but I am not sure whether it works.
I hope I can finally print out the path like this: (from start point to end point)
1 3 1
1 3 2
2 3 3
This is my code:
I use struct to store informations from txt file.
struct Maze
{
int x,y,z; //dimensions
int sx,sy,sz;//start point
int ex,ey,ez;//exit point
int grids; //number of grids in the maze where are actions available
vector<vector<int> > glist;
vector< pair<int, pair<int, int> > > gpoint; // list of (x,y,z) accessible
};
void BFS(Maze &maze,vector< pair<int, pair<int, int> > > result){
bool reach_end = false;
int xx,yy,zz;
int j=0;
int move_count = 0;
int nodes_left_in_layer = 1;
int nodes_in_next_layer = 0;
queue<int> xq,yq,zq;
xq.push(maze.sx);yq.push(maze.sy);zq.push(maze.sz);
vector< pair<int, pair<int, int> > > visited(maze.grids);
visited.push_back(make_pair(xx, make_pair(yy, zz)));
result.push_back(make_pair(xx, make_pair(yy, zz)));
while(!xq.empty()){
int xfront = xq.front();int yfront = yq.front();int zfront = zq.front();
xq.pop();yq.pop();zq.pop();
if(xfront==maze.ex && yfront==maze.ey && zfront==maze.ez){
reach_end = true;
cout << "reach end!" <<endl;
break;
}
int index=0;
index = getindex(maze,xfront,yfront,zfront);
//EXPLORE NEIGHBORS
for(j=0;j<maze.glist[index].size()-3;j++){
int action = maze.glist[index][3+j];
xx = xfront+dx[action-1]; // dx,dy,dz are lists of actions.
yy = yfront+dy[action-1];
zz = zfront+dz[action-1];
auto p2 = make_pair(xx,make_pair(yy,zz));
//skip bounds
if(xx<0 || yy<0 || zz<0){}
else if(xx >= maze.x || yy>= maze.y || zz >= maze.z){}
else if(find(visited.begin(),visited.end(),p2)!=visited.end()){
cout << "Visited: "<<xx <<yy<<zz<<endl;
}
else if(find(maze.gpoint.begin(),maze.gpoint.end(),p2)!=maze.gpoint.end()){
int index2 = getindex(maze,xx,yy,zz);
xq.push(xx);yq.push(yy);zq.push(zz);
visited.push_back(p2);
nodes_in_next_layer++;
}else{
cout<<"Not in glist!! "<<endl;
}
}
nodes_left_in_layer--;
if(nodes_left_in_layer==0){
nodes_left_in_layer = nodes_in_next_layer;
nodes_in_next_layer=0;
move_count++;
}
}
if(reach_end){
cout<< "move_count: " <<move_count<<endl;
cout << "nodes_left_in_layer: " <<nodes_left_in_layer<<endl;
cout << "nodes_in_next_layer: " <<nodes_in_next_layer<<endl;
}else{
cout<< "xxxFAILxxx " <<endl;
}
}
There 2 common ways:
You remember the distance of every visited cell from the start, and then when you find the end you walk back to the start, along the path that decreases distance with every step. This method is memory-efficient when you can use a bit-packed representation for visited vertexes, since you only need to remember the lowest 2 bits of the distance. This doesn't apply easily to you.
You directly remember the predecessor of every visited cell, and when you find the end you just follow all those links back to the start.
You should probably use method (2).
I suggest you replace your visited vector, which is currently very inefficient, with a std::unordered_map that maps each visited vertex to the index of its predecessor.

Integer pairs having biwise AND equal to 0

Two integers x and y form a magical pair, if the result of their Bitwise And equals 0.
Given an array of integers, find for every array element whether it forms a magical pair with some other array element or not.
Input
First line of the input contains a single integer T denoting the number of test cases.
The first line of each test case has an integer N denoting the number of elements in the given array.
The second line contains N single space-separated integers a1,a2,...an denoting the elements of the given array.
Output
For each test case ,print N space separated integers in a line.
If ai forms a magical pair with any other element of the given array , then ans'i should be equal to 1. Otherwise ans'i is 0.
Constraints
1<=N,Ai<=10^6
I tried brute force. For each element I checked if the bitwise AND of this number is zero or not with any other element present in the array. Obviously, it had a time complexity of O(N^2) and most of my test cases timed out
This problem is here: https://www.hackerearth.com/challenges/test/netapp-codenet-2017/algorithm/d2d1f6a92c6740278682e88ed42068a4/
Can anyone suggest me a better approach or algorithm so it passes the time limit?
Brute force code:
int n;
cin >> n;
int a[n];
for (int i = 0; i < n; i++)
cin >> a[i];
int ans[n];
for (int i = 0; i < n; i++)
for (int j = 0; j < n; j++)
if (a[i] & a[j] == 0)
ans[i] = 1;
for (int i = 0; i < n; i++)
cout << ans[i] << " ";
One way to do it would be to create a binary tree for all the numbers like a Trie.
For example, if you have array 3 6 2 9 10, binary array would look like
arr = 11, 110, 10, 1001, 1010, and the tree would like
root
/ \
0 1
\ / \
1 0 1
/ \ /
0 1 0
\ \
1 1
If we iterate through each element in binary array, the number(answer) matching the condition should have 0 for every set bit in the element and either 0 or 1 for unset bit in the element.
Now, we only need to traverse these bits into the tree. And if we are able to do it, then there exists at least one number satisfying the condition.
Time complexity O(N).
Reason:- There are n numbers. Each number is of 32 bit binary length. New node creation will take O(1). Therefore, O(32N) => O(N). Same time for inv_arr.
Note: Try converting the numbers into 32 bit binary numbers as it will cover all the numbers specified in the range. Otherwise it will result in a problem. Here 6 and 9 forms a magical pair, but 0110 in the inv_arr cannot be traversed and will result in no magical pair present as traversal of leftmost 0 cannot be done. If all numbers will be represented with same length binary, tree traversal will give correct answer.
Code
public class BinaryNode {
char c;
public BinaryNode left;
public BinaryNode right;
public BinaryNode(char c) {
this.c = c;
}
}
public class BinaryTree {
public BinaryNode root;
public BinaryTree(char c) {
root = new BinaryNode(c);
}
public void addToTree(String s) {
BinaryNode node = this.root;
int length = s.length();
for (int i = s.length()-1; i >= 0; i--) {
BinaryNode newNode;
if (s.charAt(i) == '0') {
newNode = addCharToTree(node.left, s.charAt(i));
node.left = newNode;
} else {
newNode = addCharToTree(node.right, s.charAt(i));
node.right = newNode;
}
node = newNode;
}
}
private BinaryNode addCharToTree(BinaryNode node, char c) {
if (node == null)
return new BinaryNode(c);
return node;
}
}
public class Solution {
private static void findMagicalPairs(List<Integer> list) {
// for creating 32 char long binary string list
List<String> binaryNumberList = list.stream()
.map(num -> Long.toBinaryString( Integer.toUnsignedLong(num) | 0x100000000L ).substring(1))
.collect(Collectors.toList());
// dummy character as root
BinaryTree binaryTree = new BinaryTree('c');
binaryNumberList.forEach(binaryTree::addToTree);
List<Boolean> booleanList = binaryNumberList.stream()
.map(s -> hasMagicalPair(s, binaryTree.root))
.collect(Collectors.toList());
}
private static boolean hasMagicalPair(String s, BinaryNode node) {
if (s == null || s.length() == 0)
return true;
if (node == null)
return false;
String substring = s.substring(0, s.length() - 1);
if (s.charAt(s.length()-1) == '1')
return hasMagicalPair(substring, node.left) ;
return hasMagicalPair(substring, node.left) || hasMagicalPair(substring, node.right);
}
}
First of all, sorry for the long answer :)
Problem: I think the problem with your brute force is that you are performing each checking twice (in both directions). Moreover, a lot of checkings are unnecessary.You can easily reduce the number of iterations by doing every checking only once (and only the necessary ones).
Key idea: You should not start the inner loop from 0.
Note: The first of the following sections only introduce the second, but the second section is the one that answers your question.
The whole code provided here is only meant to illustrate the stated ideas, nothing more.
1 - Find all possible magical pairs
Here we are trying to find all possible magical pairs in the given vector avoiding to check multiple times the same pair.
A solution could be:
std::vector<std::pair<int, int>> magical_pairs(const std::vector<int> & data)
{
std::vector<std::pair<int, int>> result;
for(size_t i = 0; i < data.size()-1; ++i) // Stop at second to last
{
for(size_t j = i+1; j < data.size(); ++j) // Start from i+1 and not 0
{
if((data[i] & data[j]) == 0)
result.push_back(std::make_pair(data[i], data[j]));
}
}
return result;
}
This way, you check all possible pairs only once.
According to me, if you want to get all possible magical pairs, you cannot reduce the complexity less than what it takes to check all possible pairs only once.But if someone has a better solution, I will be very interested to hear it (read it).
You can run an example this way:
std::vector<int> input_array {3, 12, -6, 27, 8, 18, -66, 47, 11}; // input example
for(const std::pair<int, int> & mp : magical_pairs(input_array))
std::cout << mp.first << " : " << mp.second << std::endl;
The results for this example:
3 : 12
3 : 8
12 : 18
8 : 18
2 - Check whether a number has a magical pair or not
Now that we know how to avoid to check already checked pairs, we will reuse the same principle to realize the function you want.
You want to check for every number in the array whether they have a magical pair in the array or not.In this case, we don't want to check all possible magical pairs, only one match is sufficient to determine if a number has a pair. Moreover, when we find a match, we can set two results at a time (one for each number of the pair).You can see that this way, we will be able to significantly reduce the number of iterations.
It leads us to proceed as follows:
Check every pair only once
Stop evaluation of a number at first match
Determine two results per match --> don't perform the search if already set
Knowing this, a solution could be:
std::vector<bool> has_magical_pair(const std::vector<int> & data)
{
std::vector<bool> result(data.size(), false);
for(size_t i = 0; i < data.size()-1; ++i) // From 0 to second to last
{
if(!result[i]) // search for a magical pair only if not already found
{
for(size_t j = i+1; j < data.size(); ++j) // From i+1 to last
{
if((data[i] & data[j]) == 0)
{
// Set two results at a time
result[i] = true;
result[j] = true;
break; // Exit the inner loop at first match
}
}
}
}
return result;
}
This way, you will be much more efficient than the brute force method.
You can run an example this way:
std::vector<int> input_array {3, 12, -6, 27, 8, 18, -66, 47, 11};
for(bool hmp : has_magical_pair(input_array))
std::cout << hmp << ", ";
std::cout << std::endl;
The results for this example:
1, 1, 0, 0, 1, 1, 0, 0, 0,
I think you will be able to adapt the code of this example to your use case quite easily.
I hope it can help you.
You have to save the operations you do first.
In the example you have 3 6 2 9 10
When you do it by brute force you first do
3 & 6
And after doing all the
3 & y
you repeat
6 & 3
. If you find how to avoid repeating this, you'll solve the problem.

Checking an array for existing values in C++

I've got this project I'm working on and it is an rpg game running in the cmd. The player navigates his character through the keyboard and fights enemies to level up and so on. I'm using a 2D array as a grid/map and in the demo version everything is working OK.
Problem: Now, in the more advanced version, I have a class which is used to load game/start new game. The function, that starts a new game, basicly creates .txt save files in which the information is stored. The problem is in the function that generates an enemy list. The enemy characteristics that are being generated, and where the problem is, are the X and Y coordinates. Here is a little bit of code showing the process:
void enemyGenerator(int level)
/* Declare the random generator */
std::default_random_engine generator((unsigned)time(0));
std::uniform_int_distribution<int> coordsX(1, 28); //There are 30 rows, from which the first and the last are border
std::uniform_int_distribution<int> coordsY(1, 48); //50 columns; first and last are border
/* Declare some variables */
int x, y;
bool ready = "False";
/* Check what level is demanded, for example level 1 */
if (level == 1)
{
while(true)
{
//Generate X and Y
x = coordsX(generator);
y = coordsY(generator);
//Now where the problem appears to be
//There will be 600 enemies = 1200 coordinates, so I have declared an array in the .h file
//Called coordinates[1200] = {}; now I want to check it bottom to top if
//the newly generated coordinates are already existing, so:
for (int i = 0; i < 1200; i += 2) //1200 = array size; += 2, because we're checking x & y at once
{
if (x != coordinates[i] && y != coordinates[i + 1] && x + y != 2) //x + y can't be 2, because this is where the player starts (1, 1)
{
if (i == 1198) //If these are the last x and y in the array
{
ready = "True";
break;
//Break the for loop with status ready
}
else
{
continue;
//If it isn't the end of the array simply continue checking
}
}
else
{
ready = "False";
break;
//If the x and y match with the ones in the array, then break with status not ready
}
}
if (ready)
{
break;
//If status is ready then break the loop and assign the rest of the stats
}
else
{
continue;
//If status is not ready then continue generating random values
}
}
//Here I define the values of the stats in private variables of the class
eX = x;
eY = y;
eLVL = 1;
//etc...
}
This is the generating code. And here is how I use it:
void newGame()
....
//I've reached to the point where I want to deploy for example 10 enemies of level 1
for (int i = 0; i < 10; i++)
{
enemyGenerator(1);
//I have an already defined fileWriter (std::fstream; std::ios::out)
fileWriter << eX << " " << eY << " " << eLVL; //<< " " etc...
}
....
Everything seems logical to me, the only illogical thing is that it is not working. The output in enemyList.txt I get is for example 3 5 1 (other stats) 3 5 1 (other stats) 3 5 1 (other stats), you get it.
Question: Can you spot any error? Can you show me the right way? If more of the code is required I can even send you the source file, just for the sake of curing my headache.
The problem there is with your random generator.
You are setting the seed of the generator everytime enemyGenerator() is called with the current time. But since you call enemyGenerator multiple times in the same fraction of a second, the time value is the same, hence the random generator seed is the same everytime, which will give you the same random pattern each successive call.
Either use the same generator for all the calls
...
std::default_random_engine random_generator((unsigned)time(0));
//I've reached to the point where I want to deploy for example 10 enemies of level 1
for (int i = 0; i < 10; i++)
{
enemyGenerator(random_generator, 1);
//I have an already defined fileWriter (std::fstream; std::ios::out)
fileWriter << eX << " " << eY << " " << eLVL; //<< " " etc...
}
....
with the enemyGenerator function is defined as
void enemyGenerator(std::default_random_engine& generator, int level)
or seed your generator with a different value each time.
Edit:
Well it seems it isn't the cause of your problem but you should still consider what I wrote.

finding out the divisors of a number

What is the most optimized approach of finding out the number of divisors of a number,such that the divisors have at least the digit 3 in it?
e.g. 21=1,3,7,21
therefore only one divisor has the digit 3 in it.
e.g.
62=1,2,31,62
therefore only one divisor has the digit 3 in it and i.e. 31
EDIT-i realized that the best way to do this woulds be to find out all the factors of a number and check for the factors containing the digit 3.
the best way to find out the factors :
Getting Factors of a Number
What is the best way to get all the divisors of a number?
Here is an expansion on my take. It first checks if there is a possible factor in the list div3. If not, it adds candidates up to number/2, skipping values that already could be factored according to this list, so '37' and '43' get added, but not '36' or '39'.
The above part should be considered "setup". If you know the input constraints (a maximum input value), you can calculate the vector div3 once, then store it inside the program.
If the list div3 is up to date, the input should be factored into one of these numbers. If it can't then none of its factors contain a '3'. If it can, this shows the remainder, which can be factored further using conventional methods.
I consider this "optimized" because the constraint "any factor should contain a '3'" is checked first. Only if any valid factor is found, you need to calculate all the others.
My first program using <vector> and its ilk, so be gentle in your comments :-)
(Edit) I now notice the factor checking loop goes over the entire div3 vector. Of course, it only needs to go up to number/2. Left as an exercise to the reader.
(Additional edit) find3 is here a reverse iterator. For some reason that seemed appropriate, but I can't recall why I thought so :) If checking up to and including number/2, you need to change it to a regular forward iterator.
#include <iostream>
#include <vector>
using namespace std;
int contains_3 (int value)
{
while (value && (value % 10) != 3)
value /= 10;
return value;
}
int main (int argc, char **argv)
{
int number, found_flag, last_div3, adjust, adjust_digit;
vector<int> div3;
vector<int>::reverse_iterator find3;
vector<int>::iterator it;
// a little seeding
div3.push_back(3);
div3.push_back(13);
div3.push_back(23);
if (argc != 2)
return -1;
number = atoi (argv[1]);
found_flag = 0;
// do we need to expand div3?
last_div3 = div3.back();
while (last_div3 * 2 < number)
{
// if this number contains a '3' in any other place than the last,
// simply increment it
if ((last_div3 % 10) != 9 && contains_3(last_div3/10))
{
last_div3++;
} else
{
// no? then simply pick the next multiple of 10 and add 3
last_div3 /= 10;
last_div3++;
last_div3 *= 10;
if (!contains_3(last_div3))
last_div3 += 3;
}
// check if it should be in the list
for (it = div3.begin() ; it != div3.end() && (last_div3 % *it); ++it) ;
if (it == div3.end())
{
div3.push_back(last_div3);
}
}
cout << "list is now: ";
for (it = div3.begin() ; it != div3.end(); ++it)
cout << ' ' << *it;
cout << endl;
for (find3 = div3.rbegin(); !found_flag && find3 != div3.rend(); find3++)
{
if (!(number % *find3))
{
cout << "candidate: " << *find3 << ", remaining to sieve: " << number/(*find3) << endl;
found_flag++;
}
}
if (!found_flag)
cout << "None found" << endl;
return 0;
}