Find words in a long word

dCode

Search for a tool

Longest Word Solver

Tool/Solver to search for the longest word made out of some letters. Longest word is a game letter whose purpose is to find the longest word possible using some given letters, a concept close to anagramming.

Results

Longest Word Solver

Tag(s) : Word Games

Share

Share

dCode and more

dCode is free and its tools are a valuable help in games, maths, geocaching, puzzles and problems to solve every day!
A suggestion ? a feedback ? a bug ? an idea ? Write to dCode!

  1. Games and Solvers
  2. Word Games
  3. Longest Word Solver

Make the Longest Word with these Letters

Play/Generate random letters

Answers to Questions (FAQ)

What is the longest word game? (Definition)

The longest word is a part of the Countdown TV program, whose purpose is to find the longest word by using only some selected letters (e.g. to rearrange letters in order to make a word from letters).

There are many letter games whose purpose is to make a word from letters (Scrabble, Wordox, Words with Friends, etc.). Most are similar to the longest word game, for example if the goal is to use all letters, it is an anagram.

In the original rules, a word list (dictionary reference) tells which word is an accepted solution or not (no proper noun). The program here is not limited and allows all kind of words, including conjugated verbs and sometimes some proper nouns.

What are the variants of the longest word game?

In its original version, the player has to try to make an anagram of the letters, or remove some of them to get the longest/biggest word possible.

Example: ABCDEFGHIJ gives JIGHEAD (7 letters)

There are variants where letters can be used multiple times (repeating letters).

Example: ABCDEFGHIJ giving CHIFFCHAFF (10 letters)

It is also possible to search a word without scrambling the letters

Example: ABCDEFGHIJ allows A_C____HI_ (ACHI) (4 letters)

Finally, it is possible to mix the two options

Example: ABCDEFGHIJ gives BEEF (4 letters)

See also dCode solvers: Scrabble, Boggle, Words containing… etc.

When was the TV Show ‘Countdown’ invented?

In 1965, in a French TV Show by Armand Jammot, completed in 1972 by countdown numbers rounds.

How to perform a random letters selection for the longest word game?

What is the longest word in english?

The longest word varies according to the dictionary used:

pneumonoultramicroscopicsilicovolcanoconiosis, but technical

hippopotomonstrosesquipedaliophobia, a word that has been created to describe the fear of long words.

antidisestablishmentarianism, found in all major dictionaries

Source code

