<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://charlesreid1.com/w/index.php?action=history&amp;feed=atom&amp;title=Project_Euler%2F42</id>
	<title>Project Euler/42 - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://charlesreid1.com/w/index.php?action=history&amp;feed=atom&amp;title=Project_Euler%2F42"/>
	<link rel="alternate" type="text/html" href="https://charlesreid1.com/w/index.php?title=Project_Euler/42&amp;action=history"/>
	<updated>2026-06-18T23:19:02Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.39.12</generator>
	<entry>
		<id>https://charlesreid1.com/w/index.php?title=Project_Euler/42&amp;diff=30591&amp;oldid=prev</id>
		<title>Admin: Add Problem 42 page with problem statement, solution approach, and code link (via create-page on MediaWiki MCP Server)</title>
		<link rel="alternate" type="text/html" href="https://charlesreid1.com/w/index.php?title=Project_Euler/42&amp;diff=30591&amp;oldid=prev"/>
		<updated>2026-06-16T14:12:31Z</updated>

		<summary type="html">&lt;p&gt;Add Problem 42 page with problem statement, solution approach, and code link (via create-page on MediaWiki MCP Server)&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==Problem Statement==&lt;br /&gt;
&lt;br /&gt;
The nth term of the sequence of triangle numbers is given by:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
t_n = \frac{1}{2} n (n + 1)&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The first ten triangle numbers are:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
1, 3, 6, 10, 15, 21, 28, 36, 45, 55, \dots&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
By converting each letter in a word to a number corresponding to its alphabetical position (A=1, B=2, ..., Z=26) and adding these values we form a word value. For example, the word value for SKY is 19 + 11 + 25 = 55 = t_{10}. If the word value is a triangle number, then the word is called a triangle word.&lt;br /&gt;
&lt;br /&gt;
Using words.txt, a 16K text file containing nearly two-thousand common English words, find the number of triangle words.&lt;br /&gt;
&lt;br /&gt;
==Approach==&lt;br /&gt;
&lt;br /&gt;
===Pre-compute Triangle Numbers===&lt;br /&gt;
&lt;br /&gt;
Generate all triangle numbers up to a sufficient bound. The longest word in the file yields a word value well under 5,000, so pre-computing triangle numbers for n = 1 to 100 (giving t_{100} = 5050) is more than adequate. Store these in a HashSet for O(1) lookup.&lt;br /&gt;
&lt;br /&gt;
===Parse the Word File===&lt;br /&gt;
&lt;br /&gt;
The file words.txt contains comma-separated, double-quoted words (e.g., &amp;quot;A&amp;quot;,&amp;quot;ABILITY&amp;quot;,&amp;quot;ABLE&amp;quot;,...). Split on commas, strip the surrounding quotes, and trim whitespace.&lt;br /&gt;
&lt;br /&gt;
===Compute Word Values===&lt;br /&gt;
&lt;br /&gt;
For each word:&lt;br /&gt;
* Convert to uppercase&lt;br /&gt;
* Iterate over each character, computing its value as (c - &amp;#039;A&amp;#039; + 1)&lt;br /&gt;
* Sum all character values to obtain the word value&lt;br /&gt;
&lt;br /&gt;
===Check Against Triangle Numbers===&lt;br /&gt;
&lt;br /&gt;
If the word value is contained in the pre-computed set of triangle numbers, increment the count.&lt;br /&gt;
&lt;br /&gt;
===Return the Count===&lt;br /&gt;
&lt;br /&gt;
After processing all words, return the total count of triangle words.&lt;br /&gt;
&lt;br /&gt;
==Solution==&lt;br /&gt;
&lt;br /&gt;
Link: https://git.charlesreid1.com/cs/euler/src/branch/main/java/Problem042.java&lt;br /&gt;
&lt;br /&gt;
==Flags==&lt;br /&gt;
&lt;br /&gt;
{{ProjectEulerFlag}}&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
	</entry>
</feed>