fulano
|
codepad
|
|
fulano
|
Saved pastes by fulano:
# A Perl Fizzbuzz implementation that is entirely more complicated than necessary
# the Fizzbuzz is calculated based on a cyclic repetition that I noticed.
$count = 1;
for (1..100)
{
|
view (19 lines, 100 lines of output) |
#Generating the Fibonacci sequence with only a list comprehension
for index,number in enumerate (
[(x < 2 and [[0, 1][x]] #This 'seeds' the first 2 numbers with 0, 1
or [locals()['_[1]'][-2] + locals()['_[1]'][-1]] #Undocumented method of gaining access to the list that is currently being built
)[0]
|
view (8 lines, 20 lines of output, 1 comment) |
<?//FizzBuzz - Showing off
for ($i = 1; $i < 101; ++$i) { print ($i%3 && $i%5 ? $i : (!($i%3) ? "Fizz" : "") . (!($i%5) ? "Buzz" : "")) . "\n";}?>
|
view (2 lines, 100 lines of output) |
#FizzBuzz - Showing Off
for a in range (1, 101): print [a, ''.join ([["Fizz", ""][bool(a % 3)],["Buzz", ""][bool(a % 5)]])][not a % 3 or not a % 5]
|
view (2 lines, 100 lines of output) |
#Sierpinski triangle created from Pascal's Triangle (Centered)
$maxRows = 128;
@row = ();
|
view (19 lines, 128 lines of output) |