Skip to content

Commit 64133c9

Browse files
committed
codeEval work
1 parent a1a7c12 commit 64133c9

80 files changed

Lines changed: 1183 additions & 419 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

codeeval/.tags

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
read_sequences /Users/samgerber/Documents/aA/aa-prep-work/codeeval/easy/05_detecting_cycles/lib/05_detecting_cycles.rb /^def read_sequences(filename)$/;" method line:1
2+
find_sequence /Users/samgerber/Documents/aA/aa-prep-work/codeeval/easy/05_detecting_cycles/lib/05_detecting_cycles.rb /^def find_sequence(list)$/;" method line:8
3+
find_sequences /Users/samgerber/Documents/aA/aa-prep-work/codeeval/easy/05_detecting_cycles/lib/05_detecting_cycles.rb /^def find_sequences(filename)$/;" method line:19

codeeval/.tags1

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
!_TAG_FILE_FORMAT 2 /extended format; --format=1 will not append ;" to lines/
2+
!_TAG_FILE_SORTED 0 /0=unsorted, 1=sorted, 2=foldcase/
3+
!_TAG_PROGRAM_AUTHOR Darren Hiebert /dhiebert@users.sourceforge.net/
4+
!_TAG_PROGRAM_NAME Exuberant Ctags //
5+
!_TAG_PROGRAM_URL http://ctags.sourceforge.net /official site/
6+
!_TAG_PROGRAM_VERSION 5.8 //
7+
read_sequences /Users/samgerber/Documents/aA/aa-prep-work/codeeval/easy/05_detecting_cycles/lib/05_detecting_cycles.rb /^def read_sequences(filename)$/;" method line:1
8+
find_sequence /Users/samgerber/Documents/aA/aa-prep-work/codeeval/easy/05_detecting_cycles/lib/05_detecting_cycles.rb /^def find_sequence(list)$/;" method line:8
9+
find_sequences /Users/samgerber/Documents/aA/aa-prep-work/codeeval/easy/05_detecting_cycles/lib/05_detecting_cycles.rb /^def find_sequences(filename)$/;" method line:19
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1.9.3-p551
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
source "https://rubygems.org"
2+
3+
gem "debugger"
4+
gem "rspec"
5+
gem 'guard-rspec'
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
GEM
2+
remote: https://rubygems.org/
3+
specs:
4+
coderay (1.1.0)
5+
columnize (0.9.0)
6+
debugger (1.6.8)
7+
columnize (>= 0.3.1)
8+
debugger-linecache (~> 1.2.0)
9+
debugger-ruby_core_source (~> 1.3.5)
10+
debugger-linecache (1.2.0)
11+
debugger-ruby_core_source (1.3.8)
12+
diff-lcs (1.2.5)
13+
ffi (1.9.10)
14+
formatador (0.2.5)
15+
guard (2.13.0)
16+
formatador (>= 0.2.4)
17+
listen (>= 2.7, <= 4.0)
18+
lumberjack (~> 1.0)
19+
nenv (~> 0.1)
20+
notiffany (~> 0.0)
21+
pry (>= 0.9.12)
22+
shellany (~> 0.0)
23+
thor (>= 0.18.1)
24+
guard-compat (1.2.1)
25+
guard-rspec (4.6.4)
26+
guard (~> 2.1)
27+
guard-compat (~> 1.1)
28+
rspec (>= 2.99.0, < 4.0)
29+
listen (3.0.5)
30+
rb-fsevent (>= 0.9.3)
31+
rb-inotify (>= 0.9)
32+
lumberjack (1.0.9)
33+
method_source (0.8.2)
34+
nenv (0.2.0)
35+
notiffany (0.0.8)
36+
nenv (~> 0.1)
37+
shellany (~> 0.0)
38+
pry (0.10.3)
39+
coderay (~> 1.1.0)
40+
method_source (~> 0.8.1)
41+
slop (~> 3.4)
42+
rb-fsevent (0.9.6)
43+
rb-inotify (0.9.5)
44+
ffi (>= 0.5.0)
45+
rspec (3.2.0)
46+
rspec-core (~> 3.2.0)
47+
rspec-expectations (~> 3.2.0)
48+
rspec-mocks (~> 3.2.0)
49+
rspec-core (3.2.3)
50+
rspec-support (~> 3.2.0)
51+
rspec-expectations (3.2.1)
52+
diff-lcs (>= 1.2.0, < 2.0)
53+
rspec-support (~> 3.2.0)
54+
rspec-mocks (3.2.1)
55+
diff-lcs (>= 1.2.0, < 2.0)
56+
rspec-support (~> 3.2.0)
57+
rspec-support (3.2.2)
58+
shellany (0.0.1)
59+
slop (3.6.0)
60+
thor (0.19.1)
61+
62+
PLATFORMS
63+
ruby
64+
65+
DEPENDENCIES
66+
debugger
67+
guard-rspec
68+
rspec
69+
70+
BUNDLED WITH
71+
1.11.2
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# A sample Guardfile
2+
# More info at https://github.com/guard/guard#readme
3+
4+
## Uncomment and set this to only include directories you want to watch
5+
# directories %w(app lib config test spec features) \
6+
# .select{|d| Dir.exists?(d) ? d : UI.warning("Directory #{d} does not exist")}
7+
8+
## Note: if you are using the `directories` clause above and you are not
9+
## watching the project directory ('.'), then you will want to move
10+
## the Guardfile to a watched dir and symlink it back, e.g.
11+
#
12+
# $ mkdir config
13+
# $ mv Guardfile config/
14+
# $ ln -s config/Guardfile .
15+
#
16+
# and, you'll have to watch "config/Guardfile" instead of "Guardfile"
17+
18+
# Note: The cmd option is now required due to the increasing number of ways
19+
# rspec may be run, below are examples of the most common uses.
20+
# * bundler: 'bundle exec rspec'
21+
# * bundler binstubs: 'bin/rspec'
22+
# * spring: 'bin/rspec' (This will use spring if running and you have
23+
# installed the spring binstubs per the docs)
24+
# * zeus: 'zeus rspec' (requires the server to be started separately)
25+
# * 'just' rspec: 'rspec'
26+
27+
guard :rspec, cmd: "bundle exec rspec" do
28+
require "guard/rspec/dsl"
29+
dsl = Guard::RSpec::Dsl.new(self)
30+
31+
# Feel free to open issues for suggestions and improvements
32+
33+
# RSpec files
34+
rspec = dsl.rspec
35+
watch(rspec.spec_helper) { rspec.spec_dir }
36+
watch(rspec.spec_support) { rspec.spec_dir }
37+
watch(rspec.spec_files)
38+
39+
# Ruby files
40+
ruby = dsl.ruby
41+
dsl.watch_spec_files_for(ruby.lib_files)
42+
43+
# Rails files
44+
rails = dsl.rails(view_extensions: %w(erb haml slim))
45+
dsl.watch_spec_files_for(rails.app_files)
46+
dsl.watch_spec_files_for(rails.views)
47+
48+
watch(rails.controllers) do |m|
49+
[
50+
rspec.spec.("routing/#{m[1]}_routing"),
51+
rspec.spec.("controllers/#{m[1]}_controller"),
52+
rspec.spec.("acceptance/#{m[1]}")
53+
]
54+
end
55+
56+
# Rails config changes
57+
watch(rails.spec_helper) { rspec.spec_dir }
58+
watch(rails.routes) { "#{rspec.spec_dir}/routing" }
59+
watch(rails.app_controller) { "#{rspec.spec_dir}/controllers" }
60+
61+
# Capybara features specs
62+
watch(rails.view_dirs) { |m| rspec.spec.("features/#{m[1]}") }
63+
watch(rails.layouts) { |m| rspec.spec.("features/#{m[1]}") }
64+
65+
# Turnip features and steps
66+
watch(%r{^spec/acceptance/(.+)\.feature$})
67+
watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) do |m|
68+
Dir[File.join("**/#{m[1]}.feature")][0] || "spec/acceptance"
69+
end
70+
end
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2
2+
Hello World
3+
CodeEval
4+
Quick Fox
5+
A
6+
San Francisco
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
def longest_lines(filename)
2+
lines = File.readlines(filename).map(&:chomp)
3+
4+
how_many = lines.shift.to_i
5+
6+
lines.sort! do | short, long |
7+
long.length <=> short.length
8+
end
9+
10+
lines.first(how_many)
11+
end
12+
13+
if $PROGRAM_NAME == __FILE__
14+
filename = ARGV[0]
15+
puts longest_lines(filename)
16+
end
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
require "02_longest_lines.rb"
2+
3+
# Write a program which reads a file and prints to stdout the
4+
# specified number of the longest lines that are sorted based
5+
# on their length in descending order.
6+
#
7+
# INPUT SAMPLE:
8+
#
9+
# Your program should accept a path to a file as its first argument.
10+
# The file contains multiple lines. The first line indicates the
11+
# number of lines you should output, the other lines are of different
12+
# length and are presented randomly. You may assume that the input
13+
# file is formatted correctly and the number in the first line is a
14+
# valid positive integer.
15+
#
16+
# For example:
17+
#
18+
# Hello World
19+
# CodeEval
20+
# Quick Fox
21+
# A
22+
# San Francisco
23+
#
24+
# OUTPUT SAMPLE:
25+
#
26+
# Print out the longest lines limited by specified number and sorted
27+
# by their length in descending order.
28+
#
29+
# For example:
30+
#
31+
# San Francisco
32+
# Hello World
33+
34+
describe "the longest_lines method" do
35+
it "returns the two longest lines" do
36+
filename = 'assets/02_longest_lines_sample.txt'
37+
lines = ['San Francisco',
38+
'Hello World']
39+
40+
expect(longest_lines(filename)).to eq(lines)
41+
end
42+
end
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1.9.3-p551

0 commit comments

Comments
 (0)