Using R to Win Worldle (2024)

[This article was first published on rbloggers – Jared Lander, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)

Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

TheWordlecraze has inspired many clones, includingWorldle. In this version, you are shown an outline of a country or territory (including uninhabited islands) and have six guesses to figure out which country or territory is displayed. With each incorrect guess you are told how far the center of the country you guessed is from the center of the correct country in kilometers, as well as the general direction.

When playing the other day, I had this outline and did not even have a clue about what country it could be.

Using R to Win Worldle (1)

So I started with some random guesses, hoping I could narrow it down by rudimentary triangulation. After three guesses I had the following results.

guesses <- tibble::tribble( ~Country, ~Distance, ~Direction, 'Iceland', 13427, 'South', 'Sierra Leone', 7144, 'South', 'Lesotho', 3404, 'Southwest')guesses
CountryDistanceDirection
Iceland13427South
Sierra Leone7144South
Lesotho3404Southwest

The best I could tell was that the correct answer was somewhere in the middle of the South Atlantic Ocean but it was probably a small island that would be hard to find by panning through Google Maps. So I decided to use R and the{sf}package to help locate the correct answer.

The goal with the code is to find the centers of each guess, draw circles around those centers, each with a radius as given by the distance in the game, then see where the three circles intersect. This is the general idea behind triangulation and should show us roughly where the correct country is positioned.

First, I needed to find the centers of my incorrect guesses, so I used the{rnaturalearth} package to pull up the boundaries of the countries guessed so far and then use st_centroid() to compute their centroids.

library(sf)library(dplyr)data(countries110, package='rnaturalearth')# this is an sp object so we make it into sfcountries <- countries110 |> st_as_sf()# here we narrow it down to the countries we want to keepstarting <- countries |> select(brk_name) |> inner_join(guesses, by=c('brk_name'='Country')) |> # leaflet makes you assign your own colors mutate(color=RColorBrewer::brewer.pal(n(), 'Set1'))# this finds the centroids of each country# the warning doesn't apply to uscenters <- starting |> st_make_valid() |> st_centroid()## Warning in st_centroid.sf(st_make_valid(starting)): st_centroid assumes## attributes are constant over geometries of x# these are the centers of each guesscenters
brk_nameDistanceDirectiongeometrycolor
Iceland13427SouthPOINT (-18.76554 65.07986)#E41A1C
Lesotho3404SouthwestPOINT (28.17182 -29.62479)#377EB8
Sierra Leone7144SouthPOINT (-11.79541 8.529459)#4DAF4A

Now we map these points to see how we’re doing. For this blog, the maps are static though when recreating this in the console or an HTML rmarkdown document, they would be pannable and zoomable.

library(leaflet)leaflet() |> addTiles() |> # we use the color column defined earlier addPolygons(data=starting, fillColor=~color, stroke=FALSE, opacity=1) |> addMarkers(data=centers)
Using R to Win Worldle (2)

For each of our guesses, we want to draw a circle extending out from their centers. The radius of each circle is given by the distance reported in the game. To compute these circles we use st_buffer()which creates a polygon around a given geometry, the points in this case.

The latest version of{sf}uses spherical geometry by default. This means we can pass ansfobject that uses lat/long tost_buffer(), specifying thedistargument in kilometers, andst_buffer()will account for the curvature of the Earth. In previous versions, we would first convert to a meters-based projection (which is hard to do on a global scale) then compute the buffer then convert back to lat/long. Spherical geometry is a huge improvement.

st_buffer() returns the entire circle as a filled in polygon, but we actually just want the boundaries of the circles because we want to compute the intersection of the boundaries not of the insides of the circles. To convert our circle polygons to just the outlines we usest_cast("LINESTRING").

circles <- centers |> # we use the distance from each center # this is stored in km so we multiply by 1000 to get meters st_buffer(dist=centers$Distance*1000) |> # get just the outline of the cirles st_cast("LINESTRING")## Warning in st_cast.sf(st_buffer(centers, dist = centers$Distance * 1000), :## repeating attributes for all sub-geometries for which they may not be constantleaflet() |> addTiles() |> # we use the color column defined earlier addPolylines(data=circles, color=~color, popup=~brk_name) |> addMarkers(data=centers)
Using R to Win Worldle (3)