dCode retains ownership of the «Longest Word Solver» source code. Except explicit open source licence (indicated Creative Commons / free), the «Longest Word Solver» algorithm, the applet or snippet (converter, solver, encryption / decryption, encoding / decoding, ciphering / deciphering, translator), or the «Longest Word Solver» functions (calculate, convert, solve, decrypt / encrypt, decipher / cipher, decode / encode, translate) written in any informatic language (Python, Java, PHP, C#, Javascript, Matlab, etc.) and all data download, script, or API access for «Longest Word Solver» are not public, same for offline use on PC, mobile, tablet, iPhone or Android app!
Reminder : dCode is free to use.

Cite dCode

The copy-paste of the page «Longest Word Solver» or any of its results, is allowed as long as you cite dCode!
Exporting results as a .csv or .txt file is free by clicking on the export icon
Cite as source (bibliography):
Longest Word Solver on dCode.fr [online website], retrieved on 2023-04-14, https://www.dcode.fr/longest-word-solver

French (Français)

Summary

https://www.dcode.fr/longest-word-solver

© 2023 dCode — The ultimate ‘toolkit’ to solve every games / riddles / geocaching / CTF.

 

I’m preparing for an exam but I’m having difficulties with one past-paper question. Given a string containing a sentence, I want to find the longest word in that sentence and return that word and its length. Edit: I only needed to return the length but I appreciate your answers for the original question! It helps me learn more. Thank you.

For example: string = «Hello I like cookies». My program should then return «Cookies» and the length 7.

Now the thing is that I am not allowed to use any function from the class String for a full score, and for a full score I can only go through the string once. I am not allowed to use string.split() (otherwise there wouldn’t be any problem) and the solution shouldn’t have too many for and while statements. The strings contains only letters and blanks and words are separated by one single blank.

Any suggestions? I’m lost i.e. I don’t have any code.

Thanks.

EDIT: I’m sorry, I misread the exam question. You only have to return the length of the longest word it seems, not the length + the word.

EDIT2: Okay, with your help I think I’m onto something…

def longestword(x):
      alist = []
      length = 0
      for letter in x:
             if letter != " ":
                     length += 1
             else:
                     alist.append(length)
                     length = 0
      return alist

But it returns [5, 1, 4] for «Hello I like cookies» so it misses «cookies». Why? EDIT: Ok, I got it. It’s because there’s no more » » after the last letter in the sentence and therefore it doesn’t append the length. I fixed it so now it returns [5, 1, 4, 7] and then I just take the maximum value.

I suppose using lists but not .split() is okay? It just said that functions from «String» weren’t allowed or are lists part of strings?

List of Long Words and their Meanings

For the long time, lexicographers have been debating about the legitimacy of certain words as possible entrants to the English dictionary. For me, the longer the word and the more the number of syllables in it, the more interesting it becomes. Find out some of the most exquisitely coined words in the English language from this article.

Longest word

Methionylthreonylthreonylglutaminylarginyl […] isoleucine
Here’s the deal: the world’s longest English word has exactly 189,819 letters in it and it takes 3 hours and 33 minutes to pronounce it completely!

Wondering what commands such an enormous (literally) honor? Well, it is the chemical name of the world’s largest known protein called titin or connectin. It is made up of 244 individually folded protein domains which in turn are connected by unstructured peptide sequences (largest known polypeptide containing 34,350 amino acids in the human body). Fascinating as the name of this wonder is, there exists some debate as to whether this technical term can actually be considered a word. But even then, mesmerizing it is, isn’t it? And guess what? Here in this article, you will actually get to see this ginormous word if you read on.

But even otherwise, the English language is a huge storehouse of long words that I find rather satisfying to pronounce. They are grand tongue twisters that make perfect sense. Two of my favorite words for the longest time have been inconsequential and quintessentially. I am psychologically satiated to the hilt every time I utter them and utter them a lot I do. But there are other words that are very rarely used and even more rarely heard of. Let’s check some of them out below. If you love the language and lap up trivia like there’s no tomorrow, this is a train ride you should definitely not miss.

A

A

1. Ablutophobia: Fear of washing or having a bath
2. Absorbefacient: Inducing or boosting absorption
3. Adiathermancy: Impervious to radiant heat or infrared radiation or unaffected by heat waves
4. Agglutination: The construction of words from component morphemes that retain their form and meaning in spite of the blending
5. Arachibutyrophobia: One having fear about peanut butter sticking to the mouth roof
6. Aurantiaceous: Appertaining to oranges or orange trees
7. Automatonophobia: One having fear about dummies, animatronic creatures, statues of wax
8. Autothaumaturgist: A person who exudes an air of mystery around himself consciously; someone pretending to be an enigma
9. Autotonsorialist: A person who cuts his own hair
10. Automysophobia: Fear of getting dirty

B

Funky Caterpillars

1. Ballistocardiograph: An instrument which is used to detect body movements caused by heartbeats
2. Bathythermograph: An instrument that is used for recording water temperature as compared to depth
3. Batrachomyomachy: A military engagement between frogs and mice
4. Batrachophagous: A person who eats frogs
5. Bicrescentic: Having the structure of a double crescent
6. Blandiloquence: A flattery or complimentary speech
7. Brachydactylous: Having abnormally short and blunt fingers and toes
8. Brobdingnagian: Colossal
9. Bouleversement: An overturning; ruination
10. Boustrophedon: An ancient method of writing in which one line is written from left to right and the next from right to left and so on.

C

Funky Caterpillars

1. Cacodemomania: Pathological belief of one being inhabited by an evil spirit
2. Caesaropapism: Secular ruler having control of the church
3. Catapedamania: Obsession with jumping from high places
4. Cephalonomancy: A kind of divination formerly practiced to detect guilt in a convict by boiling the skull of an ass and checking for any cracking of the skull or movement of the lower jaw
5. Ceruminiferous: Carrying or yielding earwax
6. Chaetophorous: Setigerous or bristle-bearing
7. Cheiloproclitic: One who is attracted to lips
8. Cholangiocholecystocholedochectomy: Process of surgically removing the hepatic duct and gallbladder
9. Chronosynchronicity: Presenting a person’s life in all the stages through a single piece of art
10. Cycloganoidei: Ganoid fish with cycloid scales

D

Funky Caterpillars

1. Dactylopterous: A state where the inferior rays of the pectoral fins are entirely or partially detached from the body
2. Defecaloesiophobia: Fear of painful defecation
3. Dendrochronology: Study of tree rings
4. Deorsumversion: Turning downwards
5. Dermatoglyphics: Study of fingerprints and skin patterns
6. Dermatopathophobia: Fear of dermal ailments
7. Didaskaleinophobia: Fear of going to school
8. Dishabiliophobia: Fear of undressing in front of another person
9. Dolichocephalic: Long-headed
10. Dysmorphophobia: Having the fear of physical deformities

E

E

1. Ecclesiasticus: An Apocryphal book
2. Edriophthalmous: Concerning the Edriophthalma
3. Electroencephalograph: An instrument for measuring the brain’s electrical impulses
4. Electrodynamometer: An instrument for measuring electric current
5. Eleutherophobia: Fear of freedom
6. Epiphenomenalism: Doctrine that mental processes are epiphenomena of brain activity
7. Ephemeromorph: Form of life that is neither animal nor plant
8. Epistaxiophobia: Fear of epistaxises or bleeding noses
9. Ethnomethodology: The study of sociological codes and conventions that underlie everyday social communication and interactions
10. Extemporaneousness: Lack of foresight

F

F

1. Febrifacient: That which renders feverish
2. Ferriprussiate: A ferricyanate; a ferricyanide
3. Flagelliferous: Bearing a whip or flagellum
4. Flibbertigibbet: Gossipy person, usually referring to a young woman
5. Fibriophobia: Having fear of fever
6. Fibrochondrosteal: Partly fibrous, partly cartilaginous, and partly bony or osseous
7. Fissigemmation: A process of reproduction that intercedes fission and gemmation
8. Forisfamiliation: The act of liberating oneself from parental authority
9. Frankalmoigne: Tenure by free alms
10. Frumentaceous: Resembling wheat or other grain

G

Bookworm

1. Galactodensimeter: Instrument used to measure the density of milk
2. Gastroduodenitis: Swelling of the stomach and duodenum
3. Gastrohysterotomy: Cæsarean section
4. Generalissimo: The Chief Commander of an army
5. Gephydrophobia: Fear of crossing bridges
6. Germanophilia: Love or fondness for Germany or for the Germans
7. Gluconeogenesis: Production of glucose from non-carbohydrates
8. Graminivorous: Feeding on grass or cereals
9. Grammaticaster: A piddling grammarian
10. Gynotikolobomassophile: One nibbling a woman’s earlobes

H

H

1. Haematogenesis: Production of blood
2. Haematodynamometer: An instrument to measure arterial or venous blood pressure
3. Haussmannize: To rebuild
4. Hellenologophobia: Fear of Greek terms or complex scientific nomenclature
5. Helioseismology: Study of wave oscillations in the sun
6. Hexakosioihexekontahexaphobia: Fear of the number six hundred sixty-six
7. Honorificabilitudinitatibus: One bearing honorableness
8. Honorificabilitudinity: Honorableness
9. Hydrometeorology: Study of atmospheric moisture
10. Hypercatalectic: Having an extra syllable at the end of a verse

I

I

1. Iatromathematics: Archaic practice of medicine in conjunction with astrology
2. Ichthyophagous: Fish-eating
3. Ichthyophthalmite: A hydrous silicate of calcium and potassium relating to zeolites
4. Immarcescible: Not perishable
5. Immunopathology: Study of immunity to disease
6. Incircumscriptible: Incapable of being restricted
7. Incomprehensibleness: Impossible to know or fathom
8. Interramification: Intertwining of branches
9. Interstratification: Alternative layering of two or more types of clay minerals
10. Ithyphallophobia: Fear of aroused male genitalia

J

J

1. Jaculiferous: Bearing arrow-like thorns
2. Japanophilia: Love or admiration for Japan or the Japanese
3. Japanophobia: Fear of Japanese
4. Johannisberger: A fine white wine produced on the estate of Schloss Johannisberg, on the river Rhine
5. Jouissance: Merriment
6. Judeophobia: Fear of Jewish people
7. Juglandaceous: Liking or pertaining to walnuts
8. Jungermanniaceae: A genus of hepatic mosses
9. Jurisprudential: Pertaining to the science of juridical law
10. Juxtaposition: The act of positioning two or more things adjacent to each other

K

K

1. Kakorrhaphiophobia: Fear of failure
2. Katagelophobia: Fear of ridicule
3. Katathermometer: Instrument used to measure the cooling power of air
4. Katsaridaphobia: Fear of cockroaches
5. Kephalonomancy: Divination using a baked head of an ass or a goat
6. Keraunophobia (or Ceraunophobia): Fear of lightning and thunder
7. Kinetheodolite: Type of theodolite used to track missiles and satellites
8. Knickerbockers: Loose breeches ending above the knee
9. Knickknackatory: A collection of baubles and trifles
10. Kosmikophobia: Fear of cosmic phenomenon

L

L

1. Lamellibranchiata: Class of gastropods with bivalve shells
2. Laryngotracheotomy: Surgery involving cutting into the larynx and the upper part of the trachea
3. Latitudinarianism: Doctrine of broad liberality in religious belief or conduct
4. Lautenclavicymbel: Lute harpsichord with gut strings instead of metal
5. Lautverschiebung: The regular alterations undergone by the primitive Indo-European stops or mute consonants in the Teutonic languages since third century BC
6. Lepidopterology: Study about butterflies and moths
7. Leucocytogenesis: Formation of leukocytes
8. Lexicographical: Pertaining to the art of making a dictionary or lexicon
9. Libanophorous: Producing incense
10. Logizomechanophobia: Fear of computers

M

M

1. Machiavellianism: The doctrines of Niccolò Machiavelli as written in his book Il Principe (“The Prince”) wherein political expediency is exalted above morality and the use of cunning and deceit in statecraft to maintain authority or to effectuate policy is commended
2. Macrocephalous: Having a large head
3. Margaritomancy: Divination using pearls
4. Maschalephidrosis: Excessive sweating of the armpits
5. Mechanotherapist: A practitioner who medically treats by employing mechanical practices, such as massaging
6. Medomalacuphobia: Fear of losing an erection
7. Metathesiophobia: Fear of changes
8. Microminiaturization: Construction of something on a scale which is smaller than miniature
9. Micropalaeontology: Study of microscopic fossils
10. Monopathophobia: Fear of definite disease

N

N

1. Necessitarianism: Philosophical theory according to which actions are always consequent to antecedent causes
2. Nemathelminthes: Roundworms
3. Neopharmaphobia: Fear of new drugs
4. Nephelodometer: An instrument for estimating the distances or speed of clouds
5. Neurophysiological: Pertaining to the branch of physiology that deals with the functions of the nervous system
6. Nigroglobulate: The act of excluding someone by a negative vote or veto
7. Noctambulation: Sleepwalking
8. Nucamentaceous: Resembling a nut either structurally or their property of indehiscence; bearing one-seeded nut-like fruits
9. Nucleomituphobia: Fear of nuclear weapons
10. Nyctohylophobia: Fear of dark wooded areas at night

O

O

1. Obeliscolychny: Lighthouse
2. Obsequiousness: Abject submissiveness
3. Omphalopsychite: One who meditates by stares fixedly at his navel
4. Oneirogmophobia: Fear of wet dreams
5. Ophthalmophobia: Fear of being stared at
6. Ophthalmoscope: Instrument for viewing the interior of the eye
7. Opisthobranchiata: Marine gastropod mollusks with no operculum and gills present posterior to the heart
8. Orphanotrophism: Care and support of orphans
9. Ostraconophobia: Fear of shellfish
10. Otorhinolaryngology: It is a study of ear, nose, and throat

P

P

1. Palaeoanthropology: The study of early humans
2. Paleophytologist: One versed in the recovery and identification of plant fossils from geological contexts
3. Paraskavedekatriaphobia: Fear of Friday the 13th
4. Penecontemporaneous: Of geological processes occurring immediately after deposition
5. Philoprogenitiveness: The love of offspring
6. Pleuroperipneumony: Inflammation of the pleura and lungs
7. Pneumatophilosophy: Philosophy of spirits or the spirit world
8. Podobromhidrosis: Smelly feet
9. Pseudoantidisestablishmentarianism: Falsely supporting the idea of disestablishment
10. Pteromerhanophobia: Fear of flying

Q

Q

1. Quadragesimarian: One who observes Lent
2. Quadrigeminous: Four-fold
3. Quadrigenarious: Four hundred
4. Quasquicentennial: One hundred twenty-fifth anniversary
5. Quatrefeuille: An ornamental foliation having four foils
6. Quindecemvirate: The body or office of the fifteen sacerdotal college men bestowed with the primary duty of protecting the Sibylline books
7. Quinquagenarian: Person between the ages of 50 and 59
8. Quinquedentated: Five-toothed
9. Quoddamodotative: Existing in a certain manner
10. Quomodocunquize: Making money in any possible way

R

R

1. Radappertization: Treatment of food with ionizing radiation to kill bacteria
2. Radiometeorograph: An instrument for measuring atmospheric conditions at high altitude
3. Rambunctiousness: The state of being boisterous and disorderly
4. Ranidaphobia: Fear of frogs
5. Representationalism: Doctrine that ideas rather than external objects are basis of knowledge
6. Retrovaccination: The inoculation of a cow with human vaccination in which smallpox virus from human vesicles is used as seed virus in producing smallpox vaccine in cattle
7. Rhabdophobia: Fear of being severely punished or beaten by a rod, or of being severely criticized
8. Rhinotillexomania: Compulsive nose picking
9. Rodomontadist: A person who boasts
10. Roentgenometrics: A chiropractic technique involving the study of X-rays by biomechanical analysis and measurement

S

Funky Caterpillars

1. Sacramentarianism: Belief that sacraments have unusual properties
2. Scrophulariaceous: Pertaining to the figwort family of plants (Scrophulariaceae)
3. Secundogeniture: The right of inheritance belonging to the second-oldest child
4. Sesquicentennially: Every 150 years
5. Siderodromophobia: Fear of trains, railroads or train travel
6. Spasmenagaliaphobia: Fear of shattered glass
7. Spermatophobia: The fear of germs
8. Spectroheliokinematograph: Camera for taking pictures of the sun
9. Sphygmomanometer: An instrument for measuring arterial blood pressure
10. Steganophthalmata: A division of jellyfishes, including most of the large disklike species

T

T

1. Trinitrophenylmethylnitramine: A type of explosive
2. Tetrakishexahedron: A solid in the isometric system, bounded by 24 congruent isosceles-triangular faces, four corresponding to each face of the cube
3. Thanatognomonic: Indicating death
4. Theologicophobia: Fear of theology
5. Theophilanthropism: Having love for divinity as well as mankind
6. Thermoluminescence: A form of luminescence that is exhibited by certain crystalline materials that may have absorbed energy previously
7. Transmogrification: Transformation to a different form or shape, especially strange or grotesque
8. Trichopathophobia: Fear of hair
9. Triskaidekaphobia: Phobia of the number 13
10. Triboluminescence: Frictional emission of light

U

U

1. Ubiquitarianism: Belief in the omnipresence of God
2. Ultramicroscope: Instrument for viewing objects that are difficult to see by the naked eye
3. Ultimogeniture: The right of inheritance belonging to the last son
4. Umbraculiform: Umbrella-shaped
5. Uncircumstandtial: Not circumstantial; trivial
6. Uncompartmentalized: Not separated into different categories or compartments
7. Unconsentaneous: Disagreement
8. Uniformitarianism: The theory or assumption that the same natural laws and processes that operate in the universe now, have operated since its inception and apply everywhere in the universe and that all geological phenomena may be explained as the result of these existing forces
9. Unsoutcheoned: Destitute of an escutcheon
10. Utilitarianism: Adopting a code of conduct that determines ethical values

V

V

1. Valetudinarianism: The condition or state of mind of a sickly or weak person who is incessantly worried about personal health
2. Vasoconstriction: Narrowing of the blood vessels owing to the contraction of their muscular walls
3. Venturesomeness: Daring and adventurous
4. Venustraphobia: Being scared of beautiful women
5. Verminophobia: Being afraid of germs
6. Vernacularization: The act, process, or state of picking elements from a foreign language and modifying and accepting it as a part of a native dialect of a specific population
7. Virginitiphobia: Fear of rape
8. Vitricophobic: One who fears his step-father
9. Volumenometer: Instrument that determines volume of a solid
10. Voicespondence: Correspondence by means of formerly recorded conversations

W

W

1. Walloonphobia: Fear of Walloons (French-speaking Belgian community)
2. Wawaskeesh: An American elk
3. welterweight: A combat sports weight class division
4. Weatherometer: Instrument for measuring weather-resisting properties of paint
5. Weatherstripping: Material to seal the openings such as doors, trunks, windows to exclude the cold, wind, and rain
6. Weltanschauungen: One’s individual or a group’s outlook towards life
7. Whereinsoever: In whatever matter, respect, place, or action
8. Whippersnappers: People considered insignificant and pretentious
9. Whippoorwill: Night-jar from America
10. Whithersoever: Wherever

X

X

1. Xanthocyanopsy: Kind of color-blindness in which one can see only blue and yellow colors
2. Xanthomelanous: Pertaining to races with black hair and yellow or olive complexion
3. Xanthophobia: Fearful towards yellow color
4. Xanthospermous: Containing yellow seeds
5. Xenodocheionology: Liking for hotels and inns
6. Xenoglossophobia: Fear of foreign languages
7. Xerophthalmia: Dry eye syndrome
8. Xeroradiography: Kind of X-ray wherein the picture is taken on a paper and not on a film
9. Xiphophyllous: Sword-shaped leaved
10. Xylopyrographist: A poker painter

Y

Y

1. Yachtsmanship: Adeptness in sailing a yacht
2. Yarborough: Hand of cards where no card is above nine
3. Yarnwindle: Tool used for winding the yarn
4. Yellowhammer: A passerine bird in the bunting family Emberizidae
5. Yellowshanks: American shorebirds of the sandpiper family
6. Yellowthroats: A New World warblers in the genus Geothlypis
7. Yeomanette: Old term for a woman serving in the American naval reserve during World War II
8. Yezdegerdian: Pertaining to Yezdegerd, the last Sassanian monarch of Persia, overthrown by the Muslims
9. Yogibogeybox: Things used by a spiritualist
10. Yttriferous: One that contains yttrium

Z

Z

1. Zemmiphobia: Being afraid of the great mole rat
2. Zalambdodont: Having molar teeth with V-shaped ridges
3. Zarathustrianism: Zoroastrianism
4. Zeusophobia: Being scared of divine beings
5. Zigzaggery: Contortion
6. Zoanthodeme: Collective zooids of compound anthozoa
7. Zooarchaeology: Studying the remnants of animals on archaeological sites
8. Zoosporangium: A spore
9. Zeugmatography: A term previously proposed for magnetic resonance imaging (MRI)
10. Zeugobranchiata: A division of marine mollusks with gills on both sides of the body and paired renal organs

Now, here are some other fun words that are bound to wriggle those gray cells optimally. Most of them aren’t a part of any lexicon yet, but that doesn’t make them any less mesmerizing.

Here are the top 5 names of places on the globe with the longest names.

Taumata­whakatangihanga­koauau­o­tamatea­turi­pukakapiki­maunga­horo­nuku­pokai­whenua­kitanatahu (85 letters) – A hill in New Zealand, the name of which stands for: “The summit of the hill, where Tamatea, who is known as the land eater, slid down, climbed up and swallowed mountains, played on his nose flute to his loved one”.

Gorsafawddachaidraigodanheddogleddolonpenrhynareurdraethceredigion (66 letters) – A town in Wales, the name of which means: “The Mawddach station and its dragon teeth at the Northern Penrhyn Road on the golden beach of Cardigan bay”.

Llanfairpwllgwyngyllgogerychwyrndrobwllllantysiliogogogoch (58 letters) – A northern Welsh town the name of which means: “The church of St. Mary in the hollow of white hazel trees near the rapid whirlpool by St. Tysilio’s of the red cave”.

Chargoggagoggmanchauggagoggchaubunagungamaugg (41 letters) – A lake in Massachusetts.

Nunathloogagamiutbingoi (23 letters) – The name of certain Alaskan dunes.

And here are two mind-boggling scientific terms for your pleasure.

Methionylglutaminylarginyltyrosylglutamylserylleucylphenylalanylalanylglutaminylleucyllysylglutamylarginyllysylglutamylglycylalanylphenylalanylvalylprolylphenylalanylvalylthreonylleucylglycylaspartylprolylglycylisoleucylglutamylglutaminylserylleucyllysylisoleucylaspartylthreonylleucylisoleucylglutamylalanylglycylalanylaspartylalanylleucylglutamylleucylglycylisoleucylprolylphenylalanylserylaspartylprolylleucylalanylaspartylglycylprolylthreonylisoleucylglutaminylasparaginylalanylthreonylleucylarginylalanylphenylalanylalanylalanylglycylvalylthreonylprolylalanylglutaminylcysteinylphenylalanylglutamylmethionylleucylalanylleucylisoleucylarginylglutaminyllysylhistidylprolylthreonylisoleucylprolylisoleucylglycylleucylleucylmethionyltyrosylalanylasparaginylleucylvalylphenylalanylasparaginyllysylglycylisoleucylaspartylglutamylphenylalanyltyrosylalanylglutaminylcysteinylglutamyllysylvalylglycylvalylaspartylserylvalylleucylvalylalanylaspartylvalylprolylvalylglutaminylglutamylserylalanylprolylphenylalanylarginylglutaminylalanylalanylleucylarginylhistidylasparaginylvalylalanylprolylisoleucylphenylalanylisoleucylcysteinylprolylprolylaspartylalanylaspartylaspartylaspartylleucylleucylarginylglutaminylisoleucylalanylseryltyrosylglycylarginylglycyltyrosylthreonyltyrosylleucylleucylserylarginylalanylglycylvalylthreonylglycylalanylglutamylasparaginylarginylalanylalanylleucylprolylleucylasparaginylhistidylleucylvalylalanyllysylleucyllysylglutamyltyrosylasparaginylalanylalanylprolylprolylleucylglutaminylglycylphenylalanylglycylisoleucylserylalanylprolylaspartylglutaminylvalyllysylalanylalanylisoleucylaspartylalanylglycylalanylalanylglycylalanylisoleucylserylglycylserylalanylisoleucylvalyllysylisoleucylisoleucylglutamylglutaminylhistidylasparaginylisoleucylglutamylprolylglutamyllysylmethionylleucylalanylalanylleucyllysylvalylphenylalanylvalylglutaminylprolylmethionyllysylalanylalanylthreonylarginylserine – At 1,913 characters, this is the full name of tryptophan synthetase – a protein which consists of 267 amino acids.

Acetylseryltyrosylserylisoleucylthreonylserylprolylserylglutaminylphenylalanylvalylphenylalanylleucylserylserylvalyltryptophylalanylaspartylprolylisoleucylglutamylleucylleucylasparaginylvalylcysteinylthreonylserylserylleucylglycylasparaginylglutaminylphenylalanylglutaminylthreonylglutaminylglutaminylalanylarginylthreonylthreonylglutaminylvalylglutaminylglutaminylphenylalanylserylglutaminylvalyltryptophyllysylprolylphenylalanylprolylglutaminylserylthreonylvalylarginylphenylalanylprolylglycylaspartylvalyltyrosyllysylvalyltyrosylarginyltyrosylasparaginylalanylvalylleucylaspartylprolylleucylisoleucylthreonylalanylleucylleucylglycylthreonylphenylalanylaspartylthreonylarginylasparaginylarginylisoleucylisoleucylglutamylvalylglutamylasparaginylglutaminylglutaminylserylprolylthreonylthreonylalanylglutamylthreonylleucylaspartylalanylthreonylarginylarginylvalylaspartylaspartylalanylthreonylvalylalanylisoleucylarginylserylalanylasparaginylisoleucylasparaginylleucylvalylasparaginylglutamylleucylvalylarginylglycylthreonylglycylleucyltyrosylasparaginylglutaminylasparaginylthreonylphenylalanylglutamylserylmethionylserylglycylleucylvalyltryptophylthreonylserylalanylprolylalanylserine – With 1,185 letters, this is the chemical name of the Coat Protein, Tobacco Mosaic Virus (TMV), Dahlemense Strain and was first published in American Chemical Society’s “Chemical Abstracts Service”.

And now for the monarch of all words – 189,819 characters long!

Chemical Name of Titin

Whew!! Wasn’t that some real heavy stuff! Well that’s it for now. Guess you too are short of breath after reading the long list. Hope you had fun reading them though!

In this program, first we read sentence from user then we use string split() function to convert it to list. After splitting it is passed to max() function with keyword argument key=len which returns longest word from sentence.


This Python program finds longest word from a given text or sentence.


Python Source Code: Longest Word


# Longest word

# Reading sentence from user

sentence = input("Enter sentence: ")

# Finding longest word
longest = max(sentence.split(), key=len)

# Displaying longest word
print("Longest word is: ", longest)
print("And its length is: ", len(longest))

Output

Enter sentence: Tongue tied and twisted just an earth bound misfit I
Longest word is:  twisted
And its length is:  7

It should come as no surprise that we are word lovers. In fact, we are big word lovers in that we love really big words. To express our love, we looked around for some of the biggest, most ludicrously long words in the English language. In addition to pure length, we also tried to find: 

  • the longest word without vowels
  • the longest one-syllable word
  • and other uniquely long words.

Figuring out which word is the longest of them all isn’t as simple as just counting letters, though. Should you count scientific words? Should obscure, rarely used words be included, or should we give the honor to a word people actually use? In the interest of fairness, our list includes scientific words, obscure words, and all of the absurdly long words stuck in between.  

methionylthreonylthreonylglutaminylarginyl… 

At over 180,000 letters long, the chemical name of the protein titin is often said to technically be the longest English word. If spoken out loud, this word takes over three hours to say! Its absurd length is due to the fact that proteins get their scientific names by combining the names of all of their joined amino acids together, and titin has quite a lot of them. For obvious reasons, titin’s official name has never actually appeared in a dictionary or scientific text. Because it is a scientific term, many would disqualify the Big M from actually taking the crown as English’s longest word. 

pneumonoultramicroscopicsilicovolcanoconiosis

Pneumonoultramicroscopicsilicovolcanoconiosis, coming in at 45 letters long, is typically the biggest word you will find that actually appears in an English dictionary. According to many sources, it was coined around 1935 by Everett Smith, who at the time was the president of the National Puzzlers’ League. The word, which was basically engineered for its length, refers to a lung disease caused by inhaling silica dust. 

sesquipedalianism

Let’s look at a word related to the business of “longest words.” Sesquipedalianism is the tendency to use long words. Do you have sesquipedalian tendencies? (We do.)

The word is traced to the ancient Roman poet Horace, who in a treatise on the art of poetry wrote that in certain circumstances, poets must avoid sesquipedalia verba, a Latin phrase meaning “words [verba] a foot and a half long [sesquipedalia].” Horace clearly had a sense of humor.

pseudopseudohypoparathyroidism

We include pseudopseudohypoparathyroidism, another medical term, because this is one of the longest words to appear in major dictionaries that wasn’t created with length in mind. Pseudo- is a combining form meaning “false, pretended, unreal.”

You might notice the appearance of pseudo- twice. That’s because this disorder simulates the symptoms of pseudohypoparathyroidism, in which the body doesn’t respond to the parathyroid hormone. So, there are two levels of “faking it” going on here.

English isn’t the only language with lengthy elements of its lexicon. Get to know some of the world’s longest words!

antidisestablishmentarianism

Often, people will bust out antidisestablishmentarianism as the longest word they know and are actually able to say. This word has rarely been used and is only mentioned due to its ridiculous length. This word refers to opposition to withdrawing support from the Anglican Church as the state church of 19th-century England. 

supercalifragilisticexpialidocious

Even though the sound if it is something quite atrocious, we do really like the word supercalifragilisticexpialidocious. This nonsensical word with no real meaning was popularized by the 1964 Disney film Mary Poppins and is often used by children as an example of a humorously long word. Songwriters Richard and Robert Sherman take credit for this exact spelling of the word, but the word itself existed even before Mary Poppins made it popular. 

floccinaucinihilipilification

Here’s one that is also very meta: floccinaucinihilipilification is a rarely used word that means “the estimation of something as valueless.” It is usually used in reference to itself! Dating back to the 1700s, the word contains four Latin roots that all mean “of little value” or “trifling”: floccī, naucī, nihilī, and pilī.

honorificabilitudinitatibus

The word honorificabilitudinitatibus, which is said to mean “capable of receiving honor,” has two major honors to its name. Firstly, it is the longest word to ever appear in the works of William Shakespeare. Billy the Bard only ever used it once, in his play Love’s Labour’s Lost (1590s). Secondly, honorificabilitudinitatibus is the longest English word wherein the consonants and vowels alternate back and forth. Check it again if you didn’t notice! 

uncharacteristically

Uncharacteristically for most of the really long words you’ve seen so far, the word uncharacteristically is often said to be the longest word that the average English speaker will commonly see or actually use in everyday life. As you may already know, uncharacteristically is an adverb that describes something as not being typical or acting in a characteristic manner. 

incomprehensibilities

At 21 characters, another one of the longest words you might actually use yourself is incomprehensibilities. We define incomprehensible as “impossible to comprehend or understand,” so incomprehensibilities are “things you can’t comprehend.” ¿Comprendes?

uncopyrightables 

If you look closely at the spelling, you’ll notice a peculiar thing about this word with 16 letters. It does not repeat any letter; each character is used only once. This word is sometimes called an isogram among lovers of words and word games.

One of the longest isograms is subdermatoglyphic, at 17 characters. But, since subdermatoglyphic (dermatoglyphics studies the patterns of skin markings on the hands and feet) is a bit scientific and certainly not one that is used often, we’re spotlighting uncopyrightables instead because it’s one we can all remember. It means, of course, “items that are unable to be copyrighted.”

rhythms 

The word rhythms may not look like much at only seven letters long, but it is said to be the longest English word without one of the five main vowels in it. The letter Y, that wishy-washy “sometimes vowel,” is filling in while A, E, I, O, and U are taking a break. As we all know, the word rhythms means “movements or procedures with uniform or patterned recurrence of a beat, accent, or the like.” 

Are there really words without vowels? Depending on the definition, the answer might elicit a hmm.

strengths 

Strengths is another smaller word with a big achievement under its belt. It is the longest English word with only a single vowel in it. Considering it is only eight letters long, that really shows you how much we value our vowels. The plural strengths is most often used to mean “positive or valuable attributes or qualities.”  

squirrelled 

We go nuts for this word. While the word squirreled usually only has one L in American English, some dictionaries accept this British English version as an alternate spelling. Some Americans pronounce the word squirrelled as a one-syllable word (rhyming with “curled”). This makes squirrelled the longest one-syllable word in the English language at 11 letters. If all of that sounds too squirrely for you, the one-syllable verb broughammed from the noun brougham, a type of carriage, is also 11 letters long. 

As an aside, some may tell you that the word schtroumpfed is actually the longest “English” word with only a single syllable. This word has been used in some translations of The Smurfs (which is Les Schtroumpfs in French) in place of the more commonly used nonsensical verb smurfed. In our opinion, claiming schtroumpfed is the longest one-syllable word is just a bunch of smurf. 

Aegilops

Aegilops sounds like the name of a mythical monster, but it is actually the name of a genus of wild grasses commonly known as goatgrass. In addition to that, Aegilops is also commonly said to be the longest English word that has all of the letters in alphabetical order.


Indulge your inner sesquipedalian and take the quiz!

Think you’re ready to ace our longest English words quiz? Or is it a long shot? It won’t be long before you find out. Remember that a little practice goes a long way!

Three Ways to Find the Longest Word in a String in JavaScript

This article is based on Free Code Camp Basic Algorithm Scripting “Find the Longest Word in a String”.

In this algorithm, we want to look at each individual word and count how many letters are in each. Then, compare the counts to determine which word has the most characters and return the length of the longest word.

In this article, I’m going to explain three approaches. First with a FOR loop, second using the sort() method, and third using the reduce() method.

Algorithm Challenge

Return the length of the longest word in the provided sentence.

Your response should be a number.

Provided test cases

  • findLongestWord(“The quick brown fox jumped over the lazy dog”) should return a number
  • findLongestWord(“The quick brown fox jumped over the lazy dog”) should return 6
  • findLongestWord(“May the force be with you”) should return 5
  • findLongestWord(“Google do a barrel roll”) should return 6
  • findLongestWord(“What is the average airspeed velocity of an unladen swallow”) should return 8
  • findLongestWord(“What if we try a super-long word such as otorhinolaryngology”) should return 19
function findLongestWord(str) {
  return str.length;
}
findLongestWord("The quick brown fox jumped over the lazy dog");

1. Find the Longest Word With a FOR Loop

For this solution, we will use the String.prototype.split() method

  • The split() method splits a String object into an array of strings by separating the string into sub strings.

We will need to add an empty space between the parenthesis of the split() method,

var strSplit = “The quick brown fox jumped over the lazy dog”.split(‘ ‘);

which will output an array of separated words:

var strSplit = [“The”, “quick”, “brown”, “fox”, “jumped”, “over”, “the”, “lazy”, “dog”];

If you don’t add the space in the parenthesis, you will have this output:

var strSplit = 
[“T”, “h”, “e”, “ “, “q”, “u”, “i”, “c”, “k”, “ “, “b”, “r”, “o”, “w”, “n”, “ “, “f”, “o”, “x”, “ “, “j”, “u”, “m”, “p”, “e”, “d”, “ “, “o”, “v”, “e”, “r”, “ “, “t”, “h”, “e”, “ “, “l”, “a”, “z”, “y”, “ “, “d”, “o”, “g”];
function findLongestWord(str) {
  // Step 1. Split the string into an array of strings
  var strSplit = str.split(' ');
  // var strSplit = "The quick brown fox jumped over the lazy dog".split(' ');
  // var strSplit = ["The", "quick", "brown", "fox", "jumped", "over", "the", "lazy", "dog"];
	
  // Step 2. Initiate a variable that will hold the length of the longest word
  var longestWord = 0;

  // Step 3. Create the FOR loop
  for(var i = 0; i < strSplit.length; i++){
    if(strSplit[i].length > longestWord){ // If strSplit[i].length is greater than the word it is compared with...
	longestWord = strSplit[i].length; // ...then longestWord takes this new value
     }
  }
  /* Here strSplit.length = 9
     For each iteration: i = ?   i < strSplit.length?   i++  if(strSplit[i].length > longestWord)?   longestWord = strSplit[i].length
     1st iteration:        0             yes             1   if("The".length > 0)? => if(3 > 0)?     longestWord = 3
     2nd iteration:        1             yes             2   if("quick".length > 3)? => if(5 > 3)?   longestWord = 5   
     3rd iteration:        2             yes             3   if("brown".length > 5)? => if(5 > 5)?   longestWord = 5   
     4th iteration:        3             yes             4   if("fox".length > 5)? => if(3 > 5)?     longestWord = 5  
     5th iteration:        4             yes             5   if("jumped".length > 5)? => if(6 > 5)?  longestWord = 6 
     6th iteration:        5             yes             6   if("over".length > 6)? => if(4 > 6)?    longestWord = 6 
     7th iteration:        6             yes             7   if("the".length > 6)? => if(3 > 6)?     longestWord = 6
     8th iteration:        7             yes             8   if("lazy".length > 6)? => if(4 > 6)?    longestWord = 6 
     9th iteration:        8             yes             9   if("dog".length > 6)? => if(3 > 6)?     longestWord = 6 
     10th iteration:       9             no               
     End of the FOR Loop*/

  //Step 4. Return the longest word
  return longestWord; // 6
}

findLongestWord("The quick brown fox jumped over the lazy dog");
function findLongestWord(str) {
  var strSplit = str.split(' ');
  var longestWord = 0;
  for(var i = 0; i < strSplit.length; i++){
    if(strSplit[i].length > longestWord){
	longestWord = strSplit[i].length;
     }
  }
  return longestWord;
}
findLongestWord("The quick brown fox jumped over the lazy dog");

2. Find the Longest Word With the sort() Method

For this solution, we will use the Array.prototype.sort() method to sort the array by some ordering criterion and then return the length of the first element of this array.

  • The sort() method sorts the elements of an array in place and returns the array.

In our case, if we just sort the array

var sortArray = [“The”, “quick”, “brown”, “fox”, “jumped”, “over”, “the”, “lazy”, “dog”].sort();

we will have this output:

var sortArray = [“The”, “brown”, “dog”, “fox”, “jumped”, “lazy”, “over”, “quick”, “the”];

In Unicode, numbers come before upper case letters, which come before lower case letters.

We need to sort the elements by some ordering criterion,

[].sort(function(firstElement, secondElement) {     return secondElement.length — firstElement.length; })

where the length of the second element is compared to the length of the first element in the array.

function findLongestWord(str) {
  // Step 1. Split the string into an array of strings
  var strSplit = str.split(' ');
  // var strSplit = "The quick brown fox jumped over the lazy dog".split(' ');
  // var strSplit = ["The", "quick", "brown", "fox", "jumped", "over", "the", "lazy", "dog"];
  
  // Step 2. Sort the elements in the array
  var longestWord = strSplit.sort(function(a, b) { 
    return b.length - a.length;
  });
  /* Sorting process
    a           b            b.length     a.length     var longestWord
  "The"      "quick"            5            3         ["quick", "The"]
  "quick"    "brown"            5            5         ["quick", "brown", "The"]  
  "brown"    "fox"              3            5         ["quick", "brown", "The", "fox"]
  "fox"      "jumped"           6            3         ["jumped", quick", "brown", "The", "fox"]
  "jumped"   "over"             4            6         ["jumped", quick", "brown", "over", "The", "fox"]
  "over"     "the"              3            4         ["jumped", quick", "brown", "over", "The", "fox", "the"]
  "the"      "lazy"             4            3         ["jumped", quick", "brown", "over", "lazy", "The", "fox", "the"]
  "lazy"     "dog"              3            4         ["jumped", quick", "brown", "over", "lazy", "The", "fox", "the", "dog"]
  */
  
  // Step 3. Return the length of the first element of the array
  return longestWord[0].length; // var longestWord = ["jumped", "quick", "brown", "over", "lazy", "The", "fox", "the", "dog"];
                                // longestWord[0]="jumped" => jumped".length => 6
}

findLongestWord("The quick brown fox jumped over the lazy dog");
function findLongestWord(str) {
  var longestWord = str.split(' ').sort(function(a, b) { return b.length - a.length; });
  return longestWord[0].length;
}
findLongestWord("The quick brown fox jumped over the lazy dog");

3. Find the Longest Word With the reduce() Method

For this solution, we will use the Array.prototype.reduce().

  • The reduce() method applies a function against an accumulator and each value of the array (from left-to-right) to reduce it to a single value.

reduce() executes a callback function once for each element present in the array.

You can provide an initial value as the second argument to reduce, here we will add an empty string “”.

[].reduce(function(previousValue, currentValue) {...}, “”);
function findLongestWord(str) {
  // Step 1. Split the string into an array of strings
  var strSplit = str.split(' ');
  // var strSplit = "The quick brown fox jumped over the lazy dog".split(' ');
  // var strSplit = ["The", "quick", "brown", "fox", "jumped", "over", "the", "lazy", "dog"];

  // Step 2. Use the reduce method
  var longestWord = strSplit.reduce(function(longest, currentWord) {
    if(currentWord.length > longest.length)
       return currentWord;
    else
       return longest;
  }, "");
  
  /* Reduce process
  currentWord      longest       currentWord.length     longest.length    if(currentWord.length > longest.length)?   var longestWord
  "The"             ""                  3                     0                              yes                          "The"
  "quick"           "The"               5                     3                              yes                         "quick"
  "brown"           "quick"             5                     5                              no                          "quick"
  "fox"             "quick"             3                     5                              no                          "quick"
  "jumped"          "quick"             6                     5                              yes                         "jumped"
  "over"            "jumped"            4                     6                              no                          "jumped"
  "the"             "jumped"            3                     6                              no                          "jumped"
  "lazy"            "jumped"            4                     6                              no                          "jumped"
  "dog"             "jumped"            3                     6                              no                          "jumped"
  */
  
  // Step 3. Return the length of the longestWord
  return longestWord.length; // var longestWord = "jumped" 
                             // longestWord.length => "jumped".length => 6
}

findLongestWord("The quick brown fox jumped over the lazy dog");
function findLongestWord(str) {
  var longestWord = str.split(' ').reduce(function(longest, currentWord) {
    return currentWord.length > longest.length ? currentWord : longest;
  }, "");
  return longestWord.length;
}
findLongestWord("The quick brown fox jumped over the lazy dog");

I hope you found this helpful. This is part of my “How to Solve FCC Algorithms” series of articles on the Free Code Camp Algorithm Challenges, where I propose several solutions and explain step-by-step what happens under the hood.

Three ways to repeat a string in JavaScript
In this article, I’ll explain how to solve freeCodeCamp’s “Repeat a string repeat a string” challenge. This involves…

Two ways to confirm the ending of a String in JavaScript
In this article, I’ll explain how to solve freeCodeCamp’s “Confirm the Ending” challenge.

Three Ways to Reverse a String in JavaScript
This article is based on Free Code Camp Basic Algorithm Scripting “Reverse a String”

Three Ways to Factorialize a Number in JavaScript
This article is based on Free Code Camp Basic Algorithm Scripting “Factorialize a Number”

Two Ways to Check for Palindromes in JavaScript
This article is based on Free Code Camp Basic Algorithm Scripting “Check for Palindromes”.

Three Ways to Title Case a Sentence in JavaScript
This article is based on Free Code Camp Basic Algorithm Scripting “Title Case a Sentence”.

Three ways you can find the largest number in an array using JavaScript
In this article, I’m going to explain how to solve Free Code Camp’s “Return Largest Numbers in Arrays” challenge. This…

If you have your own solution or any suggestions, share them below in the comments.

Or you can follow me on Medium, Twitter, Github and LinkedIn, right after you click the green heart below ;-)

