Skip to content

Instantly share code, notes, and snippets.

View BRonen's full-sized avatar
:shipit:
Functions describe the world

Brenno Rodrigues BRonen

:shipit:
Functions describe the world
View GitHub Profile
const code1 = '((7 1 +) 5 +) ((8 ((8 ((8 3 +) 1 +) +) 1 +) +) 1 +) +';
const code2 = '4 3 -';
const code3 = '(2 3 +) (23 21 +) +';
const operators = {
'+': (args) => args[0] + args[1],
'-': (args) => args[0] - args[1],
'*': (args) => args[0] * args[1],
'/': (args) => args[0] / args[1],
};
@BRonen
BRonen / full_adder.html
Last active March 7, 2024 20:42
Full adder made to prove that html with css is turing complete (without js)
<!DOCTYPE html>
<html>
<head>
<style>
div {
display: flex;
gap: 1rem;
}
@BRonen
BRonen / BinaryTree.hs
Last active June 3, 2023 14:50
A binary tree implemented in haskell just for fun
module Main where
data Tree a = Leaf a | Node (Tree a) (Tree a)
stringifyTree :: Tree Integer -> [Char]
stringifyTree (Leaf x) = show x
stringifyTree (Node left right) = " {" ++ (stringifyTree left) ++ "} - {" ++ (stringifyTree right) ++ "} "
dump :: Tree a -> [a]
dump (Leaf x) = [x]
@BRonen
BRonen / KeyValue.hs
Created June 3, 2023 18:14
A key value data structure made in haskell just for fun
module Main where
type Pair a = ( [Char], a )
updateValue :: [Char] -> a -> [Pair a] -> [Pair a]
updateValue key value [] = [(key, value)]
updateValue key value [(a, b)]
| a == key = [(key, value)]
| otherwise = [(a, b), (key, value)]
updateValue key value ((a, b):xs)
@BRonen
BRonen / LinkedList.hs
Created June 4, 2023 06:14
An example of linked list made in haskell for fun
module Main where
data List a = End a | Node a (List a) deriving (Show)
prepend :: a -> List a -> List a
prepend value x = Node value x
append :: a -> List a -> List a
append value (End x) = Node x (End value)
append value (Node x y) = Node x (append value y)
@BRonen
BRonen / README.md
Created July 30, 2023 03:56
Desafio mentoria

Requisitos

Os requisitos desse projeto não são especificos de nenhuma linguagem nem framework, as integrações podem acontecer tanto no frontend quanto no backend. O foco principal é na usabilidade do projeto pelo usuário. A base da aplicação é baseada em 3 etapas:

  • a busca de um perfil na api do github;
  • a listagem dos resultados da busca;
  • a visualização desse perfil;
@BRonen
BRonen / RomanNumerals.ts
Created July 30, 2023 04:06
Script to parse roman numerals to equivalent integer
/**
* Decodes a Roman numeral to a number.
*
* @param {string} roman - The Roman numeral to decode.
* @returns {number} The decoded Roman numeral.
*/
const numerals: Record<string, number> = {
'I': 1,
'V': 5,
@BRonen
BRonen / MorseAutocompleteSuggestions.ts
Created July 30, 2023 04:10
A script that handles incomplete morse signals and gives the original source possibilities
/**
* Finds the number in an array with the most digits.
*
* @param {string} signals - The incomplete source.
* @returns {string[]} Suggestions of possible complete sources.
*/
const MORSE_DICTIONARY: Record<string, string> = {
".": "E",
"-": "T",
@BRonen
BRonen / ReversePolishNotationInterpreter.ts
Created July 30, 2023 04:29
Evaluates an expression in Reverse Polish Notation
/**
* Evaluates an expression in Reverse Polish Notation.
*
* @param {string} expression - The input expression.
* @returns {number} The result of the RPN expression.
*/
// This script parses the expression into a tree and then evaluates, should be something like O(n) because iterates once on the parsing and once in the evaluating
type Operator = {op: string, left: Operator | number, right: Operator | number};
@BRonen
BRonen / RealtimeEditCss.html
Created August 1, 2023 18:21
Realtime editable css
<html>
<body>
<style contenteditable>
style { display: block; }@keyframes animat { 0% { background-color: pink; } 50% { background-color: orange; } 100% { background-color: red; } }body { animation: animat 750ms infinite alternate; }
</style>
</body>
</html>