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
| #include <ncurses.h> | |
| // ncurses test | |
| // rougelike code | |
| // create a player character: @ | |
| // enable the user to move the character around the screen | |
| int main() | |
| { |
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
| # a function for like that takes an array of names and returns a string | |
| def likes(names) | |
| if names.count <= 3 | |
| case names.count | |
| when 0 | |
| "no one likes this" | |
| when 1 | |
| "#{names[0]} likes this" | |
| when 2 |
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
| #include <stdio.h> | |
| int main() | |
| { | |
| int loop = 15, count, a = 0, b = 1; | |
| for(count=1; count<= loop; ++count) | |
| { | |
| printf("%d\n%d\n", a, b); | |
| a = a+b; //shift a to the next value in the squence |
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 snail(array) | |
| include FollowThePath | |
| init(array) | |
| @squares.times do walkTheSquare(array) end | |
| return @path | |
| end | |
| module FollowThePath |
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
| # find the nth value in the fibonacci squence | |
| require "matrix" | |
| # analyze processing time | |
| require 'Benchmark' | |
| time = Benchmark.realtime do | |
| # get the user input for n, the nth value to find | |
| n = gets.to_i |
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
| #!/usr/bin/env ruby | |
| a = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100] | |
| b = (1..100).to_a | |
| # total all elements of an array | |
| def total_array(array) | |
| total = 0 | |
| array.each { | number | total += number} |
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
| #!/usr/bin/env ruby | |
| # | |
| # Write a program that prints the numbers from 1 to 100. For multiples of three, print "Fizz" and for mulitples of five print "Buzz". For multiples of both three and five, print "FizzBuzz". | |
| # Let the user set the maximum number to evaluate | |
| puts "Evaluate numbers up to?" | |
| rangeMax = gets.to_i | |
| # Store all the numbers in an array | |
| numbers = (1..rangeMax).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
| // Based on http://chrisnager.com/hexcodes/ | |
| // -------------------------------------------------- | |
| // Create a color palette of all 4,096 3-digit hexadecimal colors | |
| // -------------------------------------------------- | |
| // Hexadecimal digits | |
| var digits = ['f', 'e', 'd', 'c', 'b', 'a', '9', '8', '7', '6', '5', '4', '3', '2', '1', '0'] | |
| // Create a swatch book |