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
#include <iostream> | |
using namespace std; | |
struct cvor | |
{ | |
int oznaka; | |
int PrvoDijete; | |
int SljedeciBrat; | |
}; |
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
#include <iostream> | |
using namespace std; | |
struct cvor | |
{ | |
int oznaka; | |
int PrvoDijete; | |
int SljedeciBrat; | |
bool koristeno; | |
}; |
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
''' | |
Write code that will print ten astrisks (*) like the following: | |
* * * * * * * * * * | |
''' | |
print("first"); | |
for i in range (10): | |
print ("*", end = " "); | |
''' | |
Write code that will print the following: |
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
#First enter rails console: | |
$rails console | |
#Then just type: | |
ActiveRecord::Migration.drop_table(:users) | |
Where :users is the table name. |
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
''' | |
Caesar cipher with a swap by 3 | |
2 implementations | |
''' | |
def c(s) | |
s.split("").map{|s|(65+(s.ord+16)%26).chr}.join() | |
end | |
def c2(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
''' | |
Rot13 implementation in ruby | |
21.01.2013. | |
''' | |
def a(s) | |
s.tr("A-MN-Z","N-ZA-M") | |
end | |
p a("ASDDSAZZZ") |
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
/* | |
* Simple tree traversal algorithms (preorder, inorder and postorder) | |
* on a small binary tree with 5 nodes. | |
* | |
*/ | |
#include <iostream> | |
#include <cstdlib> | |
using namespace std; |
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
/* | |
* BS-tree size solved with and without additional memory. | |
* | |
*/ | |
#include <iostream> | |
#include <cstdlib> | |
using namespace std; |
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
/* | |
You've woken up one day to find that everyone suddenly expresses numbers in different number bases. You're seeing prices in octal and phone numbers in hexadecimal. It's a numerical Tower of Babel! For your own sanity, you decide to program a simple mathematical expression evaluator that can handle numbers in different number bases. It should support addition, subtraction, and multiplication, should respect order of operations, and should handle number bases between 2 and 16. | |
While your language of choice may directly support expression evaluation, please create your own. | |
The input on stdin is a mathematical expression on a single line. Number constants are expressed like "123_4", which is "123" in base 4, which is 27 in base 10. Some digits in the higher bases will be represented with uppercase letters. Numbers within the expression will always be non-negative integers. The operators will be +, -, and *. Whitespace should be ignored. | |
Your program should emit to stdout a single base-10 number with no und |
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
res = [] | |
8.times do | |
res << [rand(7..10), rand(3..4), rand(3..6), rand(2..4)] | |
end | |
14.times do | |
res << [rand(11..20), rand(5..7), rand(3..4), rand(3..4)] | |
end | |
2.times do |
OlderNewer