C++ reading from file is not giving expected, or any output - c++

I am trying to make a game which loads it's levels from a text file. I decided to do this with the help of a 2 dimensional vector of integers. Before implementing it in my main code, I first decided to check whether my logic was right so I made a Test.txt file containing the the level I wanted to draw.
Test.txt:-
1 1 0 0 1 0 0 0 0 0 1 1 1 1 1 1 1 0 1 0 1 0 0 1 0 0 1 0 0 1 1 0
1 0 1 0 1 1 1 0 1 1 0 1 1 0 1 1 1 0 1 0 0 1 1 1 1 1 1 0 0 1 0 0
0 0 0 0 0 0 0 1 0 1 0 0 0 1 1 0 1 1 0 0 0 0 0 0 1 0 0 1 0 1 1 0
0 0 1 1 1 1 1 0 0 0 1 0 1 0 1 1 0 0 0 1 1 1 1 0 0 0 1 0 1 1 1 0
1 0 0 0 1 0 0 0 1 1 1 1 1 1 1 1 1 1 1 0 1 0 0 0 0 0 1 0 0 1 0 1
0 1 0 1 0 1 1 1 0 0 1 0 0 0 0 1 0 1 0 0 1 0 1 1 0 0 0 0 1 1 0 1
0 1 1 1 0 1 1 0 1 0 1 1 0 1 1 0 0 1 0 0 0 1 1 0 1 1 1 1 1 1 0 1
0 0 0 0 0 0 0 1 1 0 1 1 0 0 0 0 0 1 0 1 0 1 1 0 0 1 0 0 0 1 0 0
0 0 1 1 1 0 0 0 1 0 0 1 1 1 1 0 0 1 1 0 0 0 1 1 1 0 1 1 1 1 0 1
0 1 0 0 1 1 0 0 1 0 1 1 0 1 0 0 1 1 0 1 1 0 1 0 0 1 1 1 1 0 1 1
1 1 0 1 1 1 1 0 0 1 0 0 1 0 0 1 0 1 0 1 1 1 1 1 0 0 0 1 1 0 1 0
0 0 1 0 0 0 1 1 1 0 1 0 0 1 0 1 1 0 0 0 1 1 0 1 0 0 0 0 1 1 0 1
0 1 1 0 0 0 0 0 0 1 1 0 1 1 0 1 1 0 1 0 0 1 0 0 1 1 0 1 1 1 1 0
1 0 1 1 1 0 1 1 1 1 0 0 0 0 0 0 1 0 1 0 0 0 1 1 1 0 0 1 1 0 0 0
1 0 1 1 0 0 0 0 1 0 0 1 1 0 0 0 1 0 0 1 0 0 0 1 0 1 0 1 1 0 0 1
0 0 1 1 1 0 1 1 1 0 1 0 0 0 1 0 1 1 1 1 0 0 0 0 0 0 1 1 1 1 1 0
0 0 0 1 0 1 0 1 0 1 0 0 1 1 1 0 0 1 1 0 1 0 1 0 1 1 1 0 0 0 1 0
1 0 1 0 1 0 0 0 1 1 0 0 0 1 0 1 1 1 1 1 0 0 1 0 1 0 1 1 1 1 1 1
Each integer is seperated by a space and only one number is supposed to be read once at a time. The 1 and 0 tell the game which tile to draw. Now, with this wrote the following code in c++ to read the file and populate the vector with it's contents. After that it's supposed to output the contents of the vector.
Test.cpp:-
#include <iostream>
#include <fstream>
#include <vector>
using namespace std;
int num;
vector<vector<int>> nums;
int main(void) {
ifstream FileIn;
FileIn.open("Test.txt");
for(int i = 0; i < 18; i++) {
vector<int> temp;
for(int j = 0; j < 32; j++) {
FileIn >> num;
temp.push_back(num);
}
nums.push_back(temp);
temp.clear();
}
cout << nums.size() << '\n'; // outputs 18
for (unsigned int i=0; i < nums.size(); i++) {
for (unsigned int j=0; j < nums[i].size(); j++) {
cout << nums[i][j];
if (j == nums[i].size() - 1) cout << '\n';
}
}
FileIn.close();
return 0;
}
but this is where the problem starts. The code doesn't output anything to the terminal it just starts and then goes back to the prompt.
The executable compiles with no errors and there are no crashes or runtime error either. There is just no output.
Things i have tried:
Putting in spaces between the numbers
Keeping all integers on the same line
both of the solutions above, but together this time
I am using atom with the platformio terminal plugin on windows 10 (64-bit) on a intel with amd-64 architecture. Any help would be very appreciated.

