The Quest for the Boolean of Truth

You land among a sea of zeroes .
Here's your big chance to be a hero!

Your quest will be long, forsooth.
Where will lie the Boolean of Truth?

Details and assumptions:

  • Be warned that the file size is 20 MB
  • The 1st position is 0 0 , 2nd position is 1 1 , and so on.
  • The Boolean of Truth is 1.


The answer is 19398533.

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

4 solutions

Pi Han Goh
Jun 28, 2015

Step 1) Download file

Step 2) Open notepad of said file

Step 3) Copy a couple of first few 0's from the said notepad into Microsoft word

Step 4) Delete pages 2,3,4, and so on.

Step 5) Ctrl+F and replace "0" with "z"

Step 6) Note the total number of "0"s that can fit into one page: which is 3600.

Step 7) Calculate the number of zeros in one row: 80

Step 8) Copy the entire file into a new Microsoft Word spreadsheet

Step 9) Wait for awhile because it's a large file

Step 10) Ctrl+F: Search for number 1

Step 11) Wait again

Step 12) Record page number: 5389

Step 13): See page 5389

Step 14) Calculation time:

So there's 5388 pages full of zeros + the last page which has 80 × 22 26 80 \times 22 - 26 zeros.

The number of zeros before the number 1 is 5388 × 3600 + 80 × 22 26 = 19398534 5388 \times 3600 + 80\times 22 -26 = 19398534 .

But since we start with 0 instead of 1, we need to subtract one. Answer is 19398533 19398533 .

Moderator note:

There is a much better way than brute force search and count.

You are a champion. Thank you, Pi.

Brock Brown - 5 years, 11 months ago

Log in to reply

Haha, I learn from the best . SmileyFace.png

Pi Han Goh - 5 years, 11 months ago
Arulx Z
Jun 29, 2015

Python one liner -

1
open('sea.txt', 'r').read().index('1')

Java solution -

EDIT

Seems like Java also provides an index method -

1
new IO("sea").read().indexOf('1');

Old solution -

1
2
3
4
String n = (new IO("sea")).read(); //IO is a class written by me to read files.
for(int i = 0;; i++)
    if(n.charAt(i) == '1')
        System.out.println(i);

I wrote solutions in both languages because I considered the first index as 1 1 instead of 0 0 .

Moderator note:

Good solutions! Sometimes, being aware of what commands a particular language has allows you to simplify your code.

Brock Brown
Jun 28, 2015

Python 3.3:

1
2
3
4
5
position = 0
with open('sea.txt', 'r') as sea:
    while sea.read(1) != '1':
        position += 1
print("BOOLEAN OF TRUTH found at", position)

Masbahul Islam
Jul 5, 2015

x=0

a=open('C:\Users\User\Downloads\sea.txt','r')

for b in a:

for c in b:

    if c=='1':

        print c,x

    x=x+1

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...