yashsingh1/xdaforums huggingface dataset:
[Off-topic] stephj:
I have a wooden box full to the brim with ball bearings.

It is 43 balls long, 33 balls wide and 26 balls deep.

There are no prizes for figuring out that there are 36,894 balls in the box.

They must be arranged in the shape of a pyramid of one of the following types.

(1) A triangular pyramid, (tetrahedron), in which each ball rests on three balls in the level below it. And each layer apart from the solitary ball on the top, is an equilateral triangle.

(2) A square pyramid, (a classic ancient Egyptian pyramid), in which each ball rests on four balls in the level below it. And each layer apart from the solitary ball on the top, is a perfect square.

(3) A rectangular pyramid in which each ball rests on four balls in the level below it, and each layer is a rectangle, apart from the top layer, which is a single line of balls.

Every ball must be used, and every layer must be complete, (i.e. no gaps), and also the pyramid must have more than one layer. (A single line of 36,894 balls, is a nice try, but it contradicts this rule.)

So how is it done? What type of pyramid is it, how many layers does it have, and how many balls are in the bottom layer?

A spreadsheet or a few lines of code may help, but you will still have to use a bit of grey matter first!
[Off-topic] Dblfstr:
Rectangular Pyramid.

The top of the pyramid is a row of 11 bearings.

43 total layers.

Bottom layer: 2279 bearings.
[Off-topic] 4silvertooth:
Triangle Pyramid xn = n(n+1)/2 (Doesnt uses all bearings at 59th layer, 35990 bearings used no more bearing for further layers)

Square Pyramid Xn = n*n (Doesnt uses all bearings at 47th layer, 35720 bearings used no more bearing for further layers)

Top layer having 2,3,4 balls line, will have balls in consicutive layer equal to { balls in row number } + 1 * {row number} (i dont know the exact mathematical notation)

So

#include <iostream>

using namespace std;

int main()
{

int total_balls = 36894;
int used_balls = 0;
for(int toprow=2;toprow<=15;toprow++)
{
int current_layer = toprow;
for(int pos=1; pos<= 100; pos++)
{
used_balls+= current_layer * pos;
if(used_balls == total_balls)
{
cout <<"We have a Winner (Maybe) : \n"
<< " Top Row Balls = " << toprow << "\n"
<< " Total Layers = " << pos << "\n"
<< "Numer of balls in " << pos << " layer = " << current_layer * pos << "\n";
return 0;
}
if(used_balls > total_balls)
{
used_balls = 0;
break;
}
current_layer++;
}
}
return 0;
}

Says you have ..rectangular pyramid with

11 Balls in first layer.

43 Total layers.

2279 balls in the last layer.
[Off-topic] Dblfstr:
lol, yes sorry. I did not think anyone was attempting. I did, however, let someone else answer your crypto. :D

I used Summation of [(n*n+y)] = X

Where

n is 1 to infinite,

Y was constant for each iteration; but incremented by 1 for values that were FALSE; y = 1 to infinite until TRUE
[Off-topic] 4silvertooth:
Correct... heres another..

If...

3+4+5+6=91625

4+6+5+3=202410

3+3+9+8=62463

7+8+6+1=49400

7+8+7+8=494849

than what is

9+3+6+9=________?
[Off-topic] stephj:
To Dblfstr and 4silvertooth,

Well done chaps, a sterling effort, now let us up the analysis a notch or two:-

The sum of the balls in a tetrahedral pyramid of n layers is (n*(n+1)*(n+2))/6

The sum of the balls in a square pyramid of n layers is (n*(n+1)*(2n+1))/6

Both of these pyramid types can be ruled out pretty quickly, as 36894 sits between levels 59 and 60 of a tetrahedral pyramid and between levels 47 and 48 of a square pyramid. This has been pointed out above.

Extending a square pyramid to the side by one ball at the top, requires an extra n*(n+1)/2 balls to complete the end slice, one ball wide, to the bottom.

So the equation for the number of balls in a pyramid of depth n, with a single top line width of y is:-

