<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>CodeAdventures &#8211; Set Side B</title>
	<atom:link href="https://setsideb.com/tag/codeadventures/feed/" rel="self" type="application/rss+xml" />
	<link>https://setsideb.com</link>
	<description>The Flipside of Gaming</description>
	<lastBuildDate>Thu, 26 Mar 2026 03:29:15 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://setsideb.com/wp-content/uploads/2022/04/cropped-mascot512-32x32.png</url>
	<title>CodeAdventures &#8211; Set Side B</title>
	<link>https://setsideb.com</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Code Adventures: fancypants, a Command-Line Text Conversion Utility</title>
		<link>https://setsideb.com/code-adventures-a-command-line-text-conversion-utility/</link>
					<comments>https://setsideb.com/code-adventures-a-command-line-text-conversion-utility/#respond</comments>
		
		<dc:creator><![CDATA[rodneylives]]></dc:creator>
		<pubDate>Thu, 26 Mar 2026 14:00:00 +0000</pubDate>
				<category><![CDATA[niche]]></category>
		<category><![CDATA[CodeAdventures]]></category>
		<category><![CDATA[CommandLine]]></category>
		<category><![CDATA[fancypants]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[unicode]]></category>
		<guid isPermaLink="false">https://setsideb.com/?p=11880</guid>

					<description><![CDATA[𝕋𝕙𝕚𝕤 𝕨𝕖𝕚𝕣𝕕 𝕥𝕖𝕩𝕥 𝕨𝕒𝕤 𝕔𝕠𝕟𝕤𝕥𝕣𝕦𝕔𝕥𝕖𝕕 𝕨𝕚𝕥𝕙 𝕥𝕙𝕖 𝕦𝕥𝕚𝕝𝕚𝕥𝕪 𝕞𝕖𝕟𝕥𝕚𝕠𝕟𝕖𝕕 𝕚𝕟 𝕥𝕙𝕖 𝕥𝕚𝕥𝕝𝕖. 𝓢𝓸 𝔀𝓪𝓼 𝓽𝓱𝓲𝓼 𝓽𝓮𝔁𝓽 𝓱𝓮𝓻𝓮. 𝗔𝗻𝗱 𝗮𝗹𝘀𝗼 𝘁𝗵𝗶𝘀. 𝕬𝖉𝖉𝖎𝖙𝖎𝖔𝖓𝖆𝖑𝖞, 𝖙𝖍𝖎𝖘. Can you read those? There&#8217;s a good chance you can! If you can&#8217;t (like if they all show up as hollow boxes) it&#8217;s because the font you&#8217;re reading this post in doesn&#8217;t support &#8230; <a href="https://setsideb.com/code-adventures-a-command-line-text-conversion-utility/" class="more-link">Continue reading<span class="screen-reader-text"> "Code Adventures: fancypants, a Command-Line Text Conversion Utility"</span></a>]]></description>
										<content:encoded><![CDATA[
<p>𝕋𝕙𝕚𝕤 𝕨𝕖𝕚𝕣𝕕 𝕥𝕖𝕩𝕥 𝕨𝕒𝕤 𝕔𝕠𝕟𝕤𝕥𝕣𝕦𝕔𝕥𝕖𝕕 𝕨𝕚𝕥𝕙 𝕥𝕙𝕖 𝕦𝕥𝕚𝕝𝕚𝕥𝕪 𝕞𝕖𝕟𝕥𝕚𝕠𝕟𝕖𝕕 𝕚𝕟 𝕥𝕙𝕖 𝕥𝕚𝕥𝕝𝕖. 𝓢𝓸 𝔀𝓪𝓼 𝓽𝓱𝓲𝓼 𝓽𝓮𝔁𝓽 𝓱𝓮𝓻𝓮. 𝗔𝗻𝗱 𝗮𝗹𝘀𝗼 𝘁𝗵𝗶𝘀. 𝕬𝖉𝖉𝖎𝖙𝖎𝖔𝖓𝖆𝖑𝖞, 𝖙𝖍𝖎𝖘.</p>



<p>Can you read those? There&#8217;s a good chance you can! If you can&#8217;t (like if they all show up as hollow boxes) it&#8217;s because the font you&#8217;re reading this post in doesn&#8217;t support those kinds of characters, which are from the math symbols section of the Unicode character set. </p>



<p>It&#8217;s a command-line version of a web Unicode text converter, of the sort found at <a href="https://qaz.wtf/u/convert.cgi">the other end of this link</a>. It&#8217;s written in Python, and the source is at the end of this post. I saved it to a file named &#8220;fancypants&#8221; and put it in my home directory&#8217;s bin directory (which you&#8217;ll probably have to make first), where  many Linux distributions are configured to look for things to execute if you type their names at the command prompt. (Yes, all of this assumes you&#8217;re running Linux. It&#8217;s not just for supergeeks anymore! If you&#8217;re running Windows you&#8217;ll have some adjustments to make, including figuring out how to add the script&#8217;s home to your path. It should work on Macs, although I don&#8217;t know if it&#8217;ll look in your home&#8217;s bin either.)</p>



<p>Oh, you will have to run a <strong>chmod +x fancypants</strong> on it. And the script as written assumes Python is at /usr/bin/python, where most distros will put it.</p>



<p>The script expects to be executed in the form:</p>



<pre class="wp-block-preformatted"><strong>fancypants [style] [text to convert]</strong></pre>



<p>The text should probably be in quotes if there&#8217;s any spaces in it, as should the style just in case. So to produce the first text mentioned at the start of the post, I entered:</p>



<pre class="wp-block-preformatted">fancypants "=" "This weird text was constructed with the utility mentioned in the title."</pre>



<p>Usable style specifiers are &#8220;=&#8221; for double-stroke, &#8220;/&#8221; for script, &#8220;!&#8221; for a boldface kind of thing, &#8220;f&#8221; for the medieval script-looking fractur, and a few others that you can pretty easily see in the source code below. In fact each specifier has some synonyms if the single-character versions are too obscure for you to remember. And hey, if you don&#8217;t like the names I gave them you can use your own! The moment you paste it into a text file, this all becomes yours to do with as you please. Think of it as the blog version of a type-in program from an 80s computer magazine.</p>



<p>As a bonus, the names &#8220;r&#8221;, &#8220;rot&#8221; or &#8220;rot13&#8221; will perform a ROT13 code on the letters, useful for encoding spoiler text that readers can decode at <a href="https://rot13.com/">ROT13.com</a>. There are utilities that you can use to send the generated text directly to the clipboard, for pasting wherever you want, but since those differ if you&#8217;re using X.org or Wayland for your display manager (or, sure, Windows or Mac) I&#8217;ll leave those for you to figure out.</p>



<p>And if you can&#8217;t read the characters above, then I&#8217;m sorry that you&#8217;re missing out on the fun. It&#8217;s all pretty whimsical really, it&#8217;s not some huge thing that you&#8217;re missing. Come back tomorrow, I&#8217;m sure we&#8217;ll have a post about Mario or somesuch.</p>



<pre class="wp-block-preformatted">#!/usr/bin/python<br>import sys<br><br>base = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890!@#$%^&amp;*()-_=+[]{};':\",./&lt;>?~"<br>equals = "𝔸𝔹ℂ𝔻𝔼𝔽𝔾ℍ𝕀𝕁𝕂𝕃𝕄ℕ𝕆ℙℚℝ𝕊𝕋𝕌𝕍𝕎𝕏𝕐ℤ𝕒𝕓𝕔𝕕𝕖𝕗𝕘𝕙𝕚𝕛𝕜𝕝𝕞𝕟𝕠𝕡𝕢𝕣𝕤𝕥𝕦𝕧𝕨𝕩𝕪𝕫𝟙𝟚𝟛𝟜𝟝𝟞𝟟𝟠𝟡𝟘!@#$%^&amp;*()-_=+[]{};':\",./&lt;>?~"<br>script = "𝓐𝓑𝓒𝓓𝓔𝓕𝓖𝓗𝓘𝓙𝓚𝓛𝓜𝓝𝓞𝓟𝓠𝓡𝓢𝓣𝓤𝓥𝓦𝓧𝓨𝓩𝓪𝓫𝓬𝓭𝓮𝓯𝓰𝓱𝓲𝓳𝓴𝓵𝓶𝓷𝓸𝓹𝓺𝓻𝓼𝓽𝓾𝓿𝔀𝔁𝔂𝔃1234567890!@#$%^&amp;*()-_=+[]{};':\",./&lt;>?~"<br>bold = "𝐀𝐁𝐂𝐃𝐄𝐅𝐆𝐇𝐈𝐉𝐊𝐋𝐌𝐍𝐎𝐏𝐐𝐑𝐒𝐓𝐔𝐕𝐖𝐗𝐘𝐙𝐚𝐛𝐜𝐝𝐞𝐟𝐠𝐡𝐢𝐣𝐤𝐥𝐦𝐧𝐨𝐩𝐪𝐫𝐬𝐭𝐮𝐯𝐰𝐱𝐲𝐳𝟏𝟐𝟑𝟒𝟓𝟔𝟕𝟖𝟗𝟎!@#$%^&amp;*()-_=+[]{};':\",./&lt;>?~"<br>bolditalic = "𝑨𝑩𝑪𝑫𝑬𝑭𝑮𝑯𝑰𝑱𝑲𝑳𝑴𝑵𝑶𝑷𝑸𝑹𝑺𝑻𝑼𝑽𝑾𝑿𝒀𝒁𝒂𝒃𝒄𝒅𝒆𝒇𝒈𝒉𝒊𝒋𝒌𝒍𝒎𝒏𝒐𝒑𝒒𝒓𝒔𝒕𝒖𝒗𝒘𝒙𝒚𝒛1234567890!@#$%^&amp;*()-_=+[]{};':\",./&lt;>?~"<br>monospace = "𝙰𝙱𝙲𝙳𝙴𝙵𝙶𝙷𝙸𝙹𝙺𝙻𝙼𝙽𝙾𝙿𝚀𝚁𝚂𝚃𝚄𝚅𝚆𝚇𝚈𝚉𝚊𝚋𝚌𝚍𝚎𝚏𝚐𝚑𝚒𝚓𝚔𝚕𝚖𝚗𝚘𝚙𝚚𝚛𝚜𝚝𝚞𝚟𝚠𝚡𝚢𝚣𝟷𝟸𝟹𝟺𝟻𝟼𝟽𝟾𝟿𝟶!@#$%^&amp;*()-_=+[]{};':\",./&lt;>?~"<br>block = "𝗔𝗕𝗖𝗗𝗘𝗙𝗚𝗛𝗜𝗝𝗞𝗟𝗠𝗡𝗢𝗣𝗤𝗥𝗦𝗧𝗨𝗩𝗪𝗫𝗬𝗭𝗮𝗯𝗰𝗱𝗲𝗳𝗴𝗵𝗶𝗷𝗸𝗹𝗺𝗻𝗼𝗽𝗾𝗿𝘀𝘁𝘂𝘃𝘄𝘅𝘆𝘇𝟭𝟮𝟯𝟰𝟱𝟲𝟳𝟴𝟵𝟬!@#$%^&amp;*()-_=+[]{};':\",./&lt;>?~"<br>fraktur = "𝕬𝕭𝕮𝕯𝕰𝕱𝕲𝕳𝕴𝕵𝕶𝕷𝕸𝕹𝕺𝕻𝕼𝕽𝕾𝕿𝖀𝖁𝖂𝖃𝖄𝖅𝖆𝖇𝖈𝖉𝖊𝖋𝖌𝖍𝖎𝖏𝖐𝖑𝖒𝖓𝖔𝖕𝖖𝖗𝖘𝖙𝖚𝖛𝖜𝖝𝖞𝖟1234567890!@#$%^&amp;*()-_=+[]{};':\",./&lt;>?~"<br>rot = "NOPQRSTUVWXYZABCDEFGHIJKLMnopqrstuvwxyzabcdefghijklm1234567890!@#$%^&amp;*()-_=+[]{};':\",./&lt;>?~"<br>tilde = len(equals)-1<br><br>def convert(convertchar, intext):<br>  outlist = []<br>  match convertchar:<br>    case "=" | "equal" | "equals":<br>      clist = equals<br>    case "/" | "slant" | "script":<br>      clist = script<br>    case "!" | "bold":<br>      clist = bold<br>    case "!/" | "bolditalic" | "boldital":<br>      clist = bolditalic<br>    case "m" | "mono" | "monospace":<br>      clist = monospace<br>    case "b" | "block" | "mathbold":<br>      clist = block<br>    case "f" | "fraktur":<br>      clist = fraktur<br>    case "r" | "rot" | "rot13":<br>      clist = rot<br>    case _:<br>      raise ValueError("Unknown charset " + convertchar)<br>      return intext<br>  for char in intext:<br>    try:<br>      index = base.index(char)<br>    except:<br>      outlist.append(char)<br>      continue<br>    outchr = clist[index]<br>    if outchr != "~":<br>      outlist.append(outchr)<br>    else:<br>      outlist.append(base[index])<br>  return "".join(outlist)<br><br>if __name__ == "__main__":<br>  convertchar = sys.argv[1]<br>  intext = sys.argv[2]<br>  print(convert(convertchar, intext))<br></pre>
<div class="saboxplugin-wrap" itemtype="http://schema.org/Person" itemscope itemprop="author"><div class="saboxplugin-tab"><div class="saboxplugin-gravatar"><img alt='rodneylives' src='https://secure.gravatar.com/avatar/cb688ada8b517e838b06bdbcddb8d1ea3dd56de2e66848938e8c6568002a4fa9?s=100&#038;d=mm&#038;r=g' srcset='https://secure.gravatar.com/avatar/cb688ada8b517e838b06bdbcddb8d1ea3dd56de2e66848938e8c6568002a4fa9?s=200&#038;d=mm&#038;r=g 2x' class='avatar avatar-100 photo' height='100' width='100' itemprop="image"/></div><div class="saboxplugin-authorname"><a href="https://setsideb.com/author/rodneylives/" class="vcard author" rel="author"><span class="fn">rodneylives</span></a></div><div class="saboxplugin-desc"><div itemprop="description"></div></div><div class="clearfix"></div><div class="saboxplugin-socials "><a title="Twitter" target="_self" href="https://twitter.com/rodneylives" rel="nofollow noopener" class="saboxplugin-icon-grey"><svg aria-hidden="true" class="sab-twitter" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 30 30"><path d="M26.37,26l-8.795-12.822l0.015,0.012L25.52,4h-2.65l-6.46,7.48L11.28,4H4.33l8.211,11.971L12.54,15.97L3.88,26h2.65 l7.182-8.322L19.42,26H26.37z M10.23,6l12.34,18h-2.1L8.12,6H10.23z" /></svg></span></a><a title="Instagram" target="_self" href="https://www.instagram.com/rodneysnotdead/" rel="nofollow noopener" class="saboxplugin-icon-grey"><svg aria-hidden="true" class="sab-instagram" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><path fill="currentColor" d="M224.1 141c-63.6 0-114.9 51.3-114.9 114.9s51.3 114.9 114.9 114.9S339 319.5 339 255.9 287.7 141 224.1 141zm0 189.6c-41.1 0-74.7-33.5-74.7-74.7s33.5-74.7 74.7-74.7 74.7 33.5 74.7 74.7-33.6 74.7-74.7 74.7zm146.4-194.3c0 14.9-12 26.8-26.8 26.8-14.9 0-26.8-12-26.8-26.8s12-26.8 26.8-26.8 26.8 12 26.8 26.8zm76.1 27.2c-1.7-35.9-9.9-67.7-36.2-93.9-26.2-26.2-58-34.4-93.9-36.2-37-2.1-147.9-2.1-184.9 0-35.8 1.7-67.6 9.9-93.9 36.1s-34.4 58-36.2 93.9c-2.1 37-2.1 147.9 0 184.9 1.7 35.9 9.9 67.7 36.2 93.9s58 34.4 93.9 36.2c37 2.1 147.9 2.1 184.9 0 35.9-1.7 67.7-9.9 93.9-36.2 26.2-26.2 34.4-58 36.2-93.9 2.1-37 2.1-147.8 0-184.8zM398.8 388c-7.8 19.6-22.9 34.7-42.6 42.6-29.5 11.7-99.5 9-132.1 9s-102.7 2.6-132.1-9c-19.6-7.8-34.7-22.9-42.6-42.6-11.7-29.5-9-99.5-9-132.1s-2.6-102.7 9-132.1c7.8-19.6 22.9-34.7 42.6-42.6 29.5-11.7 99.5-9 132.1-9s102.7-2.6 132.1 9c19.6 7.8 34.7 22.9 42.6 42.6 11.7 29.5 9 99.5 9 132.1s2.7 102.7-9 132.1z"></path></svg></span></a><a title="Html5" target="_self" href="https://www.metafilter.com/user/23306" rel="nofollow noopener" class="saboxplugin-icon-grey"><svg aria-hidden="true" class="sab-html5" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 384 512"><path fill="currentColor" d="M0 32l34.9 395.8L191.5 480l157.6-52.2L384 32H0zm308.2 127.9H124.4l4.1 49.4h175.6l-13.6 148.4-97.9 27v.3h-1.1l-98.7-27.3-6-75.8h47.7L138 320l53.5 14.5 53.7-14.5 6-62.2H84.3L71.5 112.2h241.1l-4.4 47.7z"></path></svg></span></a><a title="Mastodont" target="_self" href="https://cybre.space/@rodneylives" rel="nofollow noopener" class="saboxplugin-icon-grey"><svg aria-hidden="true" class="sab-mastodont" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 417 512"><path fill="currentColor" d="M417.8 179.1c0-97.2-63.7-125.7-63.7-125.7-62.5-28.7-228.5-28.4-290.4 0 0 0-63.7 28.5-63.7 125.7 0 115.7-6.6 259.4 105.6 289.1 40.5 10.7 75.3 13 103.3 11.4 50.8-2.8 79.3-18.1 79.3-18.1l-1.7-36.9s-36.3 11.4-77.1 10.1c-40.4-1.4-83-4.4-89.6-54-.6-4.4-.9-9-.9-13.9 85.6 20.9 158.6 9.1 178.7 6.7 56.1-6.7 105-41.3 111.2-72.9 9.8-49.8 9-121.5 9-121.5zm-75.1 125.2h-46.6V190.1c0-49.7-64-51.6-64 6.9v62.5h-46.3V197c0-58.5-64-56.6-64-6.9v114.2H75.1c0-122.1-5.2-147.9 18.4-175 25.9-28.9 79.8-30.8 103.8 6.1l11.6 19.5 11.6-19.5c24.1-37.1 78.1-34.8 103.8-6.1 23.7 27.3 18.4 53 18.4 175z"></path></svg></span></a></div></div></div>]]></content:encoded>
					
					<wfw:commentRss>https://setsideb.com/code-adventures-a-command-line-text-conversion-utility/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Code Adventures: Simulating One Handed Solitaire</title>
		<link>https://setsideb.com/code-adventures-simulating-one-handed-solitaire/</link>
					<comments>https://setsideb.com/code-adventures-simulating-one-handed-solitaire/#comments</comments>
		
		<dc:creator><![CDATA[rodneylives]]></dc:creator>
		<pubDate>Mon, 16 Mar 2026 14:00:00 +0000</pubDate>
				<category><![CDATA[niche]]></category>
		<category><![CDATA[cardgames]]></category>
		<category><![CDATA[ChurchHatesTucker]]></category>
		<category><![CDATA[CodeAdventures]]></category>
		<category><![CDATA[GatherTogetherGames]]></category>
		<category><![CDATA[OneHandedSolitaire]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[solitaire]]></category>
		<guid isPermaLink="false">https://setsideb.com/?p=11812</guid>

					<description><![CDATA[My style in titling these things is to just present the subject on whatever it is I&#8217;m linking to in the title, so you might expect that this is about someone else doing that and me reporting on it. But no! This time it&#8217;s something I did myself! First, you have to know of a &#8230; <a href="https://setsideb.com/code-adventures-simulating-one-handed-solitaire/" class="more-link">Continue reading<span class="screen-reader-text"> "Code Adventures: Simulating One Handed Solitaire"</span></a>]]></description>
										<content:encoded><![CDATA[
<p>My style in titling these things is to just present the subject on whatever it is I&#8217;m linking to in the title, so you might expect that this is about someone else doing that and me reporting on it. But no! This time it&#8217;s something I did myself!</p>



<p>First, you have to know of a card game called One Handed Solitaire, <a href="https://www.metafilter.com/212541/More-productive-than-doomscrolling">as reported by Metafilter member ChurchHatesTucker here</a>. CHT&#8217;s been on a tear in presenting various card games lately, here&#8217;s the other recent posts they&#8217;ve made on solitaire card games, with a dungeon crawl flavor: <a href="https://avatus.itch.io/clear-the-dungeon">Clear the Dungeon</a>, <a href="https://www.metafilter.com/212303/I--Tomb-Raiderlikes">Tomb of the Four Kings</a>, <a href="https://www.metafilter.com/212217/I--Roguelikes">Scoundrel</a>.</p>



<p>One Handed Solitaire is very simple, and an example of a &#8220;zero player game.&#8221; There are no decisions to make; winning or losing is completely down to the initial state of the deck. Here are the rules in text:</p>



<p>You start with a shuffled deck of cards. Draw four to form your hand. Your hand is considered to be in sequence, you must keep them in the order drawn. Now:</p>



<ul class="wp-block-list">
<li>If the first and fourth cards are the same suit, discard the second and third cards from your hand out of play. This of course moves the fourth card to be the second card.</li>



<li>If the first and fourth cards are the same rank, discard the first four cards from your hand.</li>



<li> If neither of these things are true, draw another card from the deck to the front of your hand. This makes a new first card, and changes which the fourth card is.</li>



<li>When the deck runs out and you can no longer remove cards, the game is over. If you clear your hand and there&#8217;s still cards in the deck you&#8217;re not done, draw four more.</li>
</ul>



<p>Your score (lower is better) is how many cards are in your hand when you run out of deck and can no longer discard cards. The average score is about 13.32 cards left. If you get a score of zero, that is you discard all of the cards from your hand and the deck is empty, you win.</p>



<p><a href="https://www.youtube.com/watch?v=jayssGEYyq4">Here are the rules demonstrated by Gather Together Games</a> in a Youtube video (1¾ minutes):</p>



<figure class="wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio"><div class="wp-block-embed__wrapper">
<iframe title="How To Play One Handed Solitaire" width="840" height="473" src="https://www.youtube.com/embed/jayssGEYyq4?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>
</div></figure>



<p>ChurchHatesTucker ran a simulation of 200,000 runs and found the win rate of the game is close to 0.7%. I ran my own simulation, in a Python script, and found that out as well. I&#8217;ll put my code at the end of this post. <em>No AI was used in its writing</em>, and <em>permission is not given to use it to train AIs</em>. In fact, that&#8217;s true of all the text in this blog.</p>



<p>My first attempt found a win rate of 0.94%, but that turns out to be because I left out the aces from the deck! I tried a run with only 20 cards in the deck the 2-6 of each suit, and the win rate became about 7.5%.</p>



<p>If you want to try yourself, here&#8217;s the Python code I used. If you have Python installed, just paste it into a text file, give it the extension .py, and run it. It assumes you&#8217;re running it in a Linux or other Unix-like system; if you&#8217;re on Windows, you might have to change the &#8220;shebang&#8221; line at the front to point to where your Python is.</p>



<pre class="wp-block-preformatted">#!/usr/bin/python<br>import random<br><br>def draw(deck):<br>    if len(deck) > 0:<br>        return deck.pop(0)<br>    else:<br>        return None<br><br>def gameend(deck, hand, verbose):<br>    score = len(hand)<br>    if verbose >= 1:<br>        print("Deck exhaused. Final score:",score)<br>        if score == 0:<br>            print("Win!")<br>    if verbose >= 2:<br>        print("Deck state:",deck)<br>        print("Hand state:",hand)<br>    return score<br><br>def play(verbose = 0):<br>    deck = ["2H","3H","4H","5H","6H","7H","8H","9H","TH","JH","QH","KH","AH",<br>            "2D","3D","4D","5D","6D","7D","8D","9D","TD","JD","QD","KD","AD",<br>            "2C","3C","4C","5C","6C","7C","8C","9C","TC","JC","QC","KC","AC",<br>            "2S","3S","4S","5S","6S","7S","8S","9S","TS","JS","QS","KS","AS"]<br>    hand = []<br>    random.shuffle(deck)<br>    for a in range(4):<br>        hand.append(draw(deck))<br>    if verbose >= 3:<br>        print("Game starting--")<br>    while True:<br>        if len(hand) &lt; 4:<br>            drawcard = draw(deck)<br>            if drawcard == None:<br>                return gameend(deck, hand, verbose)<br>            if verbose >= 2:<br>                print("Drew a",drawcard)<br>            hand.insert(0, drawcard)<br>            continue<br>        cardtop = hand[0]<br>        cardfourth = hand[3]<br>        if verbose >= 3:<br>            print("********: Deck length:",len(deck), "Hand length:",len(hand))<br>        if verbose >= 2:<br>            print("CARDS:", cardtop, cardfourth)<br>        # case 1: if the 1st and 4th cards match suit, discard the second and third cards<br>        if cardtop[1] == cardfourth[1]:<br>            d1 = hand.pop(1)<br>            d2 = hand.pop(1)<br>            if verbose >= 2:<br>                print("Discarded",d1,"and",d2)<br>            continue<br>        # case 2: if the 1st and 4th cards match rank, discard the top four<br>        if cardtop[0] == cardfourth[0]:<br>            d1 = hand.pop(0)<br>            d2 = hand.pop(0)<br>            d3 = hand.pop(0)<br>            d4 = hand.pop(0)<br>            if verbose >= 2:<br>                print("Discarded:",d1,d2,d3,d4)<br>            continue<br>        # case 3: if neither is true, draw a card<br>        drawcard = draw(deck)<br>        if drawcard == None:<br>            return gameend(deck, hand, verbose)<br>        else:<br>            if verbose >= 2:<br>                print("Drew a card")<br>            hand.insert(0, drawcard)<br>        # end of loop<br><br>if __name__ == "__main__":<br>    numgames = 10000000<br>    wins = 0<br>    scores = []<br>    scoresum = 0<br>    for count in range(numgames):<br>        score = play(verbose = 0)<br>        scores.append(score)<br>        scoresum += score<br>        if score == 0:<br>            wins += 1<br>            #print("A win on game #",count+1)<br>        if count % 500000 == 0:<br>            print("Played",count,"games...")<br>    print("Finished playing",numgames,"games")<br>    print("Wins:",wins)<br>    print("Win rate:",wins/numgames)<br>    print("Total score:",scoresum)<br>    print("Average score:",scoresum/numgames)<br>    print("Run compete.")<br></pre>
<div class="saboxplugin-wrap" itemtype="http://schema.org/Person" itemscope itemprop="author"><div class="saboxplugin-tab"><div class="saboxplugin-gravatar"><img alt='rodneylives' src='https://secure.gravatar.com/avatar/cb688ada8b517e838b06bdbcddb8d1ea3dd56de2e66848938e8c6568002a4fa9?s=100&#038;d=mm&#038;r=g' srcset='https://secure.gravatar.com/avatar/cb688ada8b517e838b06bdbcddb8d1ea3dd56de2e66848938e8c6568002a4fa9?s=200&#038;d=mm&#038;r=g 2x' class='avatar avatar-100 photo' height='100' width='100' itemprop="image"/></div><div class="saboxplugin-authorname"><a href="https://setsideb.com/author/rodneylives/" class="vcard author" rel="author"><span class="fn">rodneylives</span></a></div><div class="saboxplugin-desc"><div itemprop="description"></div></div><div class="clearfix"></div><div class="saboxplugin-socials "><a title="Twitter" target="_self" href="https://twitter.com/rodneylives" rel="nofollow noopener" class="saboxplugin-icon-grey"><svg aria-hidden="true" class="sab-twitter" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 30 30"><path d="M26.37,26l-8.795-12.822l0.015,0.012L25.52,4h-2.65l-6.46,7.48L11.28,4H4.33l8.211,11.971L12.54,15.97L3.88,26h2.65 l7.182-8.322L19.42,26H26.37z M10.23,6l12.34,18h-2.1L8.12,6H10.23z" /></svg></span></a><a title="Instagram" target="_self" href="https://www.instagram.com/rodneysnotdead/" rel="nofollow noopener" class="saboxplugin-icon-grey"><svg aria-hidden="true" class="sab-instagram" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><path fill="currentColor" d="M224.1 141c-63.6 0-114.9 51.3-114.9 114.9s51.3 114.9 114.9 114.9S339 319.5 339 255.9 287.7 141 224.1 141zm0 189.6c-41.1 0-74.7-33.5-74.7-74.7s33.5-74.7 74.7-74.7 74.7 33.5 74.7 74.7-33.6 74.7-74.7 74.7zm146.4-194.3c0 14.9-12 26.8-26.8 26.8-14.9 0-26.8-12-26.8-26.8s12-26.8 26.8-26.8 26.8 12 26.8 26.8zm76.1 27.2c-1.7-35.9-9.9-67.7-36.2-93.9-26.2-26.2-58-34.4-93.9-36.2-37-2.1-147.9-2.1-184.9 0-35.8 1.7-67.6 9.9-93.9 36.1s-34.4 58-36.2 93.9c-2.1 37-2.1 147.9 0 184.9 1.7 35.9 9.9 67.7 36.2 93.9s58 34.4 93.9 36.2c37 2.1 147.9 2.1 184.9 0 35.9-1.7 67.7-9.9 93.9-36.2 26.2-26.2 34.4-58 36.2-93.9 2.1-37 2.1-147.8 0-184.8zM398.8 388c-7.8 19.6-22.9 34.7-42.6 42.6-29.5 11.7-99.5 9-132.1 9s-102.7 2.6-132.1-9c-19.6-7.8-34.7-22.9-42.6-42.6-11.7-29.5-9-99.5-9-132.1s-2.6-102.7 9-132.1c7.8-19.6 22.9-34.7 42.6-42.6 29.5-11.7 99.5-9 132.1-9s102.7-2.6 132.1 9c19.6 7.8 34.7 22.9 42.6 42.6 11.7 29.5 9 99.5 9 132.1s2.7 102.7-9 132.1z"></path></svg></span></a><a title="Html5" target="_self" href="https://www.metafilter.com/user/23306" rel="nofollow noopener" class="saboxplugin-icon-grey"><svg aria-hidden="true" class="sab-html5" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 384 512"><path fill="currentColor" d="M0 32l34.9 395.8L191.5 480l157.6-52.2L384 32H0zm308.2 127.9H124.4l4.1 49.4h175.6l-13.6 148.4-97.9 27v.3h-1.1l-98.7-27.3-6-75.8h47.7L138 320l53.5 14.5 53.7-14.5 6-62.2H84.3L71.5 112.2h241.1l-4.4 47.7z"></path></svg></span></a><a title="Mastodont" target="_self" href="https://cybre.space/@rodneylives" rel="nofollow noopener" class="saboxplugin-icon-grey"><svg aria-hidden="true" class="sab-mastodont" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 417 512"><path fill="currentColor" d="M417.8 179.1c0-97.2-63.7-125.7-63.7-125.7-62.5-28.7-228.5-28.4-290.4 0 0 0-63.7 28.5-63.7 125.7 0 115.7-6.6 259.4 105.6 289.1 40.5 10.7 75.3 13 103.3 11.4 50.8-2.8 79.3-18.1 79.3-18.1l-1.7-36.9s-36.3 11.4-77.1 10.1c-40.4-1.4-83-4.4-89.6-54-.6-4.4-.9-9-.9-13.9 85.6 20.9 158.6 9.1 178.7 6.7 56.1-6.7 105-41.3 111.2-72.9 9.8-49.8 9-121.5 9-121.5zm-75.1 125.2h-46.6V190.1c0-49.7-64-51.6-64 6.9v62.5h-46.3V197c0-58.5-64-56.6-64-6.9v114.2H75.1c0-122.1-5.2-147.9 18.4-175 25.9-28.9 79.8-30.8 103.8 6.1l11.6 19.5 11.6-19.5c24.1-37.1 78.1-34.8 103.8-6.1 23.7 27.3 18.4 53 18.4 175z"></path></svg></span></a></div></div></div>]]></content:encoded>
					
					<wfw:commentRss>https://setsideb.com/code-adventures-simulating-one-handed-solitaire/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
			</item>
	</channel>
</rss>
