This file contains hidden or 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
pragma solidity ^0.4.24; | |
contract AssetTracker { | |
// define new Asset object | |
struct Asset { | |
uint256 uuid; | |
string name; | |
string manufacturer; | |
uint256 timestamp; |
This file contains hidden or 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
pragma solidity ^0.4.19; | |
contract Owned { | |
address owner; | |
function Owned() public { | |
owner = msg.sender; | |
} | |
modifier onlyOwner() { |
This file contains hidden or 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
pragma solidity ^0.4.18; | |
contract Coursetro { | |
string fName; | |
uint age; | |
event Instructor( | |
string name, | |
uint age | |
); | |
This file contains hidden or 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
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); |
This file contains hidden or 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
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 |
This file contains hidden or 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
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 |
This file contains hidden or 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
class Computer | |
$manufacturer = "Mango Computer, Inc." | |
@@files = {hello: "Hello, world!"} | |
def initialize(username, password) | |
@username = username | |
@password = password | |
end | |
def current_user |
This file contains hidden or 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
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!" |
This file contains hidden or 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
$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 |
This file contains hidden or 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
alphabet = ["a", "b", "c"] | |
alphabet << "d" # Update me! | |
caption = "A giraffe surrounded by " | |
caption << "weezards!" # Me, too! |
NewerOlder