Skip to content

Commit

Permalink
New test/remainder, use modulo operation
Browse files Browse the repository at this point in the history
  • Loading branch information
alvarezp committed Nov 1, 2013
1 parent 9af1f5b commit 6912434
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 1 deletion.
2 changes: 1 addition & 1 deletion GNUmakefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CHALLENGES := execute hello twoplustwo firstarg firstarg-int square
CHALLENGES := execute hello twoplustwo firstarg firstarg-int square remainder

COMPLETION := $(CHALLENGES:%=done/%.done)

Expand Down
5 changes: 5 additions & 0 deletions solutions-python/remainder.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env python

import sys

print int(sys.argv[1]) % 10
35 changes: 35 additions & 0 deletions test/remainder
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/bash

ME=$(basename "$0")

if [ "$1" == "--help" ]; then
echo "Create a program that extracts and prints the last digit of a"
echo "given number. The number will be provided as the first argument"
echo "of the program."
echo
echo "For example, if the program is called like:"
echo " $ME 256"
echo "the program should print:"
echo " 6"
exit 0
fi

RESULT=$(run/"$ME" 289)

if [ "$RESULT" != "9" ]; then
exit 1
fi

RESULT=$(run/"$ME" 1512)

if [ "$RESULT" != "2" ]; then
exit 1
fi

RESULT=$(run/"$ME" 3)

if [ "$RESULT" != "3" ]; then
exit 1
fi

touch done/"$ME".done

0 comments on commit 6912434

Please sign in to comment.