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
(defun Hanoi (n origin destination auxiliar) | |
(if (= n 1) (moure 1 origin destination) | |
(progn (Hanoi (- n 1) origin auxiliar destination) | |
(moure n origin destination) | |
(Hanoi (- n 1) auxiliar destination origin)))) | |
(defun moure (k origin destination) | |
(print (list 'move 'disk k | |
'from 'column origin | |
'to 'column destination))) |
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
/*Query to detect active sessions, in order to kill them in Oracle */ | |
SELECT s.inst_id, | |
s.sid, | |
s.serial#, | |
p.spid, | |
s.username, | |
s.osuser, | |
s.machine, | |
s.program, | |
'ALTER SYSTEM KILL SESSION '''||s.sid||','||s.serial#||''' IMMEDIATE;' as cmd |
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 to return an array containing *length* random numbers | |
and having the range from 0 to *max* */ | |
function randomArray(length, max) { | |
return Array.apply(null, Array(length)).map(function() { | |
return Math.round(Math.random() * max); | |
}); | |
} | |
/* function than shuffle an array */ | |
function shuffle(array) { |
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
<?php | |
$input = "1,2,3,4,5,6,7"; | |
$sum = 0; | |
print($input); | |
$input_arr = explode(",", $input); | |
foreach($input_arr as &$inp) | |
{ |
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
<?php | |
class Dragonball { | |
public $ballCount = 0; | |
public function iFoundaBall() { | |
if ($this->ballCount < 7) { | |
$this->ballCount++; | |
} else { | |
echo("You can ask your wish!"); | |
$this->ballCount = 0; |
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
<?php | |
class FileOwners | |
{ | |
public static function groupByOwners($files) | |
{ | |
$file_return = []; | |
$files_copy = $files; | |
print_r($files); | |
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
#!/bin/python3 | |
#Given a square matrix of size NxN , calculate the absolute difference between the sums of its diagonals. | |
import sys | |
n = int(input().strip()) | |
a = [] | |
for a_i in range(n): |
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
#!/bin/python3 | |
''' | |
Given an array of integers, calculate which fraction of its elements are positive, | |
which fraction of its elements are negative, and which fraction of its elements are zeroes, | |
respectively. Print the decimal value of each fraction on a new line. | |
''' | |
import sys | |
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
#!/bin/python3 | |
''' | |
Consider a staircase of size n=4: | |
# | |
## | |
### | |
#### | |
Observe that its base and height are both equal to , and the image |
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
#!/bin/python3 | |
''' | |
Given five positive integers, find the minimum and maximum values | |
that can be calculated by summing exactly four of the five integers. | |
Then print the respective minimum and maximum values as a single line | |
of two space-separated long integers. | |
''' | |
import sys |
OlderNewer