‪#‎StayCurious‬, ‪#‎KeepOnHacking‬ & ‪#‎MakeItHappen‬!

Resources

  • split() method — MDN
  • sort() method — MDN
  • reduce() — MDN
  • String.length — MDN
  • for — MDN


Learn to code for free. freeCodeCamp’s open source curriculum has helped more than 40,000 people get jobs as developers. Get started

Ready to take your Scrabble skills to the next level? This list of the longest words in the English language could score you major points on your next game — if you can remember how to spell them.

Some of the words that qualify for the title take hours to pronounce, like the 189,819-letter word for the  protein Titin. Additionally, many of the longest words are medical terms, so we have excluded some of them to allow for more variety. The end result is a list of fascinatingly lengthy words that will make your vocabulary downright sesquipedalian.

Antidisestablishmentarianism

Part of Speech: noun

Definition: opposition to the disestablishment of the Church of England

Origins: While the word originated in 19th century Britain, it is now used to refer to any opposition to a government withdrawing support from a religious organization. Though rarely used in casual conversation, the word was featured in the Duke Ellington song, “You’re Just an Old Antidisestablishmentarianist.”  

Floccinaucinihilipilification

Part of Speech: noun

Definition: the act of defining or estimating something as worthless

Origins: This word stems from the combination of four Latin words, all of which signify that something has little value: flocci, nauci, nihili, pilifi. This style of word creation was popular in Britain in the 1700s. 

