Skip to content

Instantly share code, notes, and snippets.

View djvita's full-sized avatar

Vita V djvita

  • support enginer
  • MX remote
View GitHub Profile
using System;
using System.Collections.Generic;
using System.Text;
///<summary>
/// its just everything instanced, nothing is implemented
/// its up to you to design and crate functions.
///</summary>
namespace Softtek.Academia.CursoDotNet.Ejercicio2{ //name of the DLL
//Contoller class
public class Program:ProgramaDeConsola
# Calculate the nth Fibonacci number, f(n). Using invariants
def fibo_tr(n, acc1, acc2)
if n == 0
0
elsif n < 2
acc2
else
return fibo_tr(n - 1, acc2, acc2 + acc1)
end
end
require "mscorlib"
require "System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
require "System.Collections.Generic, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
require "System.Text, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
# <summary>
# its just everything instanced, nothing is implemented
# its up to you to design and crate functions.
module Softtek.Academia.CursoDotNet.Ejercicio2 #name of the DLL
#Contoller class
class Program < ProgramaDeConsola
@djvita
djvita / possible answer
Created April 26, 2014 16:51
Given two sorted arrays of integers, write a method to merge the two sorted arrays of integers into a single sorted array of integers. For example: Given the arrays [1,3,5] and [2,4], your method would return [1,2,3,4,5].
using System;
using System.Collections.Generic;
using System.Text;
namespace Excercise1{
public Class Program {
public static void Main(string[] args)
{
int[] a = {1, 3, 5};
int[] b = {2,4};
@djvita
djvita / possible solution
Created April 26, 2014 16:53
Given a binary search tree, write a method to find the nth smallest element in the tree. For example: Given the Tree: 8 ↙ ↘ 3 10 ↙ ↘ ↘ 1 6 14 ↙ ↘ ↙ 4 7 13 And N = 4, your method would return 6.
using System.Collections.Generic;
public int smallElement(int k)
{
Node<T> node = Root;
int count = k;
int sizeOfSubTree =0;
while (node != null)
@djvita
djvita / possible solution
Created April 26, 2014 16:55
Given a stream of characters, implement a method that will always return the first character that has only appeared once in the stream. For example, say your stream thus far is a,b,c. A call into getFirstUniqueCharacter would return a. After the next character is read, the stream thus far is a,b,c,a. Now a call to getFirstUniqueCharacter will re…
InputStream is = null;
int i;
char c;
try{
// new input stream created
is = new FileInputStream("C://test.txt");
System.out.println("Characters printed:");
This file has been truncated, but you can view the full file.
{
"metadata": {
"name": "",
"signature": "sha256:a04c38d9604adb7eb9ca89860dfa1ef72db66037cc2c07c391ef8e67a31f9254"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
@djvita
djvita / Hello!
Created May 25, 2015 20:38
Playground Swift
//: Playground - noun: a place where people can play
import UIKit
var str = "Hello, playground"
var numberOfYears: Int = 4
@djvita
djvita / othello
Created July 11, 2016 19:13 — forked from alcuin/othello
A Min-Max search algorithm for Othello on R with simple GUI.
CONST.TIME.LIMIT <- 6 # threshold of time(sec) for searching.
CONST.MAX.DEPTH <- 3 # max depth of depth-first searching.
##' main
othello <- function(verbose = FALSE) {
## initialize.
board <- as.numeric(rep(0,8^2))
turn <- 1
board[conv.xy2index(4,4)] <- board[conv.xy2index(5,5)] <- 1
board[conv.xy2index(4,5)] <- board[conv.xy2index(5,4)] <- -1