BrainDen.com - Brain Teasers

# Pickett

Members

623

8

## Posts posted by Pickett

1. ### No matter...whether Ascending or Descending order

hmmm @Pickett i guess i assumed that the containers were unmarked and only the total amount was known

Even unmarked containers can be poured out exactly half way if they are cylinders or rectangular prisms...so as long as you know the total volume (which we do), my steps still work.

2. ### No matter...whether Ascending or Descending order

Can we make the assumption that the beakers are either perfect cylinders or perfect rectangular prisms??

If we can assume that, then this can be done in 5 steps (might be better, I just haven't spent time looking) because of the fact that we can easily pour out enough liquid in any beaker to leave it EXACTLY half full (just start pouring, carefully, until the bottom corner of the beaker is level with the water):

A0, B0, C5, D5 -- Initial configuration

1. A0, B4, C1, D5 -- Pour C into B, filling B
2. A0, B2, C3, D5 -- Pour EXACTLY half of B back into C using the method above
3. A3, B2, C3, D2 -- Pour D into A, filling A
4. A1, B4, C3, D2 -- Pour A into B, filling B
5. A1, B2, C3, D4 -- Pour EXACTLY half of B into D using the method above.

** Note the wording that I used above about leaving half of the liquid in the beaker...not pouring half of the liquid out. This is because if we had 3 gallons in B, and used the method I described above, we would still be left with 2 gallons in B, and only poured 1 out.

3. ### Robots on an infinite number line.

Basically we need to come up with an algorithm that will allow one robot to eventually "overtake" the other robot after some point. Since we know one parachute is always going to be "left" of the other parachute on the number line, we can basically have the robots start moving left together. When the "right" robot gets to the left parachute, he needs to start moving left faster than the left robot. This set of instructions should accomplish this:

LRLS0L5

I have actually implemented this and tested it in Java. They always end up meeting up:

```public class DumbRobots {
private static int MAX_NUMBER = 10000000;

private static int robot1Pos = (int) (Math.random() * MAX_NUMBER);
private static int robot2Pos = (int) (Math.random() * MAX_NUMBER);
private static final int ROBOT_1_CHUTE_LOC = robot1Pos;
private static final int ROBOT_2_CHUTE_LOC = robot2Pos;
private static int robot1CurrInst = 0;
private static int robot2CurrInst = 0;

private static char[] instructions = {'L', 'R', 'L', 'S', '0', 'L', '5'};

public static void main(String[] args) {
System.out.println("Starting with robot1 at " + robot1Pos + " and robot2 at " + robot2Pos);
int numIterations = 0;
while (robot1Pos != robot2Pos) {
numIterations++;
runInstruction(true, instructions[robot1CurrInst]);
runInstruction(false, instructions[robot2CurrInst]);
}
System.out.println("ROBOTS FINALLY MET AT " + robot1Pos + " AFTER " + numIterations + " INSTRUCTIONS CALLED!!");
}

private static void runInstruction(boolean robot1, char inst) {
switch(inst) {
case 'L':
moveLeft(robot1);
break;
case 'R':
moveRight(robot1);
break;
case 'S':
skipIfAtParachute(robot1);
break;
default:
goToInstructionX(robot1, Integer.parseInt("" + inst));
break;
}
}

private static void moveLeft(boolean robot1) {
if (robot1) {
robot1Pos--;
robot1CurrInst++;
} else {
robot2Pos--;
robot2CurrInst++;
}
}

private static void moveRight(boolean robot1) {
if (robot1) {
robot1Pos++;
robot1CurrInst++;
} else {
robot2Pos++;
robot2CurrInst++;
}
}

private static void skipIfAtParachute(boolean robot1) {
if (robot1) {
if (robot1Pos == ROBOT_1_CHUTE_LOC || robot1Pos == ROBOT_2_CHUTE_LOC) {
robot1CurrInst += 2;
} else {
robot1CurrInst++;
}
} else {
if (robot2Pos == ROBOT_1_CHUTE_LOC || robot2Pos == ROBOT_2_CHUTE_LOC) {
robot2CurrInst += 2;
} else {
robot2CurrInst++;
}
}
}

private static void goToInstructionX(boolean robot1, int inst) {
if (robot1) {
robot1CurrInst = inst;
} else {
robot2CurrInst = inst;
}
}
}
```

EDIT: I also ran my code on Rainman's algorithm above...it appears to also always work. Nice job!

4. ### Trigonometry Formula to calculate positive integer n

Let f(n+1) = sec(arctan(f(n)))

and define that f(0) = 0

...that will work, however, that "definition" technically uses 2 zeros in defining the base case. I will try my best to get the meaning across:

We know that sec(arctan(x)) = sqrt(x2+1)...and that means sec(arctan(sqrt(x))) = sqrt(x+1)

With that, we can see this pattern form:

sec(arctan(0)) = sqrt(1)

sec(arctan(sqrt(1))) = sec(arctan(sec(arctan(0)))) = sqrt(2)

sec(arctan(sqrt(2))) = sec(arctan(sec(arctan(sec(arctan(0)))))) = sqrt(3)

sec(arctan(sqrt(3))) = sec(arctan(sec(arctan(sec(arctan(sec(arctan(0)))))))) = sqrt(4)

...etc...

From that, we can see that with enough iterations of "sec(arctan())" we will be able to produce all positive numbers (and all of their square roots, too!) using just secants, inverse tangents, and a single instance of 0:

1 = sec(arctan(0))

2 = sec(arctan(sec(arctan(sec(arctan(sec(arctan(0))))))))

3 = sec(arctan(sec(arctan(sec(arctan(sec(arctan(sec(arctan(sec(arctan(sec(arctan(sec(arctan(sec(arctan(0))))))))))))))))))

etc...

Maybe I'm just not thinking clearly right now...but I'm still trying to think of a good mathematical definition of that "function" that only uses one zero, however...

5. ### Not the Whole Story

You've probably heard these types of riddles: someone says a shortened version of a story that sounds odd, then the others guess about the details using only yes/no questions until they learn the whole story. Whoever guesses it correctly says the next short story. If you hear a well-known story that you know the answer to, please allow others who don't know it to guess.

Here's a starter:

The man was afraid to go home because the masked man was there.

it's a baseball game...guy rounding third towards home plate (where the catcher was waiting for him)...or some variation of that?

6. ### Agent's Code

TAIL that first agent who decided to FLEE...

Kenya

8. ### Guess the Riddle

A tree. Specifically a deciduous tree (one that loses it's leaves in the winter).

Reaching stiffly for the sky - A tree grows upwards

I bare my fingers when it's cold - Loses it's leaves and its branches are shown

In warmth I wear an emerald glove - Green leaves in summer.

and in between I dress in gold - Leaves change between summer and fall.

• 1
9. ### Find Me

Not even remotely close.

You know what those letters mean? Also the little arrows.

The letters were musical notes...and those notes correspond exactly to the beginning of the 3rd line of "This Land is Your Land" which is "From the red wood forest..."

Guess I don't know what the little arrows mean (again musically, I'd think "upstroke" on the guitar...but those notes don't match the song above...)

Oh well...it was worth a guess...

10. ### Find Me

Redwood national park in Northern California?

11. ### dice problem

you want to throw three 8 sided dice; such that: all three dice are numbered the same, and 120 different totals are possible; and the maximum number is as small as possible.

with 7 sided dice, the best possible is: 1, 2, 8, 51, 60, 79, 83

but your challenge is to go one more side.

but I'm only seeing 84 different totals possible with those 7 sides:
[3, 4, 5, 6, 10, 11, 12, 17, 18, 24, 53, 54, 55, 60, 61, 62, 63, 64, 67, 69, 70, 76, 81, 82, 83, 85, 86, 87, 88, 89, 92, 93, 95, 99, 103, 104, 110, 112, 113, 119, 121, 122, 128, 131, 132, 135, 136, 138, 140, 141, 142, 144, 145, 147, 151, 153, 159, 160, 162, 163, 164, 166, 167, 168, 170, 171, 174, 180, 181, 185, 190, 194, 199, 203, 209, 213, 217, 218, 222, 226, 237, 241, 245, 249]
However, using that same program, I validated that both superprismatic and Anza Power's solutions do indeed have 120 different totals combinations...I'm still working to see if I can get lower than Anza's, but so far, no luck...
12. ### Cloorsu

Disregard my vowel is ALWAYS yellow comment above...I overlooked some...but they are PREDOMINANTLY yellow...but that could just be coincidence...

13. ### Cloorsu

acdknqsuy

QUICKSAND
acloorv VOLCANO
aegjosuy JEALOUSY
agnosy SAXONY
bbceeir ICEBERG
beeegr GREECE
boorrs SORROW
ccdeiorwy COWARDICE
ceikmy belu beey MICKEY BLUE EYES
der anors RED SONJA
eht eegnr ehnorg THE GREEN HORNET
eht eeeggnorsu ceefft THE GREENHOUSE EFFECT
einy NIUE
llowyy abeimnrsu YELLOW SUBMARINE
rruy FURY

aabilmo SOMALIA
aagiknps PAKISTAN
aailrt LATVIA
abghiilnory LAMBORGHINI
achhinty aabcm HYACINTH MACAW
acintvy city VATICAN CITY
anost aimnrt adegir ASTON MARTIN RAPIDE
bdfr FORD
cdfghlnoy GOLDFINCH
ceinort CITROEN
cimorrs aellors CRIMSON ROSELLA
eegnr ceegkooprw GREEN WOODPECKER
egory ROGUE
ehllory HELLBOY
eht bcit THE TICK
eht ghku THE HULK

abmnssu SAMSUNG
aehny HYENA
aer gginsu AER LINGUS
aginoprsy aeiilnrs SINGAPORE AIRLINES
air ben aadelnz AIR NEW ZEALAND
bceeilrt belu ELECTRIC BLUE
bdegooy ellowy bcikr dory GOODBYE YELLOW BRICK ROAD
belu deginr bcopstu BLUE RINGED OCTOPUS
eegnr eegnr agrss fo egmo GREEN GREEN GRASS OF HOME
eelr air FEEL AIR
ehnw eht der der inorr cemos bbo bbo bbbino aglno WHEN THE RED RED ROBIN COMES BOB BOB BOBBIN ALONG
eorxx XEROX
nprsty SPRINT

aacegilmt MALACHITE
aansswy city SWANSEA CITY
abceehl CHELSEA
abcekop aoptz PEACOCK TOPAZ
ablnoo LAGOON
agnos aillv ASTON VILLA
agoy YODA
begrrv GROVER
bennsu deehnowy BUNSEN HONEYDEW
bruy RUBY
deny DUNE
eggjnu JUNGLE
egrsty eey TIGERS EYE
eillooprr LIVERPOOL

Going off of fabpig's findings of groupings of 4 and some of his categories...each category has one object of each color...

COUNTRIES/PROVINCES (flag colors): switzerland (red), saxony (green), greece (blue), niue (yellow), somalia (blue), pakistan (green), latvia (red), vatican city (yellow)...there's probably some way to divide these into two groups of four...I'm assuming because of where they were in the puzzle and the colors, it would be:

switzerland, saxony, greece, niue

somalia, pakistan, latvia, vatican city

EMOTIONS: jealousy (green), sorrow (blue), cowardice (yellow), fury (red)

MOVIES: Mickey Blue Eyes, Red Sonja, The Green Hornet, Yellow Submarine

NATURAL "DISASTERS": quicksand (yellow), volcano (red), iceberg (blue), the greenhouse effect (green)

SUPERHEROS: hellboy (red), rogue (yellow), the tick (blue), the hulk (green)

CARS (logo colors?): lamborghini (yellow), citroen (red), ford (blue), aston martin rapide (green?)

BIRDS: crimson rosella (red), green woodpecker (green), hyacinth macaw (blue), goldfinch (yellow)

SONGS: electric blue, goodbye yellow brick road, green green..., when the red...

AIRLINES: aer lingus (green), air new zealand (blue), feel air (red), singapore airlines (yellow)

TECH COMPANIES: xerox (red), andoid (green), samsung (blue), sprint (yellow)

ANIMALS: red panda (red), grasshopper (green), blue ringed octopus (blue), hyena (yellow)

MUPPETS CHARACTERS: abby cadabby (red), yoda (green), grover (blue), bunsen honeydew (yellow)

NATURAL FORMATIONS?: fissure (red), jungle (green), lagoon (blue), dune (yellow)

GEMS/STONES: malachite (green), tigers eye (yellow), peacock topaz (blue), ruby (red)

SOCCER TEAMS: liverpool (red), aston villa (green), chelsea (blue), swansea city (yellow)

The colors that the words represent are the letters that were replaced in the word itself. Now if we look at the letters that were replaced in the word, we get a bunch of 4 letter words that describe the categories:

COUNTRIES/PROVINCES (flag colors): ??? the letters are rxcuvtsa...which I can get CRUX and VAST...which I guess make some sense...all the flags that spell CRUX have some form of cross on them in some form...and countries are VAST?

EMOTIONS: FLAW (all the ones listed are negative)

MOVIES: JEST (all the ones listed are comedies)

NATURAL "DISASTERS": NIGH?

SUPERHEROS: BULK

CARS: ROMP?

BIRDS: WIND

SONGS: BACH

AIRLINES: FLEW

TECH COMPANIES: GRID? GIRD?

ANIMALS: PONY

MUPPETS CHARACTERS: BODY

NATURAL FORMATIONS?: GULF

GEMS/STONES: RICH

SOCCER TEAMS: VEST

So, now we have 16 4-letter words...from the way we found the words, we know each word has one letter associated with each color (e.g. FLEW: f=red, l=green, e=yellow, w=blue).

I find it very coincidental that each word has exactly one vowel in it...and the vowel is ALWAYS "yellow"

14. ### Cloorsu

And what we have so far with replaced letters. 3 English Premier League soccer teams are there. Not sure if eht eegnr ehnorq is a typo and should be The Green Hornet

Dam! just realised letter replaced in red sonia is I not A. I'll check for others...

So that one is the green hornet...and gives me 4 more because of that...

eht eegnr ehnorg --> THE GREEN HORNET (replace g with t)

ehllory --> HELLBOY (replace r with b)
eht bcit --> THE TICK (replace b with k)
eht ghku --> THE HULK (replace g with i)
egory --> ROGUE (replace y with u)
So we've got super heroes...

15. ### Averages Part II

if you have outliers in your data, and you want to keep the data whole (not removing any of it to influence your results), then I typically go with either the MEDIAN or MODE for my "average"...

So, in the case of this data, we obviously have an outlier...

MEAN with whole data: 47.714285

MEAN excluding outlier: 39.846153

MEDIAN: 40

MODE: 35

As a result, I would simply go with the median as our "average" for this data set...since it keeps the data whole (I kept all data points), but still gives the most accurate representation of the mean without outliers influencing it too much.

The MODE is also pretty good when the majority of your data points are a single number. In this case, 6/14 are "35"...so, IMHO, that's right on the border of wanting to use that number as your "average".

16. ### Averages Part II

you simply are talking "arithmetic mean"?

So, I'll take the first obvious answer!

35+48+35+40+50+35+35+40+150+35+40+35+45+45=668
668/14 = 47.714285...

I assume you are expecting us to consider the fact that the 150 is obviously an outlier of some sort and we should take that into account...but without throwing out any of the elements...

17. ### Cloorsu

Nice start fabpig...

I do think that every line has one letter that needs replaced. I'm guessing there is also some grouping to be made based on what the clue is. There are a couple of observations we can make based on the anagrams I have found (and the ones that fabpig has found):
• Each line has one letter that needs replaced...
• The only colors I have seen that are present in the clues are GREEN (eegnr), RED (der), BLUE (belu), and YELLOW (ellowy)
• The only letters that get replaced are "g", "r", "b", "y"...which corresponds with the GREEN RED BLUE YELLOW theme

So with that, here are the anagrams I have found so far:

acdknqsuy --> QUICKSAND (y --> i)
acloorv --> VOLCANO (r --> n)
adeilnrstwz --> SWITZERLAND (r --> r...only letter that can be substituted...)
aegjosuy --> JEALOUSY (g --> l)
ccdeiorwy --> COWARDICE (y --> a)
ceikmy belu beey --> MICKEY BLUE EYES (b --> s)
der anors --> RED ??????
eht eegnr ehnorg --> THE GREEN ?????
eht eeeggnorsu ceefft --> THE GREENHOUSE EFFECT (g --> h)
llowyy abeimnrsu --> YELLOW SUBMARINE (y -> e)
rruy --> RUBY or FURY???
aabilmo --> SOMALIA (b --> s)
aagiknps --> PAKISTAN (g --> t)
aailrt --> LATVIA (r --> v)
abghiilnory --> LAMBORGHINI (y --> m)
acintvy city --> VATICAN CITY (y --> a)
anost aimnrt adegir --> ASTON MARTIN RAPIDE (g --> p)
bdfr --> FORD (b --> o)
ceinort --> CITROEN (r --> r...again, no other letters can be substituted...)
eegnr ceegkooprw --> GREEN WOODPECKER (g --> d)
aegghoprrss --> GRASSHOPPER (g --> p)
aehny --> HYENA (y --> y...again, no other letters...)
bceeilrt belu --> ELECTRIC BLUE (b --> c)
bdegooy ellowy bcikr dory --> GOODBYE YELLOW BRICK ROAD (y --> a)
belu deginr bcopstu --> BLUE ????
der aadpr --> RED PANDA (r --> n)
eegnr eegnr agrss fo egmo --> GREEN GREEN GRASS OF HOME (g --> h)
ehnw eht der der inorr cemos bbo bbo bbbino aglno --> WHEN THE RED RED ROBIN COMES BOB BOB BOBBIN' ALONG (r -> b)
eorxx --> XEROX (r --> r...only letter...)
abcekop aoptz --> PEACOCK TOPAZ (b --> c)
agoy --> YOGA or YODA??
bruy --> RUBY (r --> r...no others)
eggjnu --> JUNGLE (g --> l)
egrsty eey --> TIGERS EYE (y --> i)

So, I'm seeing some logical groupings as well:

GEMS: Tiger's eye, ruby, peacock topaz...

PERSONALITY TRAITS/EMOTIONS: cowardice, jealousy, fury?...

COUNTRIES: somalia, pakistan, latvia, vatican city, switzerland...

CARS: ford, citroen, lamborghini, aston martin rapide...

ANIMALS: green woodpecker, grasshopper, hyena, red panda...

SONGS: electric blue, goodbye yellow brick road, green green grass of home, when the red red robin comes bob bob bobbin' along, yellow submarine (could be movie instead...)

MOVIES: mickey blue eyes, yellow submarine (could be song)...

NATURAL DISASTERS?: quicksand, volcano, greenhouse effect...

Not sure what XEROX and JUNGLE are categorized as yet...but there are a lot I'm still missing, so it could be anything...My guess is once we find them all and categorize them, then the replacement letters will come into play (whcih is why I'm keeping track of which ones get replaced)

18. ### Cloorsu

Not much, and might not be anything...

but the title is an anagram for "COLOURS"...and you can definitely see some of the words in the lists are anagrams (I see ruby, green, red, the word "the" is a there a lot)...but there are definitely some "words" in those lists that I can't think of any anagrams for...so...must be something there...
19. ### Find Me

with the city, but was thinking more Flinders Street Station area. If that's the case then the Rendezvous Grand or the Citigate Melbourne hotels might be favourite.

Yeah, you're probably closer...more trams and people there...

20. ### Find Me

Well, I'm going to say you're in Melbourne Australia...and probably on Main Street...so the hotels near train stations that I can find are:

The Bridge Hotel -1 Nepean Hwy.

Royal Oak Hotel - 1375 Nepean Hwy.

Tudor Inn - 1281 Nepean Hwy.

Quest Cheltenham - 37-39 Station Rd.

Best Western Buckingham International - 1130 Nepean Hwy.

I'll guess either the Tudor Inn or Quest Cheltenham as my first guesses...

21. ### Rime Royal

Alright, I've said it before, but I'm saying it again...this is getting ridiculous. So I took the words in bold and removed the letters from the clues...that didn't really pan out. So I tried writing them out in the order that they appear in the words. For example, the first word "HUSBAND" contains the letters of "SUN"...so writing them out in the order they appear becomes "_ U S _ _ N _"
Doesn't seem like much, until you do that with ALL of the words:
His gasses go to a sun by Clarke
HUSBAND _ U S _ _ N _
SLEIGHT S _ _ I _ H _
COWBOYS _ _ _ B _ Y _
AUCTION _ _ _ T _ O _
SCOURGE _ _ O _ _ G _
SLACKER _ L A C K E R
ETERNAL _ _ _ _ _ A _
That is the symbol for JUPITER (Clarke...gasses...)
I never did steal a gem tip sceptre
ONWARDS _ _ _ A _ _ _
BUDDIES _ _ D D I _ _
FERVENT _ E R V E N _
RESPECT R E S P E C T
CASTLED _ A S T L E _
FIGMENT _ _ G M E _ _
AGAINST _ _ _ I _ _ _
That would definitely be a DIAMOND (steal a gem...)
Ride faster my son to rest an eon
CYMBALS _ Y M _ _ _ _
INCLOSE _ N _ _ O S _
PREDICT _ R E D I _ _
POVERTY _ O _ _ _ T _
FATHERS F A T _ E R S
SARGENT S _ R _ E _ T
HARMONY _ A _ _ _ N _
That's a BICYCLE (ride faster...)
Eric the evil elf is east of Eden
GRECIAN _ R E C I _ _
DESCENT D E _ _ E N _
SILENCE S I _ _ _ _ _
ATHEISM _ T H E _ _ _
FORGERY F O _ _ _ _ _
SALUTED S A _ _ T E _
DELVING _ E L V I _ _
EPSILON (Eric Evil Elf East Eden...)
It drops as my vision relief goes bye
FAIREST _ A _ _ _ S _
GROVELS G _ O _ E _ S
MORALLY M _ _ _ _ _ Y
INSPECT I _ _ _ _ _ T
FERTILE F E R _ I L E
PARDONS P _ R D O _ S
VIOLINS V I O _ I N S
GLASSES?? (vision relief...)
(We) do go in it to go on
DRAGONS _ _ _ G O _ _
AUTOPSY _ _ T O _ _ _
BEWITCH _ E W _ _ _ _
MONSTER _ O N _ _ _ _
STIFLES _ T I _ _ _ _
PROGENY _ _ O G _ _ _
MEADOWS _ _ _ D O _ _
BRACKET (thank you Google for telling me the 7-letter synonym of parenthesis)...matches the "(We)"
Rake in one more man to alter luck
DEMONIC _ E _ O N _ _
PISTONS _ i _ _ _ N _
MOBSTER _ O _ _ T _ _
QUICKLY _ U _ C K L _
RELIANT R E L _ A _ T
IRKSOME _ R _ _ O M E
CAVEMEN _ A _ _ M _ N
??? No clue what that is supposed to be
So that gives me 5 6 of the 7 words represented by the 7 words represented by the 7 stanzas...Which, if you look at the remaining 7 words from the titles (GASSES TIP EON ELF BYE IN RAKE) you can see that they will probably do the same thing again (Glasses --> Gasses):
JUPITER _ _ P I T _ _
DIAMOND _ I _ _ _ N _
BICYCLE B _ _ Y _ _ E
EPSILON E _ _ _ _ O N
GLASSES G _ A S S E S
BRACKET _ R A _ K E _
???? ? ? ? ? ? ? ? (uses letters ELF in it)
And because the rest of it is symmetric, I'm guessing that last line is "_ _ E L F _ _" (not necessarily in that order...but in those positions)...
So the final picture is of a yin-yang...which happens to be 7 letters. I'm going to say that's the answer.
22. ### Rime Royal

So, based on that, I'm assuming my initial thought that the fact that I found all of the bold words (with the exception of one) in the 7 answers in each stanza is on the right track...just not sure what to DO with those...
I'll work on it now that I know that's the right path to go down...
23. ### Alphabetize my Dvd's

So I agree that in certain sorting algorithms, defining a "step" would be difficult...however, I think with regards to this problem from a practical standpoint, I don't think it's very difficult. A "move" or "step" is simply when you physically grab a DVD and place it in a new position on the shelf...doesn't matter how you do it. In my opinion, if you were to "swap" two DVDs on the shelf (move first to last and last to first)...to me, that is TWO moves, not one. If you decided to do a merge sort on a shelf of DVDs, I would say you are doing a TON of extra moves...while it may be more efficient in computational time, to truly do it in practice, you would be moving DVDs all over the place on the shelf before finally getting them in order (unless you're a savant that can do layers and layers of recursion in your head and just do the final moves at the very end, in which case, my hat goes off to you...).

Now with your scenario above, what you said makes complete sense...which is where I think the clarification of the OP is required...because I ran into that same scenario...however, in your SECOND solution, you did not place a DVD in it's "correct spot" on the shelf...which goes against how I interpreted the OP (when you move G to before H...that is not the "correct" place on the shelf for G...). So by reading the OP as saying "I take a single DVD off the shelf and put it in its correct place, aka index, on the shelf...and repeat this until they are sorted either ascending or descending" (which is how I took it), you definitely have an algorithm with well defined "moves". It becomes very similar to a basic selection sort (although not exactly)...An example that is similar to what you have above, which still shows the difficulty of writing the algorithm to be "smart" is the following arrangement EBCAD:

OPTIMAL:

AEBCD (take "A" and move to index 0...yes, I'm 0-based)

ABCDE (take "E" and move to index 4)

2 moves total, and followed the OP as I read it...but this required some intuition/looking ahead to realize it could be done like that...where as a typical "sorting algorithm" has to go methodically through it like the following:

SELECTION SORT:

AEBCD (take "A" and move it to index 0)

ABECD (take "B" and move it to index 1)

ABCED (take "C" and move it to index 2)

ABCDE (take "D" and move it to index 3)

4 moves...

To me, it's these constraints that make this puzzle very interesting and fun to think through programmatically. So I definitely agree that my answers that I posted before are not completely correct...I have a few things I still need to work out in the algorithm...It's starting to look like I'll need some heuristics in order to find optimal paths...of course it's very possible that I am WAY overthinking this whole thing and I'm just using it as an excuse to do something else while I'm at work ...except I'm still coding, which is what I do all day at work anyways ...

24. ### Alphabetize my Dvd's

Ok, so I think I mis-interpreted the OP...it states:

To arrange my DVDs with precision I will take one DVD off the shelf and place it in the correct spot back on the shelf.

If that's the case, let's look at the example of 2, 4, 1, 3:

Start with 1...move it to its correct spot (and shift as needed): 1, 2, 4, 3...then try 2...it's already there...then 3, and move it...1, 2, 3, 4...you're done.

However, you can also do this by moving the 2 between 1 and 3 initially:

2, 4, 1, 3 --> 4, 1, 2, 3 --> 1, 2, 3, 4...

Which of the above is what you would expect from your OP? Either way, my numbers are not correct, and I need to change them...I will probably do that tomorrow and post my results.

25. ### Alphabetize my Dvd's

I may have a small error in my code, I need to double check the results above...

×

• #### Activity

• Riddles
×
• Create New...