(n*(n+1)*(2n+1))/6 + (n*(n+1)/2*(y-1)

Note that this equation is also still valid for a square pyramid, as the second term disappears if y=1.

Starting with y=2, increase n until the total of balls exceeds or equals 36894, increment y, reset n to 1, and repeat until you hit the jackpot, when the total number of balls finally equals 36894.

Alternatively, have a look at the attached spreadsheet, and search for 36894 as a value.

The answer is a pyramid 43 layers deep with a row of 11 single balls across the top.

We have therefore added 10 triangular 'slices' to the side of a square pyramid 43x43 at the bottom, so the bottom layer is 43x53, which equals 2279 balls.
[Off-topic] Dblfstr:
Given the equations above:

w+x+y+z = abc

Where:

a = (x*w)-x

b = (y*x)-x

c = y*(z-1)

9+3+6+9 = abc

a = (3*9)-9 = 18

b = (6*3)-3 = 15

c = 6*(9-1) = 48

9+3+6+9 = 181548

Or:

(number 2 * number 1) - number 1

(number 3 * number 2) - number 2

number 3 * (number 4 - 1)
[Off-topic] Dblfstr:
2 + 2 = 4

4 + 4 = 8

142 + 468 = 621

3762 + 8271 = ?
[Off-topic] 4silvertooth:
12051

Ans is 3762 + 8271 = 12051

Thats 3762 + 8271 + (sum of digits of their subtraction)

8271 - 3762 = 4509

3762 + 8271 + 4 + 5 + 0 + 9
[Off-topic] Dblfstr:
I will say that your logic is sound.

Doing that method on the equations we get:

With the first

2-2=0, 2+2+0=4

With the second

4-4=0, 4+4+0 = 8

With the third

468-142=326, 468+142+3+2+6 = 621

So far all are correct. So it follows that 8271 - 3762 = 4509, 3762 + 8271 + 4 + 5 + 0 + 9 = 12051.

*********************************************************************************************************************

I will give your credit for finding a pattern in the equations above, however that is not the answer I was looking for.

Here is another equation that follows the same logic, but will not work with the method you described.

27+48=76

Your method would result in:

48-27=21, 48+27+2+1=78

______________________________________________________

So the above problem now becomes:

2 + 2 = 4

4 + 4 = 8

27 + 48 = 76

142 + 468 = 621

3762 + 8271 = ?
[Off-topic] 4silvertooth:
Hint..??
[Off-topic] stephj:
More pyramid stuff....

There are only three tetrahedral numbers, (the sum of the numbers of balls in a tetrahedral pyramid), that are perfect squares.

Two are the tetrahedral numbers 1 and 2, which have 1 and 4 balls respectively.

So what's the other?

Too easy...... You already have the formula above in post #1061, or it is in the spreadsheet attached to the same post.
[Off-topic] Dblfstr:
Not everythIng is based oN the samE set of rules.
[Off-topic] stephj:
How about this........

13143

All the values are in base 9.
[Off-topic] Dblfstr:
Correct.

Guess the hint was not subtle enough?

I have hidden you answer in case 4silvertooth wants to still try.
[Off-topic] stephj:
Square meals............

On a Pacific island, every ten years, there occurs the great rice ceremony.

At the start of the ceremony a single grain of rice is placed on a tray in front of the island chief's house.

Thereafter, an hour later, two grains are added, an hour later, three more, and so on and so forth.

The ceremony continues until the 23 poorest islanders can each be given a square meal.

A square meal is defined as being made from a number of grains of rice that is a perfect square.

How many grains of rice does each of the benificiaries receive?
[Off-topic] stephj:
P.S. Went back to hide the original answer in post #1070

P.P.S I have only just noticed the capital letters in the hint, I originally saw just the word 'based'.
[Off-topic] 4silvertooth:
Now i get it.. would have never thought about it without the hint.. Base-9 values...

---------- Post added at 11:40 PM ---------- Previous post was at 10:49 PM ----------

#include <iostream>
#include <math.h>
using namespace std;

bool is_perfect_square(int n) {
if (n < 0)
return false;
int root(round(sqrt(n)));
return n == root * root;
}

int main()
{

int years = 10;
for(int repeat_hour = 1; repeat_hour <= years * 365 * 24;repeat_hour++)
{
int grains_in_tray = (repeat_hour * (repeat_hour+1))/2;
if(grains_in_tray%23 == 0)
{
if(is_perfect_square(grains_in_tray/23))
{
cout << "Its " << repeat_hour << " hours\n"
<< "Grains in tray " << grains_in_tray << "\n"
<< "Each islander gets " << grains_in_tray/23 << " grains\n"
<< "Which is perfect square of " << sqrt(grains_in_tray/23) << "\n";
}
}
}
return 0;
}

Its 12167 hours

Grains in tray 74024028

Each islander gets 3218436 grains

Which is perfect square of 1794

---------- Post added at 11:49 PM ---------- Previous post was at 11:40 PM ----------

Layer 48. 19600 ball bearings is perfect square of 140
[Off-topic] Dblfstr:
was working on that rice one... :(

I have to write my code in VB in a macro for excel.

I wrote the code.. a bit sloppy;

Sub Rice_Fezt()
'
' Rice_Fezt Macro
Application.ScreenUpdating = False

Dim hour As Double
Dim oldrice As Double
Dim newrice As Double

hour = 1
newrice = 1
oldrice = 1

Range("a1:a1").Select
ActiveCell.Formula = "=SQRT(newrice/23)"

Range("a2:a2").Select
ActiveCell.Formula = "=A1-FLOOR(A1,1)"

Range("C1:C1").Select
ActiveCell.Value = newrice

Range("d1:d1").Select
ActiveCell.Value = oldrice

Range("e1:e1").Select
ActiveCell.Value = hour

Range("a2:a2").Select

'**************************************************************
'**************************************************************

Do While ActiveCell.Value <> 0

If ActiveCell.Value = 0 Then

End

Else

'**************************************************************
'**************************************************************

hour = hour + 1
oldrice = oldrice + 1
newrice = newrice + oldrice

Range("C1:C1").Select
ActiveCell.Value = newrice

Range("d1:d1").Select
ActiveCell.Value = oldrice

Range("e1:e1").Select
ActiveCell.Value = hour

Range("a2:a2").Select

End If

Loop

End Sub

I will eventually get to the right answer :D

Edit:

Macro is done running:

Total Rice grains is 74024028

Total hours was: 12167

Rice grains divided by 23 = 3218436

The square root of that is 1794

~1.4 years

I realize now that I could have used "hour" a two different variables instead of adding the variable "oldrice" - which I had named backwards anyway. :D
[Off-topic] stephj:
Well done chaps, the answers to both problems are correct.

Unfortunately 500+ days is long time to wait for a meal!

An very interesting point is that, the sum of the numbers from 1 to n, which we should know by now is (n*(n+1))/2, can only be divisible by 23, a prime number, if n itself is a multiple of 23.

12167 is 529*23

By just selecting these numbers out of every batch of 506 numbers, (22*23), the processing time can be slashed.

12167 is 24*506+23

The program can be cut down to this:

#include "stdafx.h"
#include <math.h>

int _tmain(int argc, _TCHAR* argv[])

{
long i=1,r,s;
bool not_found=true;

while(not_found)
{
r=((23*i*(23*i+1))/46);
s=(long) sqrt((double)r);
if(s*s==r)
{
printf("%ld\n",23*i);
not_found=false;
}
i++;
}
}

P.S. Not that you would notice much difference on a 3GHz+ PC thse days, but old habits die hard.

P.P.S. We'll move away from number bashing for a while, I'll be back.....
[Off-topic] 4silvertooth:
In 2012 a census taker, who was very intelligent, but eccentric in that he never asked more questions than necessary, came to a house where three of the inhabitants were not at home. To his surprise chuck norris answered the door, he asked chuck, "What is the product of their ages?" Chuck answered, "1,296." "What is the sum of their ages?" "It's the same as the house number." (At this point, we must note that the census taker knew the house number, but you, the problem solver, do not.) The census taker then said, "I still can't tell their ages. Are any of them older than you?" Then chuck answered, "No," the census taker said, "Now I know all their ages!"

What are those ages?
[Off-topic] stephj:
Have a look at post #1030, the answer is a few posts later.
[Off-topic] 4silvertooth:
Oops been away for long, will take a while to go through all threads..
[Off-topic] Dblfstr:
Complete this sequence of letters: o, t, t, f, f, s, s, _, _, _.

---------- Post added at 08:18 AM ---------- Previous post was at 08:14 AM ----------

Also:

A man has to get a fox, a chicken, and a sack of corn across a river. He has a rowboat, and it can only carry him and one other thing. If the fox and the chicken are left together, the fox will eat the chicken. If the chicken and the corn is left together, the chicken will eat the corn. How does the man do it?
[Off-topic] stephj:
First:

e,n,t

eight,nine,ten.

Second:

1 Take the hen over and drop it.
2 Return
3 Take the fox over and drop it, returning with the hen
4 Drop the hen and take the corn over and drop it
5 Return
6 Finally take the hen over. Done.
[Off-topic] Dblfstr:
Well done. Those were probably too easy. I will try to find some really hard ones. :D
[Off-topic] stephj:
If it takes a hen and a half, a day and a half, to lay an egg and a half, how long does it take twelve hens to lay a dozen eggs?
[Off-topic] Dblfstr:
A day and a half, egg rate is 3 days for 2 eggs; 2/3 egg/hen*day

Fun fact

Hens lay a single egg every day. This is part of their cycle. These eggs will only produce a baby chick if it is fertilized by a rooster before hand. Also, Hens have the ability to eject the male sperm if they feel that there is a better suitor.
[Off-topic] stephj:
I'm afraid not. Think again.

The clue is deliberately obfuscating.
[Off-topic] Dblfstr:
Yp. fixed. Did some math. :D
[Off-topic] stephj:
That's better.
[Off-topic] stephj:
Easier:

Find four consecutive prime numbers that add up to 220.

Harder:

Find a series of consecutive prime numbers that add up to 106620. There are two possible answers.

Harder still, but the algorithm is the same.

How many consecutive prime numbers add up to exactly 1 million?
[Off-topic] Dblfstr:
47,53,59,61
[Off-topic] stephj:
Correct! Well done.

Because you know there are four numbers, they are to going be somewhere around the region of 220/4 = 55.

The next two problems do not contain that extra information. so you will need a few lines of code to find the next two answers.

1.) Churn out an array of integers holding just prime numbers.

2.) Search in that array for the solutions.
[Off-topic] Dblfstr:
I had begun work on the code yesterday, but had an infinite loop somewhere. (I am not the best coder - and I am working in excel) My PC froze and I lost my changes. We will see what I can come up with today. I have a nice little code to determine prime numbers, now I just need to determine a solution.
[Off-topic] 4silvertooth:
I am on it as soon as i get home.
[Off-topic] 4silvertooth:
Using http://code.google.com/p/primesieve/