Pneumonoultramicroscopicsilicovolcanoconiosis

Part of Speech: noun

Definition: an invented word said to mean a lung disease caused by inhaling a fine dust

Origins: This word emerged in the late 1930s, and was said to be invented by Everett K. Smith, president of the National Puzzlers’ League, in an imitation of very long medical terms. It is not found in real medical usage.

Pseudopseudohypoparathyroidism

Part of Speech: noun

Definition: an inherited disorder similar to pseudohypoparathyroidism

Origins: This genetic disorder causes “short stature, round face and short hand bones,” according to the National Institutes of Health. Despite having a similar name, it is not the same as pseudohypoparathyroidism.

Psychoneuroendocrinological

Part of Speech: adjective

Definition: of or related to to the branch of science concerned with the relationships between psychology, the nervous system, and the endocrine system 

Origins: This term was first seen in the 1970s in Journal of Neurological Science, a medical journal. 

Sesquipedalian

Part of Speech: adjective

Definition: having many syllables or characterized by the use of long words

Origins: The Roman poet Horace used this term to caution young poets against relying on words that used a large number of letters. It was adopted in the 17th century by poets to ridicule their peers who used lengthy words.

Hippopotomonstrosesquippedaliophobia

Part of Speech: noun

Definition: fear of long words

Fun Fact: This word is most often used in humorous contexts. It is an extension of the word sesquipedalophobia, which has the same meaning and is more often used in a formal context.  