A few things: Start learning how to use a debugger. Your question to stackoverflow is something you probably could easily answer on your own, if you stepped through your code with a debugger. That'd save you time - and us.
Edited:
Also, you open 'test.txt' without verifying or setting the "current working directory". This will work only if you start the application from the same path, test.txt is in. But if you run the app from someplace else, the working directory may be different.
You did not check for eof or any other error condition. How do you know if opening the file did actually work? Or reading the number? Or that there are exactly the amount of numbers you are expecting.
Checking error conditions may seem like a nuisance, but it's definitely not. Hunting for errors, which you did not check in your code, is much more time consuming than forming a habit to check for errors.
Here is some code:
ifstream FileIn;
FileIn.open("test.txt");
if (!FileIn.good())
cerr << "Could not open file...";
else {
while (!FileIn.eof()) {
int num; ///!!! DONT make `num` a global variable
FileIn >> num;
if (FileIn.bad()) {
cerr << "Invalid number in file...";
return 1; // return prematurely from the application
}
// Do something with the number
}
}
Also, use cout << endl instead of cout << '\n';. endl is the official way of inserting a line break and it will work on any platform, whereas '\n' may or may not work. Some platforms require two characters.

So I finally found the problem, the code, logic, text file everything were working fine. After taking the advice about debuggers from the other answer, this time instead of using atom's terminal plugin, I used powershell and it worked. It gave the output i was expecting. Then i tried the same code with the atom's terminal and that gave no output. So the problem seemed to be not in the code but in the terminal I was using.

Related

When I use file as the input of a c++ programs, it Corrupts

I use a file as the input for a c++ programs, and the input is not complete. When I output the results to another file, it meets some problems.
Because of the uncompleted input, I think the programs will shutdown after the program, but it doesn't. It continue running and drop into a loop that never ends.
Here's the src of the program:
#include <stdio.h>
int main()
{
while(1) {
int n,i,j;
int a[100][100]={0};
int row[100]={0};
int col[100]={0};
scanf("%d",&n);
if (n==0) break;
int numr=0,numc=0,cr=0,cc=0;
for (i=0;i<n;i++) {
for (j=0;j<n;j++) {
scanf("%d",&a[i][j]);
row[i]=row[i]+a[i][j];
}
if (row[i]%2!=0) {numr++; cr=i;}
}
for (j=0;j<n;j++) {
for (i=0;i<n;i++) col[j]=col[j]+a[i][j];
if (col[j]%2!=0) {numc++; cc=j;}
}
if ((numr==0)&&(numc==0)) printf("OK\n");
else if ((numr==1)&&(numc==1)) printf("Change bit (%d,%d)\n",cr+1,cc+1);
else printf("Corrupt\n");
}
}
And I use the g++ commond to compile the file
g++ testid.cpp -o testid
The input file is:
99
0 0 1 1 1 1 0 1 0 0 1 1 0 0 1 1 1 1 1 0 0 0 1 1 1 0 1 1 0 0 0 1 0 0 1 1 0 1 1 0 0 0 1 1 1 0 1 1 0 0 1 0 0 1 0 0 0 1 1 1 1 1 1 0 0 1 0 1 1 0 0 0 0 0 0 0 0 1 1 0 1 0 1 0 0 1 1 1 0 1 0 1 1 0 1 1 0 1 0
And I run the programs:
./testid < sample.in > out
It drops into a never ending loops.
The output file look likes:
Corrupt
OK
OK
OK
OK
OK
OK
OK
OK
OK
OK
OK
OK
But I wants the result be null for I have not complete my input.
What is problem? How does it work?
With while(1), you made an infinite loop.
Instead of else printf("Corrupt\n"); try
else {
printf("Corrupt\n");
break ;
}
NB: To clarify, you keep looping and call scanf without any input resulting in
i == 0 and numr == 0 and numc == 0
You probably also want to write an exit statement for when you succeed, but this is not the question you asked.

generating combinations of combinations

