Sha256: c5ae327f444ed0d811aabf941cd54a97255806826ef76dca2f55c1ae5d024654

Contents?: true

Size: 460 Bytes

Versions: 96

Compression:

Stored size: 460 Bytes

Contents

#!/usr/bin/env bash

function usage() {
	echo "Usage: raindrops <number>" >&2
	exit 1
}

# check argument is present
if [ ! "$#" -eq 1 ]; then
  usage
fi

# check param is an integer
if ! [[ $1 =~ ^[0-9]+$ ]]; then
  usage
fi

output=""

if [ $(($1 % 3)) -eq 0 ]; then
	output="Pling"
fi

if [ $(($1 % 5)) -eq 0 ]; then
	output=$output"Plang"
fi

if [ $(($1 % 7)) -eq 0 ]; then
	output=$output"Plong"
fi

if [ -z $output ]; then
	echo $1
else
	echo $output
fi

Version data entries

96 entries across 96 versions & 1 rubygems

Version Path
trackler-2.2.1.180 tracks/bash/exercises/raindrops/example.sh
trackler-2.2.1.179 tracks/bash/exercises/raindrops/example.sh
trackler-2.2.1.178 tracks/bash/exercises/raindrops/example.sh
trackler-2.2.1.177 tracks/bash/exercises/raindrops/example.sh
trackler-2.2.1.176 tracks/bash/exercises/raindrops/example.sh
trackler-2.2.1.175 tracks/bash/exercises/raindrops/example.sh
trackler-2.2.1.174 tracks/bash/exercises/raindrops/example.sh
trackler-2.2.1.173 tracks/bash/exercises/raindrops/example.sh
trackler-2.2.1.172 tracks/bash/exercises/raindrops/example.sh
trackler-2.2.1.171 tracks/bash/exercises/raindrops/example.sh
trackler-2.2.1.170 tracks/bash/exercises/raindrops/example.sh
trackler-2.2.1.169 tracks/bash/exercises/raindrops/example.sh
trackler-2.2.1.167 tracks/bash/exercises/raindrops/example.sh
trackler-2.2.1.166 tracks/bash/exercises/raindrops/example.sh
trackler-2.2.1.165 tracks/bash/exercises/raindrops/example.sh
trackler-2.2.1.164 tracks/bash/exercises/raindrops/example.sh
trackler-2.2.1.163 tracks/bash/exercises/raindrops/example.sh
trackler-2.2.1.162 tracks/bash/exercises/raindrops/example.sh
trackler-2.2.1.161 tracks/bash/exercises/raindrops/example.sh
trackler-2.2.1.160 tracks/bash/exercises/raindrops/example.sh