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 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; | |
} |
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
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; |
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
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()); | |
} |
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 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) |
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
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]) |
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 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 | |
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 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) |
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
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++; |
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
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; ){ |
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
<!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"> |
OlderNewer