I'm trying to generate code which will take the components (i.e, a-f) of various combination permutations (combo) one, two, three, or four units long using these six components and provide various non duplicating combinations of combinations (combo.combo) which contain all of the components (i.e., [ab + cdef and ac + bde + f] but not [ae + bc + df and aef + bc + d]).
It would be nice if this code could allow me to 1) input the number of components, 2) input the min and max unit length per combo, 3) input the min and max number of combos per combo.combo, and 4) randomize the output list of combo.combos.
Maybe start with some kind of iteration loop to generate each version of the 720 possible component combinations (a-f) and then start pruning that list based on the set limiting parameters? I've got some working knowledge of python and will get started, but any tips or suggestions are most welcome.
combo.combo a b c d e f
a.bcdef 1 1 1 1 1 1
ab.cdef 1 1 1 1 1 1
abc.def 1 1 1 1 1 1
abcd.ef 1 1 1 1 1 1
abcde.f 1 1 1 1 1 1
a.b.cdef 1 1 1 1 1 1
a.bc.def 1 1 1 1 1 1
a.bcd.ef 1 1 1 1 1 1
a.bcde.f 1 1 1 1 1 1
ab.c.def 1 1 1 1 1 1
I've found a lot of code which will generate combination permutations but not combinations of combinations. I've included a binary matrix for the combination components, but am stuck on where to proceed from here or if this matrix is a false start (although a helpful visual aide.)
combo a b c d e f
a 1 0 0 0 0 0
b 0 1 0 0 0 0
c 0 0 1 0 0 0
d 0 0 0 1 0 0
e 0 0 0 0 1 0
f 0 0 0 0 0 1
ab 1 1 0 0 0 0
ac 1 0 1 0 0 0
ad 1 0 0 1 0 0
ae 1 0 0 0 1 0
af 1 0 0 0 0 1
bc 0 1 1 0 0 0
bd 0 1 0 1 0 0
be 0 1 0 0 1 0
bf 0 1 0 0 0 1
cd 0 0 1 1 0 0
ce 0 0 1 0 1 0
cf 0 0 1 0 0 1
de 0 0 0 1 1 0
df 0 0 0 1 0 1
ef 0 0 0 0 1 1
abc 1 1 1 0 0 0
abd 1 1 0 1 0 0
abe 1 1 0 0 1 0
abf 1 1 0 0 0 1
acd 1 0 1 1 0 0
ace 1 0 1 0 1 0
acf 1 0 1 0 0 1
ade 1 0 0 1 1 0
adf 1 0 0 1 0 1
aef 1 0 0 0 1 1
bcd 0 1 1 1 0 0
bce 0 1 1 0 1 0
bcf 0 1 1 0 0 1
bde 0 1 0 1 1 0
bdf 0 1 0 1 0 1
bef 0 1 0 0 1 1
cde 0 0 1 1 1 0
cdf 0 0 1 1 0 1
cef 0 0 1 0 1 1
def 0 0 0 1 1 1
abcd 1 1 1 1 0 0
abce 1 1 1 0 1 0
abcf 1 1 1 0 0 1
abde 1 1 0 1 1 0
abdf 1 1 0 1 0 1
abef 1 1 0 0 1 1
acde 1 0 1 1 1 0
acdf 1 0 1 1 0 1
acef 1 0 1 0 1 1
adef 1 0 0 1 1 1
bcde 0 1 1 1 1 0
bcdf 0 1 1 1 0 1
bcef 0 1 1 0 1 1
bdef 0 1 0 1 1 1
cdef 0 0 1 1 1 1
The approach which first comes to mind is this:
generate all the combinations using the given components (which you already did :) )
treat the resulting combinations as a new set of components (so instead of a, b,...,f your set will contain a, ab, abc, ...)
generate all the combinations from the second set
from the new set of combinations only keep those which apply to your condition (it's not very clear from your example what the constraint is)
This, of course, has sky-high exponential complexity, since you'll have to backtrack twice and step 3 has way more possibilities.
It's very possible that there's a more efficient algorithm, starting from the constraint ("non duplicating combinations of combinations which contain all of the components").

Writing a 2D vector to a file? c++

I'm wondering how I can output a 2D vector to a file with spaces in between the values. It's to write a map to a file at a specified size that the user chooses. I am already dynamically loading the map from there. I have a basis for the function but I'm kind of lost on the next bit.
void Map::SetMapSize(int sizeX, int sizeY, const char *filename)
{
std::ofstream out(filename);
out << "[Map]" << std::endl;
MapSizeVector[sizeX][sizeY];
for(int i = 0; i <= sizeX; i++)
{
for(int j = 0; j <= sizeY; j++)
{
std::ostream_iterator<std::string> output_iterator(out, " ");
}
}
}
The Map.txt looks like this:
[Map]
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 1 1 0 0 0 1 1 0 0 1 1 1 1 1 1 0 0
0 0 1 1 0 0 0 1 1 0 0 1 1 1 1 1 1 0 0
0 0 1 1 0 0 0 1 1 0 0 0 0 1 1 0 0 0 0
0 0 1 1 0 0 0 1 1 0 0 0 0 1 1 0 0 0 0
0 0 1 1 1 1 1 1 1 0 0 0 0 1 1 0 0 0 0
0 0 1 1 1 1 1 1 1 0 0 0 0 1 1 0 0 0 0
0 0 1 1 0 0 0 1 1 0 0 0 0 1 1 0 0 0 0
0 0 1 1 0 0 0 1 1 0 0 0 0 1 1 0 0 0 0
0 0 1 1 0 0 0 1 1 0 0 1 1 1 1 1 1 0 0
0 0 1 1 0 0 0 1 1 0 0 1 1 1 1 1 1 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
It also has a details bit underneath it. Basically, I want to rewrite that [Map] part to whatever size x and y the user requests above the [Details] and replacing the existing [Map] part. The numbers are fine with being 0. Thanks!
Declaration of vector in Map.h
std::vector <std::vector <int> > MapSizeVector;
Your function should look like this:
void Map::SetMapSize(int sizeX, int sizeY, const char *filename)
{
std::ofstream out(filename);
out << "[Map]" << std::endl;
MapSizeVector.resize(sizeX);
for(int i = 0; i < sizeX; i++)
{
MapSizeVector[i].resize(sizeY);
for(int j = 0; j < sizeY; j++)
{
char str[20];
sprintf(str, "%d ", MapSizeVector[i][j]);
out << str;
}
out << '\n';
}
}

3d maze recursion method - c++

I am making a 3D maze in c++. I am having trouble with a recursive method to find a valid path between the two endpoints (starting point is m[0][0][0]; endpoint is m[7][7][7];). It checks positions in the array. If its contents are a 1, then it is a valid part of the path; if 0, it is not a valid part of the path. Here is my method:
bool Maze::findPath(int row, int column, int level,string path){
cout << "findPath " << row << ", " << column << ", " << level << " value " << m[row][column][level] << endl;
if(row < 0 || row > 7 || column < 0 || column > 7 || level < 0 || level > 7 ){
cout << "Out of bounds" << endl;
//system("PAUSE");
return false;
}
else if(m[row][column][level] == 0){
cout << "spot is zero" << endl;
//system("PAUSE");
return false;
}
else if(visited[row][column][level] == 1){
cout << "visited" << endl;
return false;
}
else if(row == 7 && column == 7 && level == 7 && m[row][column][level] == 1){
cout << "Found!" << endl;
//system("PAUSE");
return true;
}
else{
visited[row][column][level] = 1;
//cout << "searching..." << endl;
if(row < 7 && findPath(row + 1,column,level,path))
return true;
if(column < 7 && findPath(row,column + 1,level,path))
return true;
if(level < 7 && findPath(row,column,level + 1,path))
return true;
if(row > 7 && findPath(row - 1,column,level,path))
return true;
if(column > 7 && findPath(row,column - 1,level,path))
return true;
if(level > 7 && findPath(row,column,level - 1,path))
return true;
}
return false;
}
So the method checks for "Out of bounds", an invalid spot on the path (zero), a visited location. I'm not sure what exactly I'm missing, but the method returns true to mazes that are unsolvable. Can anybody see some blatant mistake that I may be missing with my recursive call? Thanks
EDIT: Fixed a few code mistakes, but it still seems to be "solving" unsolvable mazes.
Here's an example of a solvable maze that it is saying is not possible to solve:
1 0 0 0 0 0 0 1
0 0 0 0 0 1 0 0
0 0 0 0 0 0 0 0
0 0 0 1 0 0 0 1
0 0 0 1 0 0 0 0
1 0 0 1 0 1 0 0
0 0 0 1 0 0 0 0
1 0 0 1 0 0 0 1
1 0 0 0 0 0 0 0
1 0 0 0 0 0 0 0
1 1 1 1 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
1 0 0 0 0 0 0 0
0 1 1 0 0 0 0 0
0 0 0 1 0 1 1 1
0 0 0 0 0 0 0 1
0 0 0 0 0 0 0 0
0 0 0 1 0 0 0 1
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 1 0 0 0 0 0 0
0 0 0 0 0 0 0 1
0 0 0 1 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 1
0 0 0 1 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
1 0 0 0 0 1 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 1
1 1 1 1 0 0 0 0
0 0 0 1 0 0 0 0
0 0 0 1 0 0 0 1
0 0 0 0 0 0 1 0
0 0 0 0 0 0 1 0
1 0 0 0 0 1 0 0
0 1 0 0 0 0 0 0
1 0 0 0 0 0 0 1
1 0 0 0 0 0 0 0
0 0 0 0 0 0 1 0
0 0 0 0 0 0 1 0
0 0 0 0 0 0 1 0
1 1 1 1 0 0 0 0
0 0 0 1 0 0 0 0
0 0 0 1 0 0 0 0
1 1 1 1 0 0 0 1
1 1 1 1 1 1 1 1
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 1 0 0 0 0 0
0 0 1 0 0 0 0 0
0 0 1 0 0 0 0 0
0 0 1 0 0 0 0 0
0 0 1 0 0 0 0 1
0 0 1 0 0 0 0 1
0 0 1 0 0 0 0 1
0 0 1 0 0 0 0 1
0 0 1 1 0 0 0 1
0 0 0 1 0 0 0 1
0 0 0 1 0 0 0 1
0 0 0 1 1 1 0 1
There's a problem in the findPath(++row,column,level,path) (and similar recursive calls): you don't want the variable increments to carry over to the other recursive calls. (For example, the variable row in findPath(row,++column,level,path) would be affected by the first recursive call.)
Use findPath(row + 1,column,level,path) (and similar) instead.
Also, in the last three recursive calls, you're not making the right tests:
//instead of level < 7
if(level < 7 && findPath(--row,column,level,path)) //should be row > 0
return true;
if(level < 7 && findPath(row,--column,level,path)) //should be column > 0
return true;
if(level < 7 && findPath(row,column,--level,path)) //should be level > 0
return true;
EDIT
However, you don't actually need these tests since you filter out out of bounds errors at the top of your recursive function. Therefore, these calls can be simplified to:
return findPath(row + 1,column,level,path) || findPath(row,column + 1,level,path)
|| findPath(row,column,level + 1,path) || findPath(row - 1,column,level,path)
|| findPath(row,column - 1,level,path) || findPath(row,column,level - 1,path);
Additionally, the test && m[row][column][level] == 1 is redundant since the else if(m[row][column][level] == 0) takes care of that. (I'd check m[7][7][7] before even calling this function the first time, by the way.)
I just Finished this algorithm as an assignment for a class, ours only used a 5x5 block as the maze, but I found that it will go very slowly testing all possibilities each time it reaches the block from any angle, I found that the program can be sped up significantly by setting values in your array to 0 as you determine that they're not useful. I did it at the return false at the end of the function.

Exact Large Finite Field Linear Algebra Library (e.g. GF(2^128) / GF(2^256) ) [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a book, tool, software library, tutorial or other off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 8 years ago.
Improve this question
General
I'm looking for a library that is able to do exact calculations on large finite fields such as GF(2128)/𝔽2128 and GF(2256)/𝔽2256. I listed the features that I need and the features that would be cool below. Obviously, the library should be as fast as possible :-). Ah, since I'm no C++ master (and probably most of the libraries are C++), sample code of say generate a random element/a constant and multiply it to it's multiplicative inverse
Must-Have Features
Addition of field elements
Multiplication of field element
Find the multiplicative inverse of a field element
Nice to Have Features
Vector/Matrix support
Random Element support
Libraries I already looked at that will probably not work
FFLAS/FFPACK, seems not to work with such large finite fields
Givaro, seems not to work on such large finite fields
Libraries I already looked at that could work (but I was unable to use)
NTL, I was not able to invert an element, but it should really work since SAGE seems to use this library when defining GF(2^256) and there an element can be inverted using x^(-1)
PARI/GP, I was not able to find everything I need in the documentation, but the SAGE documentation kind of says that it should work
Other notes
I'm writing a Haskell program and will interface that library later, so easier Haskell interfacing is better :-)
The NTL library seems to work, using this (sorry I'm quite unable to program in C++) code
#include <NTL/GF2E.h>
#include <NTL/GF2EX.h>
#include <NTL/GF2X.h>
#include <NTL/GF2XFactoring.h>
NTL_CLIENT
int main()
{
GF2X P = BuildIrred_GF2X(256);
GF2E::init(P);
GF2E zero = GF2E::zero();
GF2E one;
GF2E r = random_GF2E();
GF2E r2 = random_GF2E();
conv(one, 1L);
cout << "Cardinality: " << GF2E::cardinality() << endl;
cout << "ZERO: " << zero << " --> " << IsZero(zero) << endl;
cout << "ONE: " << one << " --> " << IsOne(one) << endl;
cout << "1/r: " << 1/r << ", r * (1/r): " << (r * (1/r)) << endl;
cout << "1/r2: " << 1/r2 << ", r2 * (1/r2): " << (r2 * (1/r2)) << endl;
}
it seems to work, proof (output of this program):
Cardinality: 115792089237316195423570985008687907853269984665640564039457584007913129639936
ZERO: [] --> 1
ONE: [1] --> 1
1/r: [0 1 0 1 1 0 1 1 1 0 1 1 1 0 0 1 1 0 1 1 1 0 1 1 0 0 0 0 0 1 0 1 0 1 1 0 1 1 0 0 0 0 0 0 1 1 1 0 1 1 1 0 1 0 1 0 0 0 1 1 1 0 1 1 1 1 0 1 0 1 0 1 1 0 1 1 1 0 0 0 1 0 0 1 0 1 1 1 0 1 1 0 1 1 0 0 0 0 0 1 1 0 1 0 1 0 0 0 0 0 1 0 0 1 1 0 0 1 0 0 1 0 1 1 1 1 0 0 1 1 0 1 0 1 1 1 1 1 1 0 1 1 0 0 0 0 0 1 1 0 1 0 0 1 1 1 0 1 1 1 1 1 0 1 0 1 0 0 0 1 1 0 0 1 1 0 0 1 0 1 1 1 0 1 1 1 1 1 0 1 1 0 1 1 1 1 0 1 0 0 0 0 1 1 1 0 1 1 1 0 1 1 1 1 1 1 1 1 0 1 0 1 0 0 1 1 0 1 1 0 1 1 1 1 1 0 0 1 1 0 1 0 1 0 0 0 0 1 1 0 0 1 1 1 0 1], r * (1/r): [1]
1/r2: [1 0 1 1 0 0 0 0 1 0 1 0 0 0 1 0 0 0 1 1 0 0 1 0 1 0 0 0 1 1 1 0 0 0 1 1 1 1 1 0 1 0 1 1 0 0 1 1 1 0 1 0 1 0 0 1 0 0 0 0 1 1 1 0 0 0 1 1 1 1 1 0 0 1 0 0 0 1 1 0 1 0 1 1 1 0 0 1 0 1 0 1 0 0 1 0 0 0 1 0 0 1 1 1 1 1 0 0 0 0 1 1 1 0 1 0 1 0 1 0 0 0 1 0 1 0 1 1 0 0 0 1 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 1 1 1 0 1 1 0 0 0 0 1 1 0 1 1 1 0 1 0 0 0 0 0 1 1 0 1 1 1 0 0 0 0 1 1 0 1 0 0 0 0 1 0 0 0 0 1 1 1 1 1 0 1 0 1 1 0 1 0 1 0 1 1 1 1 0 0 1 1 0 1 1 1 1 1 0 1 1 1 0 1 0 0 0 0 1 0 1 1 0 0 0 1 1 0 0 1 1 0 1 0 0 1 0 1 0 0 1 1], r2 * (1/r2): [1]
Even inverting seems to work (scroll as right as possible in the output sample above) :-)