<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Riddles on traviscj/blog</title>
    <link>https://traviscj.com/blog/tags/riddles/</link>
    <description>Recent content in Riddles on traviscj/blog</description>
    <generator>Hugo</generator>
    <language>en-us</language>
    <lastBuildDate>Mon, 13 Nov 2017 07:01:25 +0000</lastBuildDate>
    <atom:link href="https://traviscj.com/blog/tags/riddles/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>snack buying</title>
      <link>https://traviscj.com/blog/post/2017-11-13-snack-buying/</link>
      <pubDate>Mon, 13 Nov 2017 07:01:25 +0000</pubDate>
      <guid>https://traviscj.com/blog/post/2017-11-13-snack-buying/</guid>
      <description>&lt;p&gt;I got this text message from my father-in-law:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Ok. Soda 1.50&#xA;Chocolate bar 1.00&#xA;Gum 0.10&#xA;Jelly Bean .05&lt;/p&gt;&#xA;&lt;p&gt;Have to buy exactly 14 items and spend $10&lt;/p&gt;&#xA;&lt;p&gt;At least one of each.&lt;/p&gt;&#xA;&lt;p&gt;There are 4 diff combos. (Order: soda, chocolate, gum and jelly bean)&lt;/p&gt;&#xA;&lt;p&gt;Got 5-2-3-4&#xA;3-5-4-2&lt;/p&gt;&#xA;&lt;p&gt;Can’t get others. Any ideas?  :)&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;I whipped up this solution to check in python:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;#!/usr/bin/python3&#xA;# created_at: 2017-11-13 13:53:19 -0800&#xA;&#xA;def main():&#xA;    solutions = 0&#xA;    for si in range(1,7):&#xA;        for ci in range(1,11):&#xA;            for gi in range(1,101):&#xA;                for ji in range(1,201):&#xA;                    total = si*150 + ci*100 + gi*10 + ji*5&#xA;                    items = si + ci + gi + ji&#xA;                    if total == 1000 and items == 14:&#xA;                        print(si,ci,gi,ji, total, items)&#xA;                        solutions += 1&#xA;    print(solutions)&#xA;&#xA;if __name__ == &amp;quot;__main__&amp;quot;:&#xA;    main()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The core of this solution is the check&lt;/p&gt;</description>
    </item>
    <item>
      <title>some tips for project euler problems</title>
      <link>https://traviscj.com/blog/post/2013-01-26-some_tips_for_project_euler_problems/</link>
      <pubDate>Sat, 26 Jan 2013 00:00:00 +0000</pubDate>
      <guid>https://traviscj.com/blog/post/2013-01-26-some_tips_for_project_euler_problems/</guid>
      <description>&lt;p&gt;I wanted to make a list of a few tips on solving &lt;a href=&#34;http://projecteuler.net&#34;&gt;Project Euler&lt;/a&gt; problems that have been helpful for me while I solve them.&#xA;These are general principles, even though I do most of my Project Euler coding in Python.&lt;/p&gt;&#xA;&lt;p&gt;Without further ado:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;If the problem is asking for something concerning the number of digits, typically this indicates that the use of the $\log n$ function is warranted.&lt;/li&gt;&#xA;&lt;li&gt;If the problem is asking for the last few digits, modulo arithmetic might speed it up considerably.&lt;/li&gt;&#xA;&lt;li&gt;Some might consider this cheating, but looking up some small numbers in the &lt;a href=&#34;http://oeis.org/&#34;&gt;Online Encyclopedia of Integer Sequences&lt;/a&gt; is occasionally pretty helpful.&lt;/li&gt;&#xA;&lt;li&gt;Many problems boil down to: Find numbers with property $X$ and property $Y$. Two solutions are:&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Brute force: Try all numbers with tests of property $X$ and $Y$.&lt;/li&gt;&#xA;&lt;li&gt;Find numbers with property $X$ and filter by a test of property $Y$.&lt;/li&gt;&#xA;&lt;li&gt;Find numbers with property $Y$ and filter by a test of property $X$.&lt;/li&gt;&#xA;&lt;li&gt;Find the set of numbers with property $X$ and the set of numbers with property $Y$. Compute their intersection.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;I&amp;rsquo;ve found that it&amp;rsquo;s sometimes hard to predict which one will end up being the fastest.&#xA;It depends on the relative speed of the tests and the generators, and the frequency of finding numbers which have that property.&lt;/p&gt;</description>
    </item>
    <item>
      <title>a trig problem solved in MATLAB</title>
      <link>https://traviscj.com/blog/post/2012-02-01-a_trig_problem_solved_in_matlab/</link>
      <pubDate>Wed, 01 Feb 2012 00:00:00 +0000</pubDate>
      <guid>https://traviscj.com/blog/post/2012-02-01-a_trig_problem_solved_in_matlab/</guid>
      <description>&lt;p&gt;&lt;img src=&#34;http://i.imgur.com/yOswe.jpg&#34; alt=&#34;diagram&#34;&gt;&lt;/p&gt;&#xA;&lt;p&gt;I came across &lt;a href=&#34;http://www.reddit.com/r/matlab/comments/p4b4s/nothing_feels_as_good_as_getting_a_somewhat/&#34;&gt;this&lt;/a&gt; post. The basic idea is the guy wants to maximize $L_1+L_2$&#xA;constrained to this box, where $L_i$ is the length of beam $i$. It&amp;rsquo;s constrained&#xA;to be a 61 cmx61 cm box, but one beam must start from 10cm up from the bottom&#xA;right corner and the beams must meet at a point along the top of the box.&#xA;I added the further assumption that the other beam must end in the bottom left&#xA;corner.&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