The circle for Iceland, in red, is only displayed as a semicircle. This is due to its radius being so large and extending over the north pole. Fortunately, that doesn’t matter for our purposes. By looking where the three circles intersect we should be able to find the country we are searching for.

With triangulation, the three circles will intersect in just one spot. It may appear that all three circles intersect in two places, but this is an artifact of the circle around Iceland being weirdly displayed.

To find where all the circles intersect we find any intersection amongst them with st_intersection() then narrow down the resulting points to those that have three or more overlaps.

overlaps <- circles |> st_intersection() |> filter(n.overlaps >= 3)overlaps
brk_nameDistanceDirectioncolorn.overlapsoriginsgeometry
1.2Iceland13427South#E41A1C31, 2, 3POINT (3.483787 -54.73521)

This means we should focus our search at (3.4838,-54.7352). Since the measurements are not exact we look for this point on a map plus a little extra to help us see what’s around it.

leaflet() |> addTiles() |> addCircles(data=overlaps) |> # 100 km search area addPolylines(data=overlaps |> st_buffer(dist=100*1000))
Using R to Win Worldle (4)

And we found Bouvet Island! This little uninhabited nature reserve isn’t even in the data.frameprovided by{rnaturalearth}so I’m not sure how I would have found it without{sf}.

Spatial analytics and GIS are a really powerful part of data science and I have been using them more and more for clients lately. I’ve alsogivenacoupletalksrecently where you can see more about GIS.

While Worldle is fun to play on its own, it was even more fun using R to find the solution for a particularly tricky problem.


Using R to Win Worldle (5)Using R to Win Worldle (6)

Jared Lander is the Chief Data Scientist of Lander Analytics a New York data science firm, Adjunct Professor at Columbia University, Organizer of the New York Open Statistical Programming meetup and the New York and Washington DC R Conferences and author of R for Everyone.Using R to Win Worldle (7)

Using R to Win Worldle (8)

Related

To leave a comment for the author, please follow the link and comment on their blog: rbloggers – Jared Lander.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.

Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Using R to Win Worldle (2024)

FAQs

What is the fastest winning strategy in Wordle? ›

Here's what to do: Guess LIGHT, CANDY, POWER, and BUMFS. That's four guesses with 20 unique letters, including all five vowels. At that point—after only a few seconds of typing—you're pretty much guaranteed to know all the letters in the winning word.

What are the 5 words for the Wordle trick? ›

Here are the 5 "Magic" Words that will help you solve Wordle more often than not. "Derby, flank, ghost, winch, jumps."

What is the trick to solving Wordle? ›

1 Start with a word that has 3, 4, or 5 vowels. 2 Use your second try to confirm as many letters as possible. 3 Try our cheat sheet of the best Wordle words. 4 Learn the most common letters and their positions.

What is the #1 best word to start with in Wordle? ›

According to WordsRated's analysis, the best starting words for Wordle are CRANE (based on all available solutions) and SAUCY (based on remaining solutions as of Feb, 2024). For Normal mode, SLATE, SALET, ROATE and STARE are known to be some of the best alternative starting words for Wordle.

What is the best two word strategy in Wordle? ›

Wordle's First Two Words Can Be A Powerful Combo

With the above letters, words like "raise" can be followed with "donut" to immediately find some of the more common letters that might be part of the answer. Some good Wordle combinations might be: RAISE and DONUT. ROATE and SLING.

Has anyone ever won Wordle on the first try? ›

3. More people solve Wordle on their first guess than can be explained by chance. In the list above, we excluded first guesses that were that day's Wordle solution. That's because, about one game in every 250, a reader gets the answer right on the first try.

What is the hardest word to figure out in Wordle? ›

PARER (Wordle #454)

PARER was introduced as a Wordle solution on September 16, 2022. Almost one in two players fail to solve this word as it has a 48% failure rate. Furthermore, it broke 60% of World streaks on the day of its release.

What is a burner word in Wordle? ›

As I mentioned above, a burner word is a word you guess in Wordle (that you know is not the right answer) that you use to eliminate, or guess, several letters at a time.

What is an impressive number of guesses to get the word in Wordle? ›

If you can consistently get Wordle in three guesses, you are pretty darn good. A score of three is solidly above average, and it is certainly nothing to frown at. Especially with harder words such as “cynic,” “vivid,” or “swill,” getting it in three is very good. Three takes skill, finesse, and intellect.

What is the most common answer in Wordle? ›

Over 15% of Wordle's words of the day start with S. Only six other starting letters appear in more than 5% of Wordle words. In order of frequency, they are C, B, T, P, A, and F. These starting letters might seem pretty surprising, but they are close to the order of general five-letter words.

Does Wordle use plurals? ›

Do Wordles ever have plural nouns? No. There are no plural nouns in the answer list.

Is there an algorithm to Wordle? ›

Through a modeling method known as Exact Dynamic Programming, the researchers devised an algorithm that solves the game in the optimal manner without fail. In Wordle, players have six tries to guess a five-letter word.

What is the most popular word used in Wordle? ›

Most common Wordle starting words

ADIEU — ADIEU was the most common response, with a total of 21 submissions. We think this is a smart word to use, as it contains nearly all of the vowels, except O, allowing you to quickly assess which vowels are or aren't in the final word.

What is the very first Wordle word? ›

When did Wordle start? Wordle started as a humble independent game played only among friends and family of developer Josh Wardle in June 2021 (the first answer was "Cigar").

What is the first guess strategy in Wordle? ›

For those who want to find vowels in their first guess, we recommend you use words such as AUDIO and ADIEU, which contain four vowels and one consonant each. If you want to drop one vowel in favor of another common consonant, you could use the word ALIEN.

What are the words to win Wordle every time? ›

The Best Starting Words for Wordle
  • adieu.
  • odium.
  • shade.
  • resin.
  • alert.
  • haunt.
  • orate.
  • media.

What is the best 5 letter word for Wordle? ›

How to crack Wordle: 5-letter words to use first
  • FRAME, GRAZE, WINDY, PAINT, GOURD, SWING, VAPES. I aim for a mix of common and uncommon letters in my first guess(es). ...
  • AUDIO, FARTS. ...
  • ADIEU, OUIJA. ...
  • READY, PEARS, CHIEF, TOUCH. ...
  • ARISE. ...
  • ROAST, TEARS, MEATS, OUIJA, PIZZA. ...
  • POETS, EARLY, STEAM, BOILS, SPOUT, COUNT, WOUND, STEAK. ...
  • N/A.
Jan 14, 2022

How quickly does the average person solve Wordle? ›

Most people should, on average, get it in at least 4, even on days where it is harder. Especially if you aren't making risky moves, four guesses should supply you with enough information to make a correct guess.

What 5 words use all 25 letters? ›

Find 5 letter words with 25 distinct characters
  • brick.
  • glent.
  • jumpy.
  • vozhd.
  • waqfs.
Feb 6, 2022

Top Articles
Latest Posts
Article information

Author: Edmund Hettinger DC

Last Updated:

Views: 6177

Rating: 4.8 / 5 (58 voted)

Reviews: 89% of readers found this page helpful

Author information

Name: Edmund Hettinger DC

Birthday: 1994-08-17

Address: 2033 Gerhold Pine, Port Jocelyn, VA 12101-5654

Phone: +8524399971620

Job: Central Manufacturing Supervisor

Hobby: Jogging, Metalworking, Tai chi, Shopping, Puzzles, Rock climbing, Crocheting

Introduction: My name is Edmund Hettinger DC, I am a adventurous, colorful, gifted, determined, precious, open, colorful person who loves writing and wants to share my knowledge and understanding with you.