Tuesday, May 14, 2013

i guess you can upload SVG to blogger, i googled it, there are some work around, but i don't have time at the moment.
i've gotten my svg graph to appear and i can swap two of the bars, now i just have to rewrite my sort so that every swap is recorded with a counter so that the timeiing can be coordinated. and i will have a graph that demonstrates a sort.

Saturday, May 11, 2013

i am going to impliment all the sorts that are listed on wikipedia, i reserve the right to not worry about the case that the input is empty. although it's so easy to add, maybe i will.

i just implimented bubble sort, although i suspect it is not the sexy "think in ruby" way it should be. it was of course easy, messing with the output was the hardest part. but my goal is not to learn algorithms but rather to practice at ruby, and you have to work to a particular goal, otherwise you will only stick with what you know.
then i implimented cocktail sort, but  i couldn't get it to work without cheating, i think i am confused about how it's supposed to work, i need to work it out on paper but i didn't bring any. bleh.


next is odd-even sort, i'm not familiar with this one, we didn't do it in school.
-well that was pretty easy, i just had to create a range and use .step() to go through the indexes

next is comb sort, then gnome, the quicksort, then stooge sort. im  not doing bogosort.

comb is done, easy.

gnome is done: record time, if am getting a little bit practiced at this, also gnome sort is kinda sexy.

that was lies, quicksort is being annoying, i know how it works, but i've got my indexs  screwed up and i'm tired.


Thursday, May 2, 2013

assignment 2:

goals:
use a hash with symbols
regular expressions
blocks with yield
define a class
enumerators, blocks, iterators chapter 4 stuff

i think somekind of mad lib? maybe random text swipe from the internet, then a program that lets the user assign the grammatical catagory. then it stores this info, another program loads all these madlibs and picks random words to switch out. nope, that wont work. bleh,  maybe sports teams? yuck, i'll look through some old assignments


Oh! i just thought of something, i will make a table top RPG program, it can read in monsters, then generate encounters with keywords for settings.  The monsters can be a class that demonstrates inheritance. settings can be a class, encounters can be a class. Then it can generate text files that gives monster stats, setting keywords, and some other shit.
this is my preliminary program, it could be refined, if it was for someone other then me i would refine it.  But,, it satisfies my learning goals.


#Charles Kuehne 5/2/2013
# fortune telling program
# takes user name as command line arg
# asks user to pick a sign
# uses date and sign to generate a fortune
#fortunes read from file
# responds to screen with personalized fortune


require 'date'

name = ARGV.shift #removes the argument so gets works

zod = [ "Aries", "Tarus", "Gemini", "Cancer", "Leo", "Virgo", "Libra", "Scorpio", "Sagittarious", "Capricorn", "Aquarius", "Pisces"]

alltxt = File.read("lorem.txt")# my lorem ipsum file
fortunes = alltxt.split(". ")#puts each sentance into an array

puts "Hello #{name}"

puts "please choose your sign:"

count = 0

zod.each_with_index do |sign, index| #WITH INDEX!! so sexy!
   
     puts "(" + index.to_s + ") " + sign
    end

choice = gets.to_i

while zod[choice] == nil do
    puts "bad number, try again >"
    choice = gets.to_i
end
    puts "You chose " + choice.to_s+" which is "+ zod[choice]

today = Date.today.yday()#converts day of year to int

puts  fortunes[((today * (choice+1)) % fortunes.length)]


assignment one: Fortune Telling Machine.
goals: input and output from the terminal, command line arguments, string manipulation, arrays, switch statements.

Write a fortune telling program that takes the users first name as a command line argument.  It then asks the user to choose their zodiac sign from a list. It then uses a number generated from  their name, a number from the sign and a number from the date to choose a fortune and return a personalized message to the user.


chapter one: setup

chapter one of the pickaxe deals with setting up Ruby. I used the text and these links to get it all squared away.

i used this video to remember how to add nano to my windows machine, i'd added other things before with cygwin but not nano. and then i wanted clear also.

ri wasn't working correctly, i have to reload the information using this
Those are the only links i bookmarked during setup.

Don't read this blog...

i am trying to teach myself Ruby from the pickaxe, this means i need to come up with my own exercises to practice with.  My plan is to implement sorting algorithms and swipe exercise ideas from my C++ text. I'd like to go by chapters and post my solutions. This blog is for my own consumption, feel free to read it but i have no intention of making it have value to anyone but me. besides I'll probably loose enthusiasm in a week and have blogger sending me emails harassing me to post something.