Incomprehensibilities

Part of Speech: noun

Definition: things that are impossible to understand or comprehend

Fun Fact: In the 1990s, this word was named the longest word in common usage.

Uncopyrightable

Part of Speech: adjective

Definition: not able or allowed to be protected by copyright

Fun Fact: This word is one of the longest isograms (a word that does not repeat letters) in the English language.

Dermatoglyphics

Part of Speech: noun

Definition: the scientific study of hands, including fingerprints, lines, mounts, and shapes

Fun Fact: Unlike palmistry, this study is based in science and is often used in criminology as a way to identify both perpetrators and victims.

Euouae

Part of Speech: noun

Definition: a type of cadence in medieval music

Fun Fact: While this word might not look as impressive as others on this list, it’s the longest word in the English language to be composed entirely of vowels. (It’s also the word with the longest string of vowels.)

Psychophysicotherapeutics

Part of Speech: noun

Definition: a therapeutic approach that integrates both the mind and body

Fun Fact: While the Oxford Dictionary does not provide an official definition of this word, it is included on their list of the longest words in the English language. 

Otorhinolaryngological

Part of Speech: adjective

Definition: of or relating to the medical specialization involving the ear, nose, and throat

Fun Fact: This medical specialization is more commonly known by its acronym, ENT. 

