Skip to content

Instantly share code, notes, and snippets.

View MarkJRigdon's full-sized avatar

Mark MarkJRigdon

  • Cape Girardeau, MO
View GitHub Profile
def reverse_string(string)
split_string = string.split("")
split_string.reduce([]) { |a, b| a.unshift(b) }.join
#reversed = []
#string.size.times { reversed << split_string.pop}
#reversed.join
end
puts reverse_string("codelabs")
def max_num_char_str(string)
split_string = string.split("")
count_hash = Hash.new(0)
split_string.each do |c|
count_hash[c] += 1 unless c == " "
end
count_hash.max_by { | c, n | n }.join
end
puts max_num_char_str("lots of sss to show")
def sum(array)
return array.inject(:+)
end
array.each_with_object({odd:[], even:[]}) do |elem, memo|
memo[elem.odd? ? :odd : :even] << elem
end
// vigenere.c by Mark J. Rigdon
// CS50
// 2018-12-16
// Program encrypts messages using Vigenere's cipher.
// Includes
#include <cs50.h>
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
// caesar.c by Mark J. Rigdon
// CS50
// 2018-12-16
// Program encrypts messages using Caesar's cipher.
// Includes
#include <cs50.h>
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
// Mark J Rigdon
// 2018-12-11
// Problem set 1
// Creates a half right-aligned pyramid for Mario
#include <cs50.h>
#include <stdio.h>
int main(void)
{
// Mark J Rigdon
// 2018-12-11
// Problem set 1
// Creates a half right-aligned pyramid and a left-aligned pyramid for Mario
#include <cs50.h>
#include <stdio.h>
int main(void)
{
// Mark J Rigdon
// 2018-12-11
// Problem set 1
// Program calculates the minimum number of coins required to give a user change.
// Greedy algorithm example...
#include <cs50.h>
#include <math.h>
#include <stdio.h>
def reverse_string(string)
split_string = string.split("")
reversed = []
string.size.times { reversed << split_string.pop }
reversed.join
end
puts reverse_string("codelabslone")