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
# 1. Each player has two 10x10 boards with columns labeled 1-10 and rows labeled A-J, one labeled "Your Ships" | |
# to represent their own ships and one to represent their opponent's board, labeled "Enemy Ships" | |
# 2.Each player arranges their ships on their own board (see fleet table) | |
# 3.Take turns firing a salvo at your opponent, calling out squares as "A3", "B6", etc. | |
# Salvo = number of your ships you have left (use counter) / 1 shot. | |
# 4.Mark salvos fired on the "Enemy Ships" grid (/ marks a miss, i.e. water; X marks a hit). | |
# You must call out when your ship is sunk completely. | |
# Setting up the environment | |
# User plays against the computer |
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
referf |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>DOM manipulation with jQuery</title> | |
<!-- Add a link to jQuery CDN here script here --> | |
<script type="text/javascript" src="jquery_example.js"></script> | |
</head> | |
<body> |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>DOM manipulation with jQuery</title> | |
<!-- Add a link to jQuery CDN here script here --> | |
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> | |
<script type="text/javascript" src="jquery_example.js"></script> | |
</head> |
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
cheatsheet that helped me during this challenge: | |
http://www.westwind.com/reference/os-x/commandline/text-files.html) | |
429 git clone https://github.com/dbc-challenges/CLI-Obstacle-Course desktop/command_line | |
430 cd desktop/command_line/"CLI-Obstacle-Course" | |
431 cd desktop/command_line | |
432 ls | |
433 ls -la | |
434 mv images app/assets | |
435 ls -la app/asset |
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
#as with the PezDispenser, i decided to try out new things, and here is what I got | |
class Board_games | |
attr_reader :board # make the board possible to view | |
def initialize (board = []) | |
puts "Board ready, if you want to mix the letters and start with a new board, just shake" | |
@board = board | |
the_choice_of_letters = ('a'..'z').to_a |
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 BoggleBoard | |
attr_reader :board # make the board possible to view by using the attribute reader | |
def initialize (board) | |
puts "Board is ready" | |
@board = board | |
end | |
#initializing the default variable of a newly created instance. And every time a new instance is created, the user will get |
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
def north_korean_cipher(coded_message) | |
input = coded_message.downcase.split("") | |
characters = ('a'..'z').to_a | |
rotated_characters = characters.rotate(4) | |
cipher = Hash[rotated_characters.zip(characters)] | |
decoded_sentence = input.collect do |x| | |
if cipher.has_key?(x) | |
x = cipher[x] | |
elsif x.match(/[\@\#\$\%\^\&\*]/) |
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
require 'bigdecimal' #require the bigdecimal, since Fibonacci sequence can have very large numbers, and for working with large numbers we would need to call the methods of exactly this class | |
def is_fibonacci?(i) | |
return true if i == 0 || i == 1 #if this is not specified, Ruby will be returning an FloatDomain Error, negative value, for the 0 passed in as an argument | |
i = BigDecimal.new(i) #setting the variable so that the code can also work with big numbers | |
fib_number = (5 * i**2 + 4).sqrt(0) #calling the method "sqrt" of BigDecimal class to return the square root, and this will work for large numbers also | |
fib_number_two = (5 * i**2 - 4).sqrt(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
# Background | |
# Your future career will require you to deal with a lot of "legacy code," | |
# i.e. code that works as intended, but is difficult to modify. | |
# Sometimes you will be given the option to start over or modify the original code. | |
# Other times you will be forced to work with legacy code due to time or budget constraints. | |
# In this challenge, you have the option to completely trash the code and start | |
# over or work with the code that's here, but make sure that it works the same way. | |
# The driver code should still print "true" without being modified. |