tags: Book asin: B01KAFIQE6 title: The Daily Stoic subtitle: 366 Meditations for Clarity, Effectiveness, and Serenity author:
- "[[Ryan Holiday]]"
- "[[Stephen Hanselman]]" date: 2016-10-27 publisher: Profile Books
tags: Book asin: B01KAFIQE6 title: The Daily Stoic subtitle: 366 Meditations for Clarity, Effectiveness, and Serenity author:
defmodule FizzBuzz do | |
def compute(n), do: fb(n, rem(n, 3), rem(n, 5)) | |
defp fb(_, 0, 0), do: "FizzBuzz" | |
defp fb(_, 0, _), do: "Fizz" | |
defp fb(_, _, 0), do: "Buzz" | |
defp fb(n, _, _), do: n | |
end |
Some VHDL stuff |
#!/usr/local/bin/ruby -w | |
require 'test/unit' | |
class FizzBuzz | |
def self.fizzbuzz(number) | |
result = "" | |
result << "Fizz" if is_divisible_by_three?(number) | |
result << "Buzz" if is_divisible_by_five?(number) | |
return result if result != "" |
#!/usr/local/bin/python3 | |
def fizzbuzz(n): | |
string = '' | |
if n % 3 == 0: | |
string += 'Fizz' | |
if n % 5 == 0: | |
string += 'Buzz' | |
#!/usr/local/bin/ruby -w | |
class Mega | |
attr_reader :apostas | |
def initialize(n = 6, l = 1) | |
@l = l | |
@n = n | |
@apostas = Array.new | |
apostar | |
jogos |
def snail(array) | |
result = Array.new | |
n = array.length | |
runs = n.downto(0).each_cons(2).to_a.flatten | |
delta = [[1,0], [0,1], [-1,0], [0,-1]].cycle | |
x, y = -1, 0 | |
for run in runs | |
dx,dy = delta.next | |
run.times do |i| | |
x += dx |
def pascalsTriangle(n = 1) | |
return nil if n == nil || n < 1 | |
rows = [[1]] | |
2.upto(n) do |i| | |
row = [1] | |
1.upto(i-2) do |j| | |
row << rows.last[(j-1) % rows.last.size] + rows.last[j % rows.last.size] | |
end | |
rows << (row << 1) | |
end |
class RomanNumerals | |
MAX = 4999 | |
FACTORS = [['M', 1000], ['CM', 900], ['D', 500], | |
['CD', 400], ['C', 100], ['XC', 90], ['L', 50], ['XL', 40], | |
['X', 10], ['IX', 9], ['V', 5], ['IV', 4], ['I', 1]] | |
def self.to_roman(i) | |
if i <= 0 || i > MAX then fail "Roman values must be > 0 and <= #{MAX}" end | |
roman = '' | |
for code, factor in FACTORS |