Difference between revisions of "XMMS"

From Embedded Xinu
Jump to navigation Jump to search
(Added reference image and M&M counting program)
 
(4 intermediate revisions by 2 users not shown)
Line 1: Line 1:
[[Image:XMMS-02-13-2008a.jpg|thumb|400px|left|Our current record for fullness of the M&M jug.]]
+
[[Image:Mms_full_02.jpg|thumb|400px|left|A full M&M jug.]]
 
+
[[Image:XMMS-02-13-2008b.jpg|thumb|400px|left|The M&M jug from a more dramatic angle.]]
 
M&M's are small candy coated milk chocolate delights that come in a rainbow of colors and several variations.  The XINU Lab maintains a supply of these colorful treats so that members of the lab can make it through the hard days and long nights of XINU development.
 
M&M's are small candy coated milk chocolate delights that come in a rainbow of colors and several variations.  The XINU Lab maintains a supply of these colorful treats so that members of the lab can make it through the hard days and long nights of XINU development.
  
[[Image:XMMS-02-13-2008b.jpg|thumb|300px|center|The M&M jug from a more dramatic angle.]]
+
[[Image:145ozmm.jpg|thumb|200px|center|Reference shot for 3-45 oz bags of M&Ms in the jug.]]
[[Image:145ozmm.jpg|thumb|300px|center|Reference shot for 3-45 oz bags of M&Ms in the jug.]]
+
[[Image:Mms_full_01.jpg|thumb|300px|center|Reference shot for 4.5-56 oz bags of M&Ms in the jug.]]
  
 
== Number of M&Ms in the jug ==
 
== Number of M&Ms in the jug ==
Line 13: Line 13:
 
Perhaps someone should port this to work with the [[XINU]] code base.
 
Perhaps someone should port this to work with the [[XINU]] code base.
  
#include <stdio.h>
+
<source lang="c">
#include <stdlib.h>
+
#include <stdio.h>
+
#include <stdlib.h>
void usage(char *prog);
+
 
+
void usage(char *prog);
int main(int argc, char **argv)
+
 
{
+
int main(int argc, char **argv)
        int oz, mm;
+
{
+
    int oz, mm;
        if (argc != 2)
+
 
        { usage(argv[0]); }
+
    if (argc != 2)
+
    {
        oz = atoi(argv[1]);
+
        usage(argv[0]);
+
    }
        /* empirical evidence shows 500 M&Ms per pound */
+
 
        mm = 500 * (oz / 16);
+
    oz = atoi(argv[1]);
+
 
        /* catch the remaining oz */
+
    /* empirical evidence shows 500 M&Ms per pound */
        mm += (31 * (oz % 16));
+
    mm = 500 * (oz / 16);
+
 
        /* technically it is 31.25 M&Ms per ounce */
+
    /* catch the remaining oz */
        /* so add 1 M&M for every 4 ounces */
+
    mm += (31 * (oz % 16));
        mm += ((oz % 16) / 4);
+
 
+
    /* technically it is 31.25 M&Ms per ounce */
        printf("There are approximately %d M&Ms in %d ounces.\n", mm, oz);
+
    /* so add 1 M&M for every 4 ounces */
+
    mm += ((oz % 16) / 4);
        return 0;
+
 
}
+
    printf("There are approximately %d M&Ms in %d ounces.\n", mm, oz);
+
 
void usage(char *prog)
+
    return 0;
{
+
}
        fprintf(stderr, "Usage: %s oz\n", prog);
+
 
        fprintf(stderr, "  Calculate the number of M&Ms in oz ounces.\n");
+
void usage(char *prog)
        exit(1);
+
{
}
+
    fprintf(stderr, "Usage: %s oz\n", prog);
 +
    fprintf(stderr, "  Calculate the number of M&Ms in oz ounces.\n");
 +
    exit(1);
 +
}
 +
</source>

Latest revision as of 22:35, 28 September 2011

A full M&M jug.
The M&M jug from a more dramatic angle.

M&M's are small candy coated milk chocolate delights that come in a rainbow of colors and several variations. The XINU Lab maintains a supply of these colorful treats so that members of the lab can make it through the hard days and long nights of XINU development.

Reference shot for 3-45 oz bags of M&Ms in the jug.
Reference shot for 4.5-56 oz bags of M&Ms in the jug.

Number of M&Ms in the jug

After filling the M&M jug about halfway full, I wondered about how many M&Ms it held. A little investigation and I developed this program to provide the number of M&Ms given <math>n</math> ounces.

mm.c

Perhaps someone should port this to work with the XINU code base.

#include <stdio.h>
#include <stdlib.h>

void usage(char *prog);

int main(int argc, char **argv)
{
    int oz, mm;

    if (argc != 2)
    {
        usage(argv[0]);
    }

    oz = atoi(argv[1]);

    /* empirical evidence shows 500 M&Ms per pound */
    mm = 500 * (oz / 16);

    /* catch the remaining oz */
    mm += (31 * (oz % 16));

    /* technically it is 31.25 M&Ms per ounce */
    /* so add 1 M&M for every 4 ounces */
    mm += ((oz % 16) / 4);

    printf("There are approximately %d M&Ms in %d ounces.\n", mm, oz);

    return 0;
}

void usage(char *prog)
{
    fprintf(stderr, "Usage: %s oz\n", prog);
    fprintf(stderr, "  Calculate the number of M&Ms in oz ounces.\n");
    exit(1);
}