In this post, we’re going to walk through another common coding interview problem: finding the longest word in a paragraph. This is a really good question, because it’s very easy to forget some important details, and the perhaps obvious solution isn’t necessarily the best.

Walking Through the Problem

For this particular problem, we’re going to imagine we’ve been given the following string of lorem ipsum text. For the sake of space, we’ll assume that this string is being used as the value for a variable called base_string.

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas luctus ipsum et facilisis dignissim. Duis mattis enim urna. Quisque orci nunc, vulputate id accumsan nec, imperdiet sit amet sem. Integer consequat nibh vel mattis elementum. Nam est elit, sodales vitae augue nec, consequat porttitor nibh. Aliquam ut risus vehicula, egestas ligula sed, egestas neque. Fusce hendrerit vel risus in molestie. Morbi molestie eleifend odio vel ullamcorper. Donec at odio libero. Quisque vulputate nisl nisi, ut convallis lorem vulputate et. Aenean pretium eu tellus a dapibus. Ut id sem vulputate, finibus erat quis, vestibulum enim. Donec commodo dui eros, non hendrerit orci faucibus eu. Integer at blandit ex. Duis posuere, leo non porta tincidunt, augue turpis posuere odio, sed faucibus erat elit vel turpis. Quisque vitae tristique leo.

Lorem ipsum is just a common dummy text used in typesetting and printing to simulate actual text content. It includes words of various lengths, as well as punctuation, so it’s perfect for our purposes.

So, how do we find the longest word?

Since our paragraph is currently a single string, we’re probably going to have to find a way to break it up into individual words. This will let us to perform a direct comparison between different words, allowing us to find out whether a given word is longer than another.

There are a few ways we can perform the actual comparison.

We can create a variable called something like longest_word set to an empty string, and then iterate over all the words, comparing the length of the current longest_word with the word we’re checking as part of this iteration. If the new word is longer, we can replace the value of  longest_word with the new word. Repeating this process for every word in the paragraph will leave us with the longest word in the paragraph bound to the longest_word variable.

Another option is that we use the max function, which takes in an iterable, and returns a single item from the collection. It will return the single largest member of the collection, but we’ll have to provide some configuration to max so that it knows what that means given the context.

Both of these solutions potentially have a small issue in that they only return a single word. What if two words are of identical length? Do we provide one of these longest words as a solution, or do we provide a collection of all the longest words? If we have to provide all the longest words, then we’re going to need to use a different method.

With that, let’s move onto out first bit of code for this problem. There is a problem with these solutions, which I’ll talk about in a moment.

Our First Solution

Python includes a handy method for strings called split. You can read about split in the official documentation.

split will essentially allow us to divide a string into a list of items using a delimiter string. Whenever this delimiter is encountered in the string, split will create a break point. Everything between these break points becomes an item in the resulting list.

We can therefore do something like this:

word_list = base_string.split(" ")
# ["Lorem", "ipsum", "dolor", "sit", "amet,", ... etc.]

Eagle eyed readers may have already noticed a problem. The comma after amet is included in the corresponding list item. This is the case for all words that have punctuation, and it poses a serious problem.

Our text actually has two longest words, but one of them is at the end of a sentence, and therefore has an appended full stop. With the punctuation included, this word incorrectly becomes the sole longest word in the paragraph.

The problem could be even worse if we have punctuation like quotation marks, since the inclusion of two punctuation characters might make a word longer than the real longest word, despite being potentially a character shorter in reality. This only gets worse as punctuation gets compounded together.

It’s clear then that we have to do something about all this extra punctuation.

We can make use of another string method called strip to take of the problem. Once again, you can find details on how strip works in the official docs.

strip allows us to remove characters from either end of a string, and it will keep removing those characters until it encounters a character which does not match those it was instructed to remove. By default, it removes whitespace characters, but we can provide a collection of punctuation instead.

Using a list comprehension, we can therefore iterate over our word_list and correct the punctuation issue:

word_list = base_string.split(" ")
processed_words = [word.strip(".,?!"':;(){}[]") for word in word_list]

This is absolutely going to work for our example string, but it’s also not a very good solution. For a start, having to use these escape characters is ugly, but more importantly, this group of punctuation is not complete, and it would very tedious to make it complete.

Right now we don’t do anything to filter out tildes for example (~), or percentage signs, or hash symbols. There’s also another issue we didn’t consider at all thus far: numbers. Numbers could easily end up being larger than our longest words, giving us erroneous results.

Instead of removing things we don’t wan’t, perhaps we can go the other way, adding only the things we do want. Enter RegEx.

Using RegEx

RegEx or regular expressions are a means through which we can define patterns to look for in strings. RegEx is a pretty expansive topic, certainly too big to cover here, but there’s a tutorial on using RegEx in Python available in the documentation.

In order to work with regular expressions in Python, we need to import the re module, so that’s our first step:

import re

Next, we’ll take our base_string variable, containing our lorem ipsum text, and provide as an argument to the findall function that we find in the re module. Along with base_string, we’re also going to provide a pattern using the RegEx syntax like so:

import re

word_list = re.findall("[A-Za-z]+", base_string)

RegEx is notoriously cryptic, but our pattern here is relatively simple. It says that we’re looking for any letter character in the basic Latin alphabet; we don’t care about case; and we want patterns that include any number of these characters, as indicated by the + symbol.

Our resulting word_list variable will now contain a list full of letter only strings. While traversing our string, any time a character was encountered that wasn’t part of the our defined pattern, findall considered that the end of a word.

Pretty neat stuff if you ask me.

Another Minor Problem

Unfortunately, it’s too early to celebrate just yet. There’s once again a problem with our current implementation: punctuation inside words.

Consider a situation like this:

John’s dog hasn’t eaten its food.

We might make a very good argument that «John’s» and «hasn’t» are single words, in which case, we have a problem. Right now if we run our code on this sentence we get the following:

import re

base_string = "John's dog hasn't eaten its food."
word_list = re.findall("[A-Za-z]+", base_string)

# ['John', 's', 'dog', 'hasn', 't', 'eaten', 'its', 'food']

This might be perfectly fine, but what happens if your interviewer asks you to treat «John’s» as one word? In that case, «John’s» is a 5 letter word with a piece of punctuation.

The best answer might be to combine our methods. We can split the string based on spaces, and then check each word for punctuation. This time, however, instead of splitting the string, we’ll perform a replacement using another re function called sub.

sub takes a pattern, a replacement string for that pattern, and a string to search.

import re

base_string = "John's dog hasn't eaten its food."
word_list = base_string.split(" ")
processed_words = [re.sub("[^A-Za-z]+", "", word) for word in word_list]

# ['Johns', 'dog', 'hasnt', 'eaten', 'its', 'food']

Here our pattern is exactly the same as before, except we’ve added a special character, ^, which essentially says match anything which is not in this pattern. As our pattern includes only basic Latin letters, all punctuation is going to be matched by this pattern. Our replacement string is an empty string, which means any time we find a match, the matching characters will simply be removed.

Putting this in a list comprehension, we can perform the substitution for every word in the word_list, giving us a list of properly processed words.

With that, we can finally start counting the length of the words and find the longest word in the paragraph.

Finding the Longest Word

As I mentioned before, we have a couple of options for finding the longest word in our list of words.

Let’s start with the string replacement method, using our original paragraph:

import re

word_list = base_string.split(" ")
processed_words = [re.sub("[^A-Za-z]+", "", word) for word in word_list]

longest_word = ""
for word in processed_words:
	if len(longest_word) < len(word):
		longest_word = word

print(longest_word)  # consectetur

In this implementation, we start with an empty string, and begin iterating over all the words in the processed_words. If the current word is longer than the current longest_word we replace the longest word. Otherwise, nothing happens.

Since we start with an empty string, the first word will become the longest string initially, but it will be dethroned as soon as a longer word comes alone.

Instead of this fairly manual method, we could make use of the max function.

import re

word_list = base_string.split(" ")
processed_words = [re.sub("[^A-Za-z]+", "", word) for word in word_list]

longest_word = max(processed_words, key=len)

print(longest_word)  # consectetur

In this method we have to pass in the processed_words as the first argument, but we also have to provide a key. By providing the len function as a key, max will use the length of the various words for determining which is of the greatest value.

Both of these methods only provide a single word, so how do we get all of the longest words if we have multiple words of equal length?

Finding a List of the Longest Words

In order to find all of the longest words, we can do a second pass over our processed_words now that we know what the longest word actually is. We can do this using a conditional list comprehension.

import re

word_list = base_string.split(" ")
processed_words = [re.sub("[^A-Za-z]+", "", word) for word in word_list]

max_word_length = len(max(processed_words, key=len))
longest_words = [word for word in processed_words if len(word) == max_word_length]

print(longest_words)  # ['consectetur', 'ullamcorper']

Wrapping Up

With that, we’ve successfully found the longest words in a paragraph. Of course this isn’t the only way you could solve this problem, and the specific problem might call for minor variations as well. You may be asked to find the length of the longest word in the paragraph, but if you can do the version shown here, that question should be a breeze.

We’d love to see your own solutions to this problem, so get on repl.it and share your solutions with us on Twitter. If you liked the post, we’d also really appreciate it if you could share it with your techy friends.

We’ll see you again Monday when we’ll be releasing part two of our brief look at the itertools module! If you can’t wait, you might want to check out our Complete Python Course where we go into more depth on many of these topics.

The Longest Words in English

websters second international dictionary

Most English words longer than about 15-20 letters are scientific, meaningless, or highly specialized, and they tend to be formed by affixation. This is the act or process of adding affixes to a base word to produce a derivative word—in the word affixation, for instance, -ation is an affix. Here are some of the longest words.

respiratory masks

The longest word entered in most standard English dictionaries is Pneumonoultramicroscopicsilicovolcanoconiosis with 45 letters. Our definition is «a lung disease caused by inhalation of very fine silicate or quartz dust.» The entry for this word can be found in our Medical Dictionary.

woman using microscope

Yes, that number is correct. The longest string of letters used to describe something isn’t technically a word—it’s the chemical name for a protein, begins with methionylthreonylthreonylglutaminyl…, and continues for quite a while after that. The name has 189,819 letters, fills more than 50 pages, and takes more than three hours to say. If you’ve got three hours to blow, you can listen to it said here.

28, 29, and 34 Letters

floating umbrella

There are some long words that are rarely or never used in a sentence, but instead are simply used as examples of long words, and for that reason we don’t include them in our dictionaries. The most famous of these are antidisestablishmentarianism, which has 28 letters and supercalifragilisticexpialidocious, which has 34 letters. Floccinaucinihilipilification (29 letters) («the act or habit of assessing something as worthless») is another of this ilk. Our claim is not that these aren’t words, but that they aren’t words that meet our criteria for entry. We explain why here.

lake

The longest place name in the United States is possibly a lake in Massachusetts called Lake Chargoggagoggmanchauggauggagoggchaubunagungamaugg (49 letters, or 53, if you count the Lake portion). It is also sometimes called Webster Lake. While the longer name is based on earlier names for the lake from the language of the Nipmuc people who inhabited the area, this version of the name—along with its reputed translation, «You fish on your side; I fish on my side; nobody fishes in the middle”—appears to have been the invention of a local newspaper editor.

alt-62a77ae9ab3cd

Photo: Hill near Hawkes Bay, NZ

The longest place name in the English-speaking world is thought to be a 1,001-foot-high hill in New Zealand called Taumatawhakatangihangakoauauotamateaturipukakapikimaungahoronukupokaiwhenu-akitanatahu. Similar to the lake mentioned above, this place name also has spelling variations. It comes from the Maori language and has been translated as “the place where Tamatea, the man who had big knees, the climber of mountains, the slider, the land-swallower that traveled about, played the nose flute that he had to the loved ones.” The hill is sometimes called “Taumata” for short.

30 Letters

medical test results

29 Letters

mdma pills in baggie

Methylenedioxymethamphetamine refers to a synthetic amphetamine used illicitly for its mood-enhancing and hallucinogenic properties. You may know this drug by another, shorter, name: ecstasy. Or you may know it by an even shorter name: MDMA. (Fun fact: in the 1970’s psychiatrists used it to «enhance» therapy sessions.)

23, 24, 25, 26, and 27 Letters

electroencephalograph

22 Letters

doctor examining ear

Counterrevolutionaries refers to people who participate in a revolution directed toward overthrowing a government or social system established by a previous revolution.

Deinstitutionalization refers to the release of institutionalized individuals from institutional care (as in a psychiatric hospital) to care in the community, and also to the reform or modification of an institution to remove or disguise its institutional character..

Otorhinolaryngological refers to a medical specialty concerned especially with the ear, nose, and throat and related parts of the head and neck.

21 Letters

confused child

Incomprehensibilities refers to things that are hard to comprehend or understand. (We’re pretty sure most of these words qualify.)

Pseudohermaphroditism refers to the condition of having the gonads and karyotype of one sex and external genitalia that is of the other sex or is ambiguous.

And finally, psychoneuroimmunology refers to a branch of medicine that deals with the influence of emotional states and nervous system activities on immune function.

(Did you count only 20 words in the list? The 21st is hippopotomonstrosesquippedaliophobia, which is fear of long words. Apologies to anyone who suffers from this condition with its 36-letter name—we’re sure we’ve made it worse.)

Given a string S consisting of lowercase English alphabets, the task is to print the longest word present in the given string in python.

Examples:

Input: S = “be confident and be yourself”
Output: “confident”
Explanation:
Words present in the sentence are “be”, “confident”, “and”, “be” and “yourself”. Length of each of the words are 2, 9, 3, 2, and 8 respectively.
Therefore, the longest word is “confident”.

Input: S = “geeks for geeks”
Output: “geeks”

Searching-based Approach: Refer to this article to solve this problem by performing the following steps:

  • Iterate over the characters of the string.
  • Check if the current character encountered is a space or end of the string is reached.
  • If the current character is found to be so, update the maximum length of a word obtained.
  • Finally, print the longest word obtained using substr() method.

Time Complexity: O(N) 
Auxiliary Space: O(N)

Approach using sorted() method: The idea is to split the string into separate words and store in a list. Then, sort the list in the order of increasing length using the sorted() method. Print the last string in the sorted list.

Below is the implementation of the above approach:

Python3

def largestWord(s):

    s = sorted(s, key = len)

    print(s[-1])

if __name__ == "__main__":

    s = "be confident and be yourself"

    l = list(s.split(" "))

    largestWord(l)

Time Complexity: O(N * logN)
Auxiliary Space: O(1)

Approach using max() and split() methods:  This approach uses the max() function with the split () method to split the string into a list of words and find the longest word.

Python3

def longestword(s):

    s=s.split()

    print(max(s,key=len))

if __name__ == "__main__":

    s = "be confident and be yourself"

    longestword(s)

Time Complexity: O(N), N is the number of words in the input string used for iteration only once.
Auxiliary Space: O(N), N is used for creating a new list from the input string and stores it in memory.

Approach using re module:

Python3

import re

def longest_word(sentence):

    words = re.findall(r'bw+b', sentence)

    return max(words, key=len)

sentence = "be confident and be yourself"

print(longest_word(sentence))

Time Complexity: O(N), N is the number of words in the input string used for iteration only once.
Auxiliary Space: O(N), N is used for creating a new list from the input string and stores it in memory.

Approach Using the reduce() function from the functools module: 

Algorithm:

1.Split the input string into a list of words using the split() method.
2.Initialize a variable to store the longest word as the first word in the list.
3.Iterate through the list of words and compare the length of each word to the length of the current longest word.
4.If the length of the current word is greater than the length of the current longest word, update the variable storing the longest word.
5.Return the longest word.

Python3

from functools import reduce

def longest_word(s):

    words = s.split()

    return reduce(lambda x, y: x if len(x) > len(y) else y, words)

s = "be confident and be yourself"

longest = longest_word(s)

print("The longest word in the string is:", longest)

Output

The longest word in the string is: confident

Time Complexity: O(n), where n is the total number of characters in the input string. This is because we need to iterate through each character in the string to split it into words, and then iterate through each word to find the longest one.

Space Complexity: O(m), where m is the total number of words in the input string. This is because we need to store each word in a list, and then store the longest word as a variable.

Понравилась статья? Поделить с друзьями:
  • Find words in a bigger word
  • Find words from a word game
  • Find word worksheet making
  • Find word with regular expression
  • Find word with random letters