Skip to content

Instantly share code, notes, and snippets.

View idimitrov07's full-sized avatar
🏠
Working from home

Ivan Dimitrov idimitrov07

🏠
Working from home
View GitHub Profile
pragma solidity ^0.4.24;
contract AssetTracker {
// define new Asset object
struct Asset {
uint256 uuid;
string name;
string manufacturer;
uint256 timestamp;
pragma solidity ^0.4.19;
contract Owned {
address owner;
function Owned() public {
owner = msg.sender;
}
modifier onlyOwner() {
pragma solidity ^0.4.18;
contract Coursetro {
string fName;
uint age;
event Instructor(
string name,
uint age
);
@idimitrov07
idimitrov07 / GuessingGame.sol
Created March 4, 2018 19:29
Simple guessing game on Solidity
pragma solidity ^0.4.18;
// Problem - generate a random rumber
contract GuessingGame {
uint nonce = 0;
event UserWon(address user, uint numberGenerated);
event UserLost(address user, uint numberGenerated);
q = gets.strip.to_i
for a0 in (0..q-1)
s = gets.strip
# your code goes here
# hackerrank
word = ""
index = 0
s.each_char do |c|
if c == "hackerrank"[index]
word += c
n = gets.strip.to_i
a = gets.strip
arr = a.split(' ').map(&:to_i)
# your code goes here
min = 2147483647
arr.sort!
(1...arr.size).each do |i|
diff = (arr[i - 1] - arr[i]).abs
if diff < min
min = diff
class Computer
$manufacturer = "Mango Computer, Inc."
@@files = {hello: "Hello, world!"}
def initialize(username, password)
@username = username
@password = password
end
def current_user
5.times { puts "Hello!" }
###
fibs = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55]
doubled_fibs = fibs.collect { |el| el * 2 }
####
def block_test
puts "We're in the method!"
puts "Yielding to the block..."
yield
puts "We're back in the method!"
$VERBOSE = nil # We'll explain this at the end of the lesson.
require 'prime' # This is a module. We'll cover these soon!
def first_n_primes(n)
unless n.is_a? Integer
return "n must be an integer."
end
if n <= 0
alphabet = ["a", "b", "c"]
alphabet << "d" # Update me!
caption = "A giraffe surrounded by "
caption << "weezards!" # Me, too!