+ My ugly brut force code.

#include <soe/PrimeSieve.h>
#include <iostream>

unsigned int sum = 0;

void sumPrimes(unsigned int prime) {
sum += prime;
}

int main() {
PrimeSieve ps;

int sum_to_find = 106620;

int p_start;
int p_end;
for(p_start = 2;p_start < sum_to_find;p_start++)
{
for(p_end = p_start+1;;p_end++)
{
sum = 0;
ps.generatePrimes(p_start, p_end, sumPrimes);
if(sum == sum_to_find)
{
std::cout << "Prime number after " << p_start << " to " << p_end << " Sum = " << sum << std::endl;
break;
}
if(sum > sum_to_find)
{
break;
}
}
}

return 0;
}

+ Some manual work too to find prime numbers between those range.

=

13297

13309

13313

13327

13331

13337

13339

13367

--------

106620

17747

17749

17761

17783

17789

17791

---------

106620

for 1 million my pc still computing.
[Off-topic] stephj:
So far so good!

The two answers to 106620 are correct. Well done.

If the program is a taking a week, check that you are not over-running 16 bit integers, you will need 32 bit 'long' integers to get it to work.

Later I will post plain 'C' code that will create and store all the prime numbers up to over a million in under a second.

Using this, the answer to the million question also runs in well under a second.
[Off-topic] 4silvertooth:
ok after some optimizing the code to increment all odd numbers i get,

4999 to 6491 = 1000000.. well with in INT range that means i found a different solution may be??
[Off-topic] Dblfstr:
Ok, I have a code that is working, but the way I have it set is taking forever. I have a list of prime sorted from largest to smallest.

I have i set to increment each value and is calculated as a sum each iteration adds the next prime number 2+3+5+etc.

The code checks that against 106620, if the sum is smaller, next i. If the sum gets larger, start subtracting j (j being the same as i only the sum is subtracted from the total) Total - 2, total - sum (2+3) etc.

My problem is that j resets every time . So I will get a sum larger than 106620, and so the sum of j will be subtracted from the total, if (when) this gets back below 106620, i kicks back in to start adding the next prime, again we grow larger than 106620, but j resets back at 2 (first prime I have) instead of picking up where it left off. :(

Sub check()
'
'
' check Macro

Dim LR As Long, i As Long
Dim RR As Long, j As Long
Dim now2 As Double
Dim iold2 As Double
Dim Now As Double
Dim iold As Double
Now = 0
iold = 0
now2 = 0
iold2 = 0

LR = Range("$A$65536").End(xlUp).Row
RR = Range("$A$65536").End(xlUp).Row

For i = LR To 2 Step -1

If Range("$c1:$c1") = 106220 Then
MsgBox "yep"
End

ElseIf Range("$c1:$c1") < 106220 Then
now2 = 0
iold2 = 0
Now = Cells(i, "a").Value
Range("e1:e1").Select
ActiveCell.Value = Now
Range("d1:d1").Select
ActiveCell.Value = iold + Now
iold = Range("d1:d1").Value

For j = RR To 2 Step -1

If Range("$c1:$c1") > 106220 Then

now2 = Cells(j, "a").Value
Range("e2:e2").Select
ActiveCell.Value = now2
Range("d2:d2").Select
ActiveCell.Value = iold2 + now2
Range("c2:c2").Select
ActiveCell.Value = Range("d2:d2")
iold2 = Range("d2:d2").Value
End If
Next j
End If
Next i
End Sub
[Off-topic] stephj:
To 4silvertooth:

That's the correct answer, the 174 prime numbers starting at 4999 through to 6491. There is only one solution and that's it.Well done.

While the numbers themselves will fit in a short int, the sum of a million will overrun it. The sum must be a long.

Some compilers, VS C++ for example, automatically promote/augment shorts to longs.

*********************************************

To dblstfr:

I'll have a look at the code and see if I can spot anything.

*********************************************

To anybody else who's the slightest bit interested:

This code generates both the primes and does the search in around 0.5 sec on 2.6Ghz Quad Core. The other three cores sit there doing nothing. To multi-thread it, the search section of the code would have to be rewritten as a separate function, and separate threads created to search different sections of the arrays. It is just not worth the effort for the saving involved.

It uses a trial division method, similar to the Sieve of Eratosthenes.

The trial number, (t), is tested for divisibility against all primes numbers up to its square root. If it still not divisible against these numbers, then the trial itself is prime. Add it and its square to the arrays.

The arrays are primed with the first two elements. They then become self populating as the program runs.

#include <stdio.h>
long int primes[80000];
long int squares[80000];

main()
{
long i=2,j,t=1,s;

primes[0]=2;
primes[1]=3;
squares[0]=4;
squares[1]=9;

// Generate primes up to 1020361

while(i<80000)
{
t+=2;
for(j=1;t>squares[j] && t%primes[j];j++);
if(t<squares[j])
{
primes[i]=t;
squares[i]=t*t;
i++;
}
}

// Search for a contiguous series of primes that add up to 1000000

for(i=0;i<80000;i++)
{
t=0;
j=i;

while(t<1000000)
{
t+=primes[j];
j++;
}

// Print the number of primes found, followed by their values
if(t==1000000)
{
printf("%ld\n",j-i);
for(s=i;s<j;s++)
printf("%ld\n",primes[s]);
}
}
return(0);
}

Here's the result:

174
4999
5003
5009
5011
5021
5023
5039
5051
5059
5077
5081
5087
5099
5101
5107
5113
5119
5147
5153
5167
5171
5179
5189
5197
5209
5227
5231
5233
5237
5261
5273
5279
5281
5297
5303
5309
5323
5333
5347
5351
5381
5387
5393
5399
5407
5413
5417
5419
5431
5437
5441
5443
5449
5471
5477
5479
5483
5501
5503
5507
5519
5521
5527
5531
5557
5563
5569
5573
5581
5591
5623
5639
5641
5647
5651
5653
5657
5659
5669
5683
5689
5693
5701
5711
5717
5737
5741
5743
5749
5779
5783
5791
5801
5807
5813
5821
5827
5839
5843
5849
5851
5857
5861
5867
5869
5879
5881
5897
5903
5923
5927
5939
5953
5981
5987
6007
6011
6029
6037
6043
6047
6053
6067
6073
6079
6089
6091
6101
6113
6121
6131
6133
6143
6151
6163
6173
6197
6199
6203
6211
6217
6221
6229
6247
6257
6263
6269
6271
6277
6287
6299
6301
6311
6317
6323
6329
6337
6343
6353
6359
6361
6367
6373
6379
6389
6397
6421
6427
6449
6451
6469
6473
6481
6491

Edit: As an afterthought: The number of array elements can almost be cut by half to around 41541/2 elements. The primes pass 500,000 at this point.

As the result is the sum of at least one prime, we can stop here, because the resulting sum will be greater than 1 million.
[Off-topic] stephj:
To Dblfstr:

This works, but it is a VBA port of the 'C' code above. We can use the Excel Sum function to do a lot of the graft.

Assuming you have the primes from 2 to 1020361 in cells A1 to A80000 try this:

Sub check()

Dim RangeStart As Long
Dim RangeEnd As Long
For RangeStart = 1 To 79999
RangeEnd = RangeStart + 1
While (WorksheetFunction.Sum(Range(Cells(RangeStart, "A"), Cells(RangeEnd, "A"))) < 1000000)
RangeEnd = RangeEnd + 1
Wend
If (WorksheetFunction.Sum(Range(Cells(RangeStart, "A"), Cells(RangeEnd, "A"))) = 1000000) Then
MsgBox ("Start:" & RangeStart & " End:" & RangeEnd)
End If
Next
End Sub

It pops up the message box shown below. Don't forget it is referring to the cell addresses not their values. 670 to 843 inclusive is 174 as above. A670 contains 4999 and A843 contains 6491 again as above.

The code continues running after the message box has been clicked until the macro finishes. To smarten it up we could force the macro to end after it is clicked.
[Off-topic] Dblfstr:
Like I said, I'm not great at coding :D
[Off-topic] 4silvertooth:
If you deep a tennis ball in super glue, maximum how many tennis balls can you stick to it?
[Off-topic] stamatis:
26?
[Off-topic] stephj:
I'll have a go at:-

12

Arranged as:

Six surrounding the central ball in the same plane 60 degrees apart. Three in the layer above, and three in the layer below.
[Off-topic] stamatis:
i dont get it why 3 at the layer above and 3 at the layer below....can you explain a little further....

my thought was:

we have to cover the ball...

so, we need the obvious 6 balls that will placed at 90 degrees from each

now we need to cover the corners and the spaces between the balls we placed before,so,for the spaces we will need 4 at the top,4 at the bottom and 4 at the center and for the corners we will need 4 at the top,4 at the bottom

summary=26

in sort words, there will be made a cube that will have dimensions 3x3x3 minus the 1 ball that we started with

3x3x3-1=

27-1=

26

if you dont understand my explaination sorry, my english are not that good,but i can tell it in another way....

do you have a rubik's cube? and if you havent i am sure you know how it is, now imagine the little cubes being balls and now imagine that there is a ball at the same size at the center....how many balls are surrounding the ball at the center?!

:confused::confused:

where am i wrong?
[Off-topic] stephj:
If you have a square packed lattice like a Rubic Cube, the central ball only comes into contact with six other balls, the one in the centre of each face.

The eight corner balls and the twelve centre edge balls do not actually touch the centre ball.

To visualise the 12 ball solution above, then, in the image below, remove the top ball, then repeat the layer with three balls in it, underneath the bottom layer.

All twelve of these balls touch the central ball.
[Off-topic] azzledazzle:
Take 9 from 6, 10 from 9, 50 from 40 and leave 6.

How Come ??

EDIT: You have to be left with 6 and only 6 !