Skip to content

Instantly share code, notes, and snippets.

View dluciano's full-sized avatar
🎯
Focusing

Dawlin dluciano

🎯
Focusing
  • UK
View GitHub Profile
@dluciano
dluciano / flatten.js
Last active October 8, 2016 16:08
I forget upload latest changes.
function flatten(array){
var result = [];
for (var i = 0, len = array.length; i < len; i++) {
var aux = array[i];
if(Array.isArray(aux))
aux = flatten(aux);
result = result.concat(aux);
}
return result;
}
@dluciano
dluciano / IsBalanced.js
Created October 14, 2016 05:10
Creation of IsBalanced Brackets algorithms
var isBalanced = function(text){
let stack = []
for(let i = 0, len = text.length; i < len; i++){
let character = text[i];
if(character !== "(" && character !== ")")
continue;
if(character === "(")
stack.push(true);
else if(stack.pop() === undefined)
return false;
@dluciano
dluciano / SumOfNRecursive.cs
Last active May 23, 2017 15:55
Sum of N - Recursive
using System;
using System.Linq;
public class Test
{
public static int Sum(int [] arr){
if(arr.Length == 0)
return 0;
return arr[0] + Sum(arr.Skip(1).ToArray());
}
@dluciano
dluciano / sumOfN.py
Last active May 23, 2017 16:12
Sum of N - Recursive Py3
def sum(arr):
if len(arr) == 0:
return 0
return arr[0] + sum(arr[1:len(arr)])
s = sum([1,2,3,4,5])
print(s)
@dluciano
dluciano / palindrome.cs
Last active December 10, 2023 11:21
Palindrome - C#
using System;
public class Test
{
public static bool Palindrome(string text){
if(string.IsNullOrWhiteSpace(text))
return false;
text = text.ToLower();
for(int i = 0; i < text.Length / 2; i++){
if(text[i] != text[text.Length - 1 - i])
@dluciano
dluciano / palindrome.py
Created May 23, 2017 18:34
Palindrome - Python
def palindrome(text):
M = len(text)
if(M <= 0):
return False
i = 0
text = text.lower()
while(i < M):
if(text[i] != text[M - 1 - i]):
return False
@dluciano
dluciano / palindromeR.py
Created May 23, 2017 19:05
Palindrome Recursive - Python 3
def palindromeR(text):
M = len(text)
if(M <= 1):
return True
return (text[0] == text[M - 1]) and palindromeR(text[1: M - 1])
n = "racecare"
isP = palindromeR(n)
print(isP)
@dluciano
dluciano / intToBit.cs
Created May 23, 2017 22:03
Int to Bit - C#
using System;
class MainClass {
public static void ToBin(int N){
int[] t = new int[32];
bool isNeg = N < 0;
N = Math.Abs(N);
int i = 0;
while(N >= 1){
t[i] = N%2;
i++;
@dluciano
dluciano / recipe_base2.cs
Created July 25, 2017 15:49
Recipe with base 2 in c#
using System;
public class Test
{
public static void Main()
{
int[] recetas = {1,2,4,8,16,32,64,128};
int X = 17;
Console.Write("Tenemos una receta de: ");
for(var z = X; z >= 1; ){
@dluciano
dluciano / index.html
Created July 27, 2017 21:45
Reverse polish notation algo
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>RPN</title>
<meta name="description" content="The HTML5 Herald">
<meta name="author" content="SitePoint">