While it wasn't hard to optimize enough for the lights by just messing with the loop ordering and ensuring the loop counter (A) is less than the addend (B), I did something different for the TIS-100 multiplication challenge: a binary shift/add multiplier, like most CPUs use, but adapted to the limitations of the TIS-100 CPU. repeated addition loop: add B to X A times. get and save parameters, skipping everything if either is 0 Then output the resulting sum.Ī sample solution (not optimal in either way also untested and may not work): Then loop by the first #'s times (skipping if either value was 0), adding the second to the result each time around the loop instead of outputting the current counter as in the previous exercise. ![]() Store the first number in a spot to use as a counter (I use the new label facility to label this A), store the second somewhere else (I label this B), and store the result in a third tile (I label this X), copying 0 (tile 9, which I label 0) to it first to initialize. The Countdown exercise, #19, shows how to use a value as a counter to control a loop. The solutions I saw online didn't make a shred of sense to me. Yogsloth: There's no way to identify what number is on a tile, so I have no idea how to use it as a counter. XGekhRjN2RbRszEkqmobSK9scdP+3SXpu9XLrZdOqdxSuaIqoOhH3ZuslY0388Vaiqbxtm9cvq/Teml6į/gkiUnGrYsmna9dO82/c+mCDfvaFy07w0AEeLR8wz7HFUYr05ZZz5g9T7T22SzvMuFp3mUWUzZU/pt4 TqlmLjmguHF5n3TLCqARDHsctlTetHs547zj/WUpboVrxQPOruYN3ricJez63Njw1ok6EW4NiiHhkxRD GqkgflRtQFFU7atGo2rmLUbVwndBYlZrpIMjN+Z6MO3TM99/ZIfJp4s7TLwvl1tJXZntHn/lX+rVyxHVĪy8e7f54SmPV5aNyOzjXnrq5YfXTu8d3WVyuOvL+/M47sucfPYX4bxSMguEOAHj3evc ĮJwzZGBguKpZqVyjwaQYqsakuEbhvepl6WDdD5I7TD5IegS1yM2Kq9G4mT9Bk79CSout7aDGgqn31BQW HLnkb7WnJSh+U1Dw/WUng65uqfS7e+WH19O7bo5B70D6J6ZkLmFPOXQBxFZJaqsC0fWFmydcqFkwdVXH GZC6TqvdM19bKCz8aup09Ktp5VmQ2A1znVQQvTXQaA6zP8vcp573l+1137XhnRvPXmP3nwd7PAqO5HkV TXuxHsS3P5GmoX1cMPHkCZa5IP7W468aT5540B98Mv82iK+58/KjoEOXHy250vCW/VbD24Tbd16DxGOOĮJxzZ2BgaBJ4r9okoGdeznO+1oaz4AgDWCxNw0Mk33C15P4QFmnTvFgZw82mUjx7PUSWneER9D53jHPZ USUR7ngHZNaKKv6KKZVbKo9WSDQerWidOKUyc8mUysqzILmblZctQPSlrtKM0DmlGSA224wgl4xpX4o/ Gq1NMWTB1F+BmUsKAs+u5g1+sb4wYteG/thpi4vid890TGid2JawsC40ka1tVmLVNoHEnwerY7ivtEbO ZFbnk+r5wk+tlzY8d52+/OXfGtfXWyq539uWV3xkz9/7cV82wygYBQMIAIrPsY8 ĮJwLZGBg4BF8LnNbMN/wtuC/1OMCN9qOC1TPv8Abch0oxZAqJCITK3NF8a78em0vpQZnLyWd1I8KbG0fįQrX3pWfuuu5TOzJ/VLLzqwSSrvUzWtxGaTHyIG/wsihpF7YOn33OSunoyAxLrt8QxA9K1GpOC6Ov0In I4mh6/XeZDnp/K0p1p62+IzO2dUJhlXbXKzSd29yTt89zSdsZaWf6/R9foktqb4BRWKeb4NT3LZ5f3d2ĨFS3cfAEmcMaKx3sFXt9rm58z8Z1Sff2Xk0JPaCaeW/vzlyx9WoFK+epFZRmnM1TjvmXeyGtNNe/c3fJġS0gfbztyjG87RNyfrbWdNi1fdxh1/Zi/aUutjbtHp3UXz1fY/j61kRWT1gT+XzS48RTUybk3JuaXXZvĦu6ZIL0W86JSLmx/kwViW61RcVVfbRY+d1Vd4aNVfyZvWK2wcMNqnr0gOc+j2jXBJyUaay71N5+5VlK/ħsbN/HU3JLPuX9dJ/X1OJ/XAaffMlhPHShYeK6mPOdY6seXEkUUfT4Wt3HbOed2ni2Lrd1zVWAUyp/OJ Well now I will go try to find an approach that doesn't take a whopping 40 steps, lol.ĮJxLZGBg4JWIlVcQStNg5I0xC+AKcolkX10Qyd5Wxc1l08fIe3b1D/6pu/YJzzt8R8LpKFA5wyNr6eAk After storing the larger one in a sum slot and the smaller in the counter slot it then bumps the counter and begins adding the larger into itself until the counter hits zero. It works by storing the first two numbers then subtracting the first from the second to see which is smaller. Needless to say I will have to try again to get the challenges complete but I thought my code was awesome or at least fun enough to share. At that point I became determined to make it work no matter how many commands but was hoping that the steps used would remain minimal which failed. ![]() ![]() As further steps net less, this is not sufficient.My first attempt and I had an idea for adding one number while counting with the other. An optimization on step size is to unroll the loops (b,d )like this:ĭoing this on both loops, one can get down to 196 steps. The above program satisfies the size challenge but misses the mark on the speed challenge (Size 29, 209 Steps). Finally, put the required numbers into the outbox: ![]() If the substraction is negative, switch over to 10 substraction / up-bumping. Now repeatedly substract 100 from that box and bump up the 100 counter box. Grab the inbox and copy it to a third box. Start by copying the 0 to two other boxes to count occurencies of 100 / 10.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |