Skip to content

Instantly share code, notes, and snippets.

@lot224
Created September 7, 2012 23:19
Show Gist options
  • Save lot224/3670633 to your computer and use it in GitHub Desktop.
Save lot224/3670633 to your computer and use it in GitHub Desktop.
FizzBuzz in SASS3
/*
http://en.wikipedia.org/wiki/Bizz_buzz
*/
$count: 100 !default;
@mixin fizzbuzz(
$count
) {
@for $i from 1 through $count {
@if ($i % 3) + ($i % 5) == 0 {
@debug("FizzBuzz");
}
@else if $i % 3 == 0 {
@debug("Fizz");
}
@else if $i % 5 == 0 {
@debug("Buzz");
}
@else {
@debug($i);
}
}
}
/* RESULTS
_fizzbuzz.scss:24 DEBUG: 1
_fizzbuzz.scss:24 DEBUG: 2
_fizzbuzz.scss:16 DEBUG: Fizz
_fizzbuzz.scss:24 DEBUG: 4
_fizzbuzz.scss:20 DEBUG: Buzz
_fizzbuzz.scss:16 DEBUG: Fizz
_fizzbuzz.scss:24 DEBUG: 7
_fizzbuzz.scss:24 DEBUG: 8
_fizzbuzz.scss:16 DEBUG: Fizz
_fizzbuzz.scss:20 DEBUG: Buzz
_fizzbuzz.scss:24 DEBUG: 11
_fizzbuzz.scss:16 DEBUG: Fizz
_fizzbuzz.scss:24 DEBUG: 13
_fizzbuzz.scss:24 DEBUG: 14
_fizzbuzz.scss:12 DEBUG: FizzBuzz
_fizzbuzz.scss:24 DEBUG: 16
_fizzbuzz.scss:24 DEBUG: 17
_fizzbuzz.scss:16 DEBUG: Fizz
_fizzbuzz.scss:24 DEBUG: 19
_fizzbuzz.scss:20 DEBUG: Buzz
_fizzbuzz.scss:16 DEBUG: Fizz
_fizzbuzz.scss:24 DEBUG: 22
_fizzbuzz.scss:24 DEBUG: 23
_fizzbuzz.scss:16 DEBUG: Fizz
_fizzbuzz.scss:20 DEBUG: Buzz
_fizzbuzz.scss:24 DEBUG: 26
_fizzbuzz.scss:16 DEBUG: Fizz
_fizzbuzz.scss:24 DEBUG: 28
_fizzbuzz.scss:24 DEBUG: 29
_fizzbuzz.scss:12 DEBUG: FizzBuzz
_fizzbuzz.scss:24 DEBUG: 31
_fizzbuzz.scss:24 DEBUG: 32
_fizzbuzz.scss:16 DEBUG: Fizz
_fizzbuzz.scss:24 DEBUG: 34
_fizzbuzz.scss:20 DEBUG: Buzz
_fizzbuzz.scss:16 DEBUG: Fizz
_fizzbuzz.scss:24 DEBUG: 37
_fizzbuzz.scss:24 DEBUG: 38
_fizzbuzz.scss:16 DEBUG: Fizz
_fizzbuzz.scss:20 DEBUG: Buzz
_fizzbuzz.scss:24 DEBUG: 41
_fizzbuzz.scss:16 DEBUG: Fizz
_fizzbuzz.scss:24 DEBUG: 43
_fizzbuzz.scss:24 DEBUG: 44
_fizzbuzz.scss:12 DEBUG: FizzBuzz
_fizzbuzz.scss:24 DEBUG: 46
_fizzbuzz.scss:24 DEBUG: 47
_fizzbuzz.scss:16 DEBUG: Fizz
_fizzbuzz.scss:24 DEBUG: 49
_fizzbuzz.scss:20 DEBUG: Buzz
_fizzbuzz.scss:16 DEBUG: Fizz
_fizzbuzz.scss:24 DEBUG: 52
_fizzbuzz.scss:24 DEBUG: 53
_fizzbuzz.scss:16 DEBUG: Fizz
_fizzbuzz.scss:20 DEBUG: Buzz
_fizzbuzz.scss:24 DEBUG: 56
_fizzbuzz.scss:16 DEBUG: Fizz
_fizzbuzz.scss:24 DEBUG: 58
_fizzbuzz.scss:24 DEBUG: 59
_fizzbuzz.scss:12 DEBUG: FizzBuzz
_fizzbuzz.scss:24 DEBUG: 61
_fizzbuzz.scss:24 DEBUG: 62
_fizzbuzz.scss:16 DEBUG: Fizz
_fizzbuzz.scss:24 DEBUG: 64
_fizzbuzz.scss:20 DEBUG: Buzz
_fizzbuzz.scss:16 DEBUG: Fizz
_fizzbuzz.scss:24 DEBUG: 67
_fizzbuzz.scss:24 DEBUG: 68
_fizzbuzz.scss:16 DEBUG: Fizz
_fizzbuzz.scss:20 DEBUG: Buzz
_fizzbuzz.scss:24 DEBUG: 71
_fizzbuzz.scss:16 DEBUG: Fizz
_fizzbuzz.scss:24 DEBUG: 73
_fizzbuzz.scss:24 DEBUG: 74
_fizzbuzz.scss:12 DEBUG: FizzBuzz
_fizzbuzz.scss:24 DEBUG: 76
_fizzbuzz.scss:24 DEBUG: 77
_fizzbuzz.scss:16 DEBUG: Fizz
_fizzbuzz.scss:24 DEBUG: 79
_fizzbuzz.scss:20 DEBUG: Buzz
_fizzbuzz.scss:16 DEBUG: Fizz
_fizzbuzz.scss:24 DEBUG: 82
_fizzbuzz.scss:24 DEBUG: 83
_fizzbuzz.scss:16 DEBUG: Fizz
_fizzbuzz.scss:20 DEBUG: Buzz
_fizzbuzz.scss:24 DEBUG: 86
_fizzbuzz.scss:16 DEBUG: Fizz
_fizzbuzz.scss:24 DEBUG: 88
_fizzbuzz.scss:24 DEBUG: 89
_fizzbuzz.scss:12 DEBUG: FizzBuzz
_fizzbuzz.scss:24 DEBUG: 91
_fizzbuzz.scss:24 DEBUG: 92
_fizzbuzz.scss:16 DEBUG: Fizz
_fizzbuzz.scss:24 DEBUG: 94
_fizzbuzz.scss:20 DEBUG: Buzz
_fizzbuzz.scss:16 DEBUG: Fizz
_fizzbuzz.scss:24 DEBUG: 97
_fizzbuzz.scss:24 DEBUG: 98
_fizzbuzz.scss:16 DEBUG: Fizz
_fizzbuzz.scss:20 DEBUG: Buzz
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment