Blog Features

January 05, 2021 - 3 min read

Components

Embedding a Component

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris at magna ut lacus pellentesque porttitor. Nam molestie rutrum mollis. Nam eget turpis vel velit pulvinar venenatis. Integer pretium turpis ac mauris vulputate elementum. Duis imperdiet sollicitudin velit, quis porta nisi scelerisque quis. Vestibulum feugiat nunc quis fringilla bibendum. Sed malesuada gravida arcu molestie ullamcorper. Etiam elementum aliquam sem, ut laoreet dui aliquam eu.

Ace Chad
TestCo Employee

Tweets

Can Embed Tweets

Youtube videos

KaTeX

Mathematical Equations such as x2dx\int_{\infty}^{-\infty} x^2 dx can be placed inline with the text. Alternatively, it can be used as a block such as below.

y=x2+2x+1=(x+1)(x+1)=(x+1)2\begin{aligned} y & = x^2 + 2x + 1 \\ & = (x+1)(x+1) \\ & = (x+1)^2 \end{aligned}

2x(n12)+n-2 \left|x - \left( \frac{n-1}{2} \right) \right| + n

Code

Inline Code testing

// JavaScript
function diamond(n) {
    if (n < 0 || n % 2 == 0) return ""
    const midpoint = (n - 1) / 2
    const spaces = x => Math.abs(x - midpoint)
    const filled = x => n - 2 * Math.abs(x-midpoint)
    const layer = l => " ".repeat(spaces(l)) + "*".repeat(filled(l)) + "\n"
    return [ ...Array(n).keys()].reduce((d, l) => d + layer(l), "")
}

print(diamond(11))
# Python
def diamond(n):
    if n < 0 or n % 2 == 0:
        return ""
    midpoint = (n - 1) // 2
    spaces = lambda x: abs(x - midpoint)
    filled = lambda x: n - 2 * abs(x-midpoint)
    layer = lambda l: " " * spaces(l) + "*" * filled(l) + "\n"
    return "".join([layer(l) for l in range(n)])


print(diamond(11))
-- Haskell
diamond :: Int -> [Char]
diamond n 
    -- Return Nothing if even
    | n `mod` 2 == 0 = ""
    | otherwise = unlines $ [layer n x | x <- [0..(n - 1)]]
    where
        midpoint :: Int -> Int
        midpoint n = (n - 1) `quot` 2 

        spaces :: Int -> Int -> Int
        spaces n x = abs (x - midpoint n)

        filled :: Int -> Int -> Int
        filled n x = n - 2 * abs(x - midpoint n)

        layer :: Int -> Int -> [Char]
        layer n x = (concat (replicate (spaces n x) " ")) ++ (concat (replicate (filled n x) "*"))

main = putStr(diamond 11)

Gists

RSS Feed

I used Gatsby to create an RSS Feed, containing a standardized format of my blog. This can be easily parsed and used in applications, and I have a project planned using it in the future.


Currently a freshman student in FCIT, I created this blog to document my programming journey and the projects I create. My strengths are in Python and Typescript, however, I plan on diving deeper into Computer Science in the coming years.

Ryan Samman
Computer Science Student, FCIT