![]() |
![]() |
#1 |
Oct 2011
10101001112 Posts |
![]()
You have 680 glasses and need to build a tower 15 levels high with 1 on top. Is there an equation that can be used to solve for glasses per level?
|
![]() |
![]() |
![]() |
#2 |
"Forget I exist"
Jul 2009
Dumbassville
100000110000002 Posts |
![]() |
![]() |
![]() |
![]() |
#3 |
Oct 2011
7×97 Posts |
![]() |
![]() |
![]() |
![]() |
#4 |
If I May
"Chris Halsall"
Sep 2002
Barbados
100100101110102 Posts |
![]() |
![]() |
![]() |
![]() |
#5 |
Oct 2011
7×97 Posts |
![]() |
![]() |
![]() |
![]() |
#6 |
Basketry That Evening!
"Bunslow the Bold"
Jun 2011
40<A<43 -89<O<-88
3·29·83 Posts |
![]()
Well the sum over the integers up to n := the nth triangular number would describe perfect triangles. So find the highest triangular number <= 680, then distribute the remainder evenly over each layer. In C:
Code:
int * pyramid(int x) { int i,j,diff; int sum=0; int * layer; printf("Input is %d\n", x); for( i=1; sum <= x; i++) sum += i; sum -= (--i); i--; // The loop goes one too far, so fix it layer = (int *)malloc(i*sizeof(int)); // Declares an array of size i for( j=0; j<i; j++) layer[j] = j+1; // The basic shape is a triangle diff = x - sum; if( diff > 0 ) { for( j=i-1; diff>0; diff-- /* Decrement diff until diff==0 */ ) { // Distribute the difference over each layer if( j<1 ) j = i - 1; // Keep cycling over the pyramid layer[j]++; // Add one to the current layer j--; // Move to the next higher layer } printf("There will be %d layers, as follows:\n", i); for( j=0; j<i; j++) printf("%d\n", layer[j]); printf("\n"); return layer; } else if( diff==0 ) {printf("A perfect triangle of glasses!\n\n"); return NULL;} else {printf("You need %d more debugging printfs!\n", x); return (int *)"YOU SUCK";} } Code:
What number of glasses should I use? 1 Input is 1 A perfect triangle of glasses! What number of glasses should I use? 2 Input is 2 There will be 1 layers, as follows: 2 What number of glasses should I use? 3 Input is 3 A perfect triangle of glasses! What number of glasses should I use? 4 Input is 4 There will be 2 layers, as follows: 1 3 What number of glasses should I use? 5 Input is 5 There will be 2 layers, as follows: 1 4 What number of glasses should I use? 6 Input is 6 A perfect triangle of glasses! What number of glasses should I use? 7 Input is 7 There will be 3 layers, as follows: 1 2 4 What number of glasses should I use? 8 Input is 8 There will be 3 layers, as follows: 1 3 4 What number of glasses should I use? 680 Input is 680 There will be 36 layers, as follows: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 24 25 26 27 28 29 30 31 32 33 34 35 36 37 ![]() EDIT: WHOOPS 15 per layer. There's a HUGE piece of missing information. Well, at least I had fun solving my own problem :/ (Another edit: This is a 2-D solution, as opposed to eh 3-D ones below :P:P:P) Last fiddled with by Dubslow on 2012-02-20 at 23:24 Reason: replaced code with working version |
![]() |
![]() |
![]() |
#7 |
If I May
"Chris Halsall"
Sep 2002
Barbados
2·3·1,567 Posts |
![]() |
![]() |
![]() |
![]() |
#8 | ||
"Forget I exist"
Jul 2009
Dumbassville
26×131 Posts |
![]() Quote:
Quote:
|
||
![]() |
![]() |
![]() |
#9 |
Oct 2011
7·97 Posts |
![]()
Actually, that may work...
1+3+6+10+15+21+28+36+45+55+66+78+91+105+120=680 yep, that works... I was thinking 15x15,14x14, etc but it went well over 1k. With the levels now known, without using trial and error, is there an actual equation that would solve this? Last fiddled with by bcp19 on 2012-02-20 at 23:02 |
![]() |
![]() |
![]() |
#10 | |
Apr 2010
22·37 Posts |
![]() Quote:
Numbering the levels beginning with 1 at the top, the glass count for level i is the triangular number T(i) = i*(i+1)/2. The total glass count V(n) for n levels is then And indeed V(15) = 680. Edit: OK, folks, you have been faster. Last fiddled with by ccorn on 2012-02-20 at 23:16 |
|
![]() |
![]() |
![]() |
#11 |
Mar 2006
Germany
2·1,433 Posts |
![]() |
![]() |
![]() |
![]() |
Thread Tools | |
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Some puzzle | Harrywill | Puzzles | 4 | 2017-05-03 05:10 |
Four 1's puzzle | Uncwilly | Puzzles | 75 | 2012-06-12 13:42 |
4 4s puzzle | henryzz | Puzzles | 4 | 2007-09-23 07:31 |
Dot puzzle | nibble4bits | Puzzles | 37 | 2006-02-27 09:35 |
now HERE'S a puzzle. | Orgasmic Troll | Puzzles | 6 | 2005-12-08 07:19 |