This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
s = ''' | |
01001001 01101110 | |
01110100 01100101 | |
01101100 00100000 | |
01001000 01100101 | |
01100001 01110010 | |
01110100 01110011 | |
00100000 01011001 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1.upto(100) do |i| | |
s = "#{[:Fizz][i % 3]}#{[:Buzz][i % 5]}" | |
puts s.empty? ? i : s | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1.upto(100) do |i| | |
puts i % 15 != 0 ? i % 3 != 0 ? i % 5 != 0 ? i : 'Buzz' : 'Fizz' : 'FizzBuzz' | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 | |
2 | |
Fizz | |
4 | |
Buzz | |
Fizz | |
7 | |
8 | |
Fizz | |
Buzz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
system 'curl https://gist.github.com/st98/7431455/raw/552a45a51a2d26c6bf56e7cba2f33eb763ed3297/fizzbuzz3' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def bottles_of_beer(n) | |
def bottle(n) | |
bottles = case n | |
when 0 | |
"No more bottles" | |
when 1 | |
"#{n} bottle" | |
else | |
"#{n} bottles" | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
String::partition = (n) -> @match new RegExp('(.{' + n + '})|(.+)', 'g') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from random import randint | |
def gen_variable_name(a): | |
while True: | |
yield ''.join([ | |
chr(0x61 + randint(0, 25)) | |
for _ in range(a) | |
]) | |
if __name__ == '__main__': |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from functools import reduce | |
from operator import mul | |
def fact(n): | |
return reduce(mul, range(1, n + 1)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function () { | |
'use strict'; | |
var root = this; | |
var ascii = {}; | |
var prevAscii = root.ascii; | |
if (typeof exports !== 'undefined') { | |
if (typeof module !== 'undefined' && module.exports) { |
OlderNewer