47

Can you change the word TRUMP to the name BIDEN in 10 steps or less by changing one letter at a time?

Each change must result in a valid word from MW dictionary.

No proper nouns, abbreviations or acronyms. No rearrangement or anagrams either.

Have fun.

I did it in 10 but there must be a faster solution??

DrD
  • 39,225
  • 7
  • 76
  • 323

5 Answers5

41

Based on ThatOneNerdyBoy's answer, here's a 9-step solution in which all words are contained within MW

TRUMP
TRAMP
TRAMS
TEAMS
TERMS
TERES
TIRES
TIDES
BIDES
BIDEN

Lukas Rotter
  • 10,321
  • 1
  • 49
  • 89
  • That looks better! – ThatOneNerdyBoy Oct 14 '20 at 18:35
  • @Lukas Rotter I am going to wait a couple of days before I accept your answer. Still hope for a 8 step answer!!! – DrD Oct 15 '20 at 11:43
  • 2
    @DrD 5 letters to full change, it takes too long to move into common words 8-step might actually be impossible especially because you have to move to the wrong vowel before getting to the right one (7 steps now) and 2 steps to reach vowel movement (9). – IT Alex Oct 15 '20 at 14:39
  • Point well taken @IT Alex. – DrD Oct 15 '20 at 14:48
  • 4
    Interesting. Did a small prog (using a dict of ~16000 5-letters words), and the best it can find is exactly your answer :-) – Déjà vu Oct 17 '20 at 14:37
  • It's interesting how the ladder itself seems to contain some subtle political commentary – Chris Sunami Oct 17 '20 at 16:32
  • 1
    @e2-e4: Same here. I even added french, german, spanish and italian word lists, but couldn't find anything better than 9 steps. – Eric Duminil Oct 18 '20 at 09:14
  • @EricDuminil try to add the word BIDEN ... ;-) – Déjà vu Oct 18 '20 at 09:20
  • @e2-e4: I had to, because it isn't present in any word list I had. – Eric Duminil Oct 18 '20 at 09:44
  • @e2-e4 oh, so you allowed letters to be removed and added? – Eric Duminil Oct 18 '20 at 10:13
  • @e2-e4 sorry, I still don't get it. What would the complete chain look like? It doesn't seem to make sense to repeat any word. – Eric Duminil Oct 18 '20 at 11:02
  • @EricDuminil (removed previous comments to avoid the 'chat' punishment) there would be incorrect words in between in 5 steps if BIDEN is auth., and we can only change 1 letter at once, so indeed adding it wouldn't hurt (then dep on algo, the tree search (in mine) is a bit faster by stopping at 4 common chars) – Déjà vu Oct 18 '20 at 11:13
  • @e2-e4: Once again, I don't get it. Getting into chat wouldn't bother me. 'BIDEN' must be in the graph, doesn't it? Do you have an example of the incorrect words? What would the chain look like, exactly? – Eric Duminil Oct 18 '20 at 12:20
18

Here it is in 10 steps, at least

TRUMP
TRAMP
TRAMS
TEAMS
BEAMS
BEATS
BENTS (noun - stalks of stiff coarse grass)
BINTS
BINES
BIDES
BIDEN

hexomino
  • 135,910
  • 10
  • 384
  • 563
14

Here is a possible 9 step:

TRUMP
TRAMP
TRAMS
TEAMS
TERMS
TERES - a shoulder blade muscle
BERES - bere: a type of cereal grass
BEDES - bede: a devout deity petition
BIDES
BIDEN

ThatOneNerdyBoy
  • 1,151
  • 1
  • 7
  • 19
11

If deletions and insertions are allowed, it is possible in 7 steps:

TRUMP RUMP RUM RIM RID RIDE BIDE BIDEN

Beefster
  • 303
  • 1
  • 3
  • 11
    But deletions and insertions aren't allowed. – bobble Oct 15 '20 at 19:33
  • 12
    @bobble I will leave that up to OP and mods. Some word ladders allow it and OP never specified. – Beefster Oct 15 '20 at 19:36
  • 11
    Hello @Beefster. Thanks for your answer. Honestly when I made up the puzzle I did not even think of removing/adding letters. To me "change one letter at a time" meant replacing it with another. If that did not come across here I apologize. This is something new I learned today. For my next word ladder puzzle I will keep it in mind. Thanks again. – DrD Oct 15 '20 at 20:18
  • 5
    Another 7 using this format TRUMP - RUMP - BUMP - BUM - BUD - BID - BIDE - BIDEN – corsiKa Oct 15 '20 at 23:52
4

I found a solution in only 8 intermediate steps:

0. trump
1. tramp
2. trams
3. teams
4. terms
5. teres
6. tires
7. tides
8. bides
Done: biden

It is possible that shorter paths still exists, because I couldn't obtain the complete MW dataset.


Methodology:

  1. First obtained a word list
    aspell -d en dump master | aspell -l en expand > words.en.txt
    
  2. Keep only words that are 5 letters long
    awk 'length($0)== 5' wordlist1.txt > wordlist2.txt
    
  3. Kepp only words without apostrophes (')
    awk '!/'\''/' wordlist2.txt > wordlist3.txt
    
  4. Remove words with capital letters (proper nouns)
    awk '!/[A-Z]/' wordlist3.txt > wordlist4.txt
    
  5. Add 'biden' and 'teres' as words
    printf "%s\n" biden teres >> wordlist4.tx
    
  6. Sort the file
    sort wordlist4.txt > words.sorted
    

After that a simple Breadth first search in ruby was enough to obtain the result, and finally the answer was confirmed to contain only words that exist in MW.


#!/usr/bin/env ruby
# frozen_string_literal: true

words = File.readlines('words.sorted', chomp: true)

def distance_is_1?(letters, otherword) diff = 0 val_letters = otherword.split('')

0.upto(4) do |i| diff += 1 if letters[i] != val_letters[i] return false if diff > 1 end diff == 1 end

def distance(letters, otherword) diff = 0 val_letters = otherword.split('')

0.upto(4) do |i| diff += 1 if letters[i] != val_letters[i] end diff end

def neighbors(word_list, word) letters = word.split ''

word_list.select do |w| dist = distance_is_1?(letters, w) dist end.map(&:downcase).uniq end

solutions = { ['trump'] => distance(%w[b i d e n], 'trump') }

iter = 0 counted_nodes = {}

loop do res = {} new_counted = {} solutions.each do |s, _v| neighbors(words, s.last).uniq.each do |n| if s.include?(n) || counted_nodes.include?(n) || distance(%w[b i d e n], n) > 12 - iter next end

  new_counted[n] = s + [n]
  res[s + [n]] = 1
end

end solutions = res counted_nodes = counted_nodes.merge new_counted iter += 1 break if iter > 12

p 'solutions', solutions, solutions.count if solutions.any? { |k, _v| k.last == 'biden' } p('FINAL ANSWER', solutions.select { |k, _v| k.last == 'biden' }) exit end end ```

user000001
  • 141
  • 2
  • 4
    This is the same as the 9-step accepted answer, but it is nice that you added your working. – Jaap Scherphuis Oct 18 '20 at 07:57
  • Thanks, it's almost the same because I didn't have the word beres in my list, I'm running it again with that word to see It there is anything shorter than that. – user000001 Oct 18 '20 at 08:04
  • @JaapScherphuis: Actually now that I see it again, it isn't the same because that answer contains lists not in the dictionary specified by OP. – user000001 Oct 18 '20 at 09:03
  • I think you're confusing this answer with this answer. The second one is the exact same as yours. And this is 9 steps, not 8. – Lukas Rotter Oct 18 '20 at 09:14
  • @LukasRotter: Oh right, I was wrong – user000001 Oct 18 '20 at 09:22
  • 1
    I didn't try your code and don't know how long it takes, but it looks like at least O(n²). If you're interested, you could try an algorithm like this one in order to find the neighbours: https://pastebin.com/8q7fm6A7

    You iterate once over every word, and you save them into a hash of arrays, each time replacing one letter by '-'.

    You can then iterate over the values of the hash, and select the ones with more than one element: every word inside this array has a distance of exactly 1 with all the other ones.

    – Eric Duminil Oct 18 '20 at 10:35
  • For example: {"-RUMP"=>["CRUMP", "ERUMP", "FRUMP", "GRUMP", "TRUMP"], "T-UMP"=>["THUMP", "TRUMP"], "TR-MP"=>["TRAMP", "TROMP", "TRUMP"], "TRU-P"=>["TRUMP"], "TRUM-"=>["TRUMP"]} – Eric Duminil Oct 18 '20 at 10:35