diff --git a/_config.yml b/_config.yml index 33bc03d..ca43969 100644 --- a/_config.yml +++ b/_config.yml @@ -2,7 +2,7 @@ name: SILShack Spring 2014 pygments: true markdown: redcarpet redcarpet: - extensions: ["no_intra_emphasis", "fenced_code_blocks", "autolink", "tables", "with_toc_data"] + extensions: ["no_intra_emphasis", "fenced_code_blocks", "autolink", "tables", "with_toc_data", "strikethrough"] timezone: America/New_York diff --git a/_drafts/2014-01-22-simplyhowto.md b/_drafts/2014-01-22-simplyhowto.md deleted file mode 100644 index 0059df1..0000000 --- a/_drafts/2014-01-22-simplyhowto.md +++ /dev/null @@ -1,94 +0,0 @@ ---- -author: grant -layout: post -title: Getting Started with Simple -published: false ---- - - -Hi Guys! Today we're going to make a blog on Heroku. - -[TOC] - -## Simple in Nitrous.io - -First thing, go the [Nitrous.io](https://www.nitrous.io/join/R2AIjhSAO64) and log in using Github. - -Now got to **Boxes** and [create a box](https://www.nitrous.io/app#/intro/create). The type doesn't really matter, but Django is probably best for us right now. - -Don't worry, you don't need to pay for more N2O, the free 155 is more than enough to do everything we need to do for our class. - -Now your box is running you can click on it and click **Terminal**. - -Now you should be looking at a black screen with a cursor on it. something like this: -![terminal](http://i.imgur.com/nKH2jtN.png) - -In front of you is a full-fledge linux/unix terminal with all the power therein. This is where we will be spending the rest of the semester. - -Now we are going to load and run a simple python-based blogging application. So simple in fact, it's named [Simple](https://github.com/orf/simple). - -First, in Nitrous, go to **Boxes**, select your box and click **Reveal Public Key**. This lets us access a secure encryption key we will find useful later. You should also click **Add to GitHub** which will share that key with GitHub and make things just a little bit easier. - -Now to getting the blog up and running. In the Nitrous terminal (or the Nitrous IDE console): - -```bash -$ mkdir silshack #make a new directory -$ cd silshack #move into the silshack directory -$ git clone https://github.com/sils/simple.git #get the simple blog -$ cd simple -$ pip install --user -r requirements.txt #install all of our required libraries, this will produce errors, don’t worry. -$ python create_config.py --fresh #configure your blog -$ python simple.py -``` - -Now go to **Preview** and **Port 4000**. Pretty cool, eh? - -## Simple on Heroku - -Nitrous is very useful for development and testing, but because we are on a free account, your box will shutdown after about 6 hours of inactivity. So we can't use it to host things we want other people to see. - -To host our site so other can see it we are going to use [Heroku](http://heroku.com), a really cool Platform as a Service that lets us test and host all kinds of web apps for free. - -Go to [Heroku](https://id.heroku.com/signup/www-header) and [sign up for an account](https://id.heroku.com/signup/www-header). Confirm your account and sign in. - -A free account is more than good enough for our purposes. - -Create a new app - -![heroku new app](http://i.imgur.com/IU9gEFV.png) - -Name it something you can remember, preferably **SILSHACK-_GITHUBNAME_** - -Back in Nitrous.io, in your _simple/_ directory do the following -Don't copy and paste, because it will want responses for some of these. - -```bash -$ heroku login -$ heroku keys:add -$ git config --global user.email “(your git email)” #use the email you use on github -$ git config --global user.name “(your git username)” #use the name you use on github -$ git commit -am "Updated config" #We are saving the changes you made to the config earlier -$ git remote add heroku git@heroku.com:(appname).git -$ git push heroku master -``` - -Now go to _http://appname.herokuapp.com_ and see your working blog in action. - -## What's Next? - -Now, it's up to you. Go look at _simple.py_. That is the entire application running your blog. Break it, experiment with it, do something completely different. - -Simple is built with [Flask](http://flask.pocoo.org/) A really cool and really simple Python Web Framework. - -For your assignment, make a short blog post on Github linking to your herokuapp. Try to change Simple.py in an interesting way. You can edit the css or javascript too. - -Be bold. Flask is really powerful. You can do some really cool things with it. - -# Your assignment -A post, on Github, with a pull request into [silshack/spring2014](https://github.com/silshack/spring2014) with the following: - -1. A link to your Heroku app running Simple - -2. A brief description of the process of getting your instance of Simple onto Heroku - -3. Something cool you did to Simple, the relevant source code and a description. The cooler the better. diff --git a/_posts/2013-01-02-brittanysanotherbranchtest.md b/_posts/2013-01-02-brittanysanotherbranchtest.md new file mode 100644 index 0000000..540d440 --- /dev/null +++ b/_posts/2013-01-02-brittanysanotherbranchtest.md @@ -0,0 +1,7 @@ +--- +layout: post +author: brittany +title: Another Branch test post +--- + +##Testing another branch test post \ No newline at end of file diff --git a/_posts/2013-01-25-sunhwaanotherbranch.md b/_posts/2013-01-25-sunhwaanotherbranch.md new file mode 100644 index 0000000..8f13839 --- /dev/null +++ b/_posts/2013-01-25-sunhwaanotherbranch.md @@ -0,0 +1,7 @@ +--- +layout: post +author: grant +title: another post test branching +--- + +branching is useful. \ No newline at end of file diff --git a/_posts/2013-03-05-julieseiferttestpost.md b/_posts/2013-03-05-julieseiferttestpost.md new file mode 100644 index 0000000..95147ce --- /dev/null +++ b/_posts/2013-03-05-julieseiferttestpost.md @@ -0,0 +1,6 @@ +--- +layout: post +author: julie +title: Julie's First Post from a Branch +--- + diff --git a/_posts/2014-01-01-XuxiangTestsPost.md b/_posts/2014-01-01-XuxiangTestsPost.md new file mode 100644 index 0000000..ac55cc0 --- /dev/null +++ b/_posts/2014-01-01-XuxiangTestsPost.md @@ -0,0 +1,11 @@ +--- +layout: post +author: xuxiang +date: 2014-01-01 +title: Test Post! +--- + +## Test Post + +This is a test. +Dont care about it. \ No newline at end of file diff --git a/_posts/2014-01-01-bdferrtestpost2.md b/_posts/2014-01-01-bdferrtestpost2.md new file mode 100644 index 0000000..2207aa5 --- /dev/null +++ b/_posts/2014-01-01-bdferrtestpost2.md @@ -0,0 +1,7 @@ +--- +layout : post +author : bdferr +title : another test post +--- + +This is an in-class test post. \ No newline at end of file diff --git a/_posts/2014-01-01-brittanystestpost.md b/_posts/2014-01-01-brittanystestpost.md new file mode 100644 index 0000000..3b3598c --- /dev/null +++ b/_posts/2014-01-01-brittanystestpost.md @@ -0,0 +1,10 @@ +--- +layout: post +author: brittany +date: 2014-01-01 +title: brittany's latest test post +--- + +##Test post + +This is a test. \ No newline at end of file diff --git a/_posts/2014-01-01-chunxitest.md b/_posts/2014-01-01-chunxitest.md new file mode 100644 index 0000000..c6ae8d6 --- /dev/null +++ b/_posts/2014-01-01-chunxitest.md @@ -0,0 +1,10 @@ +--- +layout: post +author: chunxigit +title: Chunxi's Test +date: 2014-01-01 +--- + +## Test Post + +Here is the test. \ No newline at end of file diff --git a/_posts/2014-01-01-mandystestypost.md b/_posts/2014-01-01-mandystestypost.md new file mode 100644 index 0000000..cafb1b6 --- /dev/null +++ b/_posts/2014-01-01-mandystestypost.md @@ -0,0 +1,9 @@ +--- +layout: post +author: agooch +title: Mandy's Test Posts Through Nitrous +--- + +## Test Post through Nitrous + +Here is my test post. \ No newline at end of file diff --git a/_posts/2014-01-01-newpost.md b/_posts/2014-01-01-newpost.md new file mode 100644 index 0000000..83cb8cf --- /dev/null +++ b/_posts/2014-01-01-newpost.md @@ -0,0 +1,10 @@ +--- +layout: post +author: laura +date: 2014-01-01 +title: testPost! + +--- +## Test Post + +This is a test post. \ No newline at end of file diff --git a/_posts/2014-01-01-oaktestpost.md b/_posts/2014-01-01-oaktestpost.md new file mode 100644 index 0000000..c47b6e7 --- /dev/null +++ b/_posts/2014-01-01-oaktestpost.md @@ -0,0 +1,9 @@ +--- +layout: post +author: blucka12 +title: Test Post +--- + +##Test Post + +This is also a test... \ No newline at end of file diff --git a/_posts/2014-01-01-sophiatestpost2.md b/_posts/2014-01-01-sophiatestpost2.md new file mode 100644 index 0000000..5fda577 --- /dev/null +++ b/_posts/2014-01-01-sophiatestpost2.md @@ -0,0 +1,9 @@ +--- +layout: post +author: slaffer +title: Sophia Nitrious test post 2 +--- + +##Test Post Nitrious #2 + +Test post number 2. Getting more practice with making a post on Nitrious. \ No newline at end of file diff --git a/_posts/2014-01-01-sunhwatestpost.md b/_posts/2014-01-01-sunhwatestpost.md new file mode 100644 index 0000000..af2faf2 --- /dev/null +++ b/_posts/2014-01-01-sunhwatestpost.md @@ -0,0 +1,10 @@ +--- +layout: post +author: sunhwap +date: 2014-01-01 +title: test post! +--- + +## Test Post + +This is a test. diff --git a/_posts/2014-01-16-turtledrawing.md b/_posts/2014-01-16-turtledrawing.md index ec3a89a..4e87104 100644 --- a/_posts/2014-01-16-turtledrawing.md +++ b/_posts/2014-01-16-turtledrawing.md @@ -1,7 +1,7 @@ --- layout: post author: laura -title: Laura’s Turtle Exercise: a silly drawing +title: "Laura’s Turtle Exercise, a silly drawing" --- ``` diff --git a/_posts/2014-01-30-ThuMaiListsStrings.md b/_posts/2014-01-30-ThuMaiListsStrings.md index e4f2d5b..b54fe6a 100644 --- a/_posts/2014-01-30-ThuMaiListsStrings.md +++ b/_posts/2014-01-30-ThuMaiListsStrings.md @@ -260,7 +260,7 @@ main() **Output:** -![Arrowhead image](https://lh5.googleusercontent.com/-T9wi6fD_tKI/Uuqf5SyrwTI/AAAAAAAAA7o/FnJjuTEbnoE/w415-h414-no/arrowhead.png) +![Arrowhead image](https://lh3.googleusercontent.com/-xundALvps9Y/UvOWIwbc3KI/AAAAAAAAA9g/6QBpM7oohYY/w415-h414-no/arrowhead.png) *** @@ -330,7 +330,7 @@ main() **Output:** -![PeanoGosper image](https://lh4.googleusercontent.com/-rWtGuM3yRgc/Uuqf6Fz4HmI/AAAAAAAAA7w/U2QmjkJn2Zk/w414-h412-no/peano-gosper.png) +![PeanoGosper image](https://lh5.googleusercontent.com/-bM4ADJ8KhsI/Uwq086HU0fI/AAAAAAAABBA/x12IaLsWYmQ/s410-no/peano-gosper.png) *** *** @@ -553,7 +553,7 @@ main() **Output:** -![Herb image](https://lh5.googleusercontent.com/-iEzm_iCtmqI/UuqfrKepcDI/AAAAAAAAA7U/JxqjAKiI2HQ/w413-h411-no/herb.png) +![Herb image](https://lh4.googleusercontent.com/-yCSU0NQMIC8/UvOWPAzTNEI/AAAAAAAAA94/SOhVwsd86K8/w413-h411-no/herb.png) *** @@ -629,6 +629,6 @@ main() **Output:** -![Branch image](https://lh3.googleusercontent.com/-XLmV9qqxgbg/Uuqfrb6jqCI/AAAAAAAAA7Q/aWaLicqWZPM/w413-h410-no/branch.png) +![Branch image](https://lh6.googleusercontent.com/-X_0ltn04nqc/UvOWMswAagI/AAAAAAAAA9s/EdsVXiXVqqU/w413-h410-no/branch.png) *** diff --git a/_posts/2014-02-05-Laura-testint-nitrous.md b/_posts/2014-02-05-Laura-testint-nitrous.md new file mode 100644 index 0000000..4caf249 --- /dev/null +++ b/_posts/2014-02-05-Laura-testint-nitrous.md @@ -0,0 +1,14 @@ +--- +layout: post +author: laura +title: Testing Nitrous +date: 2014-02-19 +--- + +## Hi! + +{% include python %} + +print ("Hi I am python code.") + +{% include endpython %} \ No newline at end of file diff --git a/_posts/2014-02-05-Leitestytest.md b/_posts/2014-02-05-Leitestytest.md new file mode 100644 index 0000000..c33bd78 --- /dev/null +++ b/_posts/2014-02-05-Leitestytest.md @@ -0,0 +1,13 @@ +--- +author: lei +title: A very cool title for a test post +layout: post +--- + +## Lei Wang + +{% include python %} + +print("I'm Python code") + +{% include endpython %} \ No newline at end of file diff --git a/_posts/2014-02-05-ThuMaiNitrous.md b/_posts/2014-02-05-ThuMaiNitrous.md new file mode 100644 index 0000000..8ef160e --- /dev/null +++ b/_posts/2014-02-05-ThuMaiNitrous.md @@ -0,0 +1,16 @@ +--- +author: tlchristian +title: Thu-Mai's First Post via Nitrous +layout: post +date: 2014-02-19 +--- + +This is how we do it. + +{% include python %} + +print("Insert Python code here.") + +{% include endpython %} + +--- \ No newline at end of file diff --git a/_posts/2014-02-05-bdferrsamplenewpost.md b/_posts/2014-02-05-bdferrsamplenewpost.md new file mode 100644 index 0000000..0dd87a8 --- /dev/null +++ b/_posts/2014-02-05-bdferrsamplenewpost.md @@ -0,0 +1,10 @@ +--- +layout: post +author: bdferr +title: This is only a test; do not be alarmed. +date: 2014-02-19 +--- +# There is nothing of importance to put in this post. +{% include python %} +print("I am doing something with Python") +{% include endpython %} \ No newline at end of file diff --git a/_posts/2014-02-05-brittanytest.md b/_posts/2014-02-05-brittanytest.md new file mode 100644 index 0000000..3e40e22 --- /dev/null +++ b/_posts/2014-02-05-brittanytest.md @@ -0,0 +1,14 @@ +--- +author: brittany +title: Brittany's nitrous test post +layout: post +date: 2014-02-19 +--- + +##Test post + +{% include python%} + +print("I'm python code") + +{% include endpython %} \ No newline at end of file diff --git a/_posts/2014-02-05-juliesboxpost.md b/_posts/2014-02-05-juliesboxpost.md new file mode 100644 index 0000000..0e0e01c --- /dev/null +++ b/_posts/2014-02-05-juliesboxpost.md @@ -0,0 +1,14 @@ +--- +author: julie +title: Julie's post from the Nitrous box +layout: post +date: 2014-02-19 +--- + +Here is my post. doo dodoo + +{% include python %} + +print("I'm Python code") + +{% include endpython %} diff --git a/_posts/2014-02-05-madelinetest.md b/_posts/2014-02-05-madelinetest.md new file mode 100644 index 0000000..34b50bd --- /dev/null +++ b/_posts/2014-02-05-madelinetest.md @@ -0,0 +1,14 @@ +--- +author: madeline +title: Our house is a very very very fine house +layout: post +date: 2014-02-19 +--- + +## That song is stuck in my head. + +{% include python %} + +print("I'm Python code!") + +{% include endpython %} diff --git a/_posts/2014-02-05-mandynitroustestpost.md b/_posts/2014-02-05-mandynitroustestpost.md new file mode 100644 index 0000000..2348530 --- /dev/null +++ b/_posts/2014-02-05-mandynitroustestpost.md @@ -0,0 +1,16 @@ +--- +author: agooch +layout: post +title: Mandy's Nitrous Test Post +date: 2014-02-19 +--- + +## This is my test post! ## + +It is pretty basic. + +{% include python %} + +print("I'm Python code") + +{% include endpython %} \ No newline at end of file diff --git a/_posts/2014-02-05-sierrapost.md b/_posts/2014-02-05-sierrapost.md new file mode 100644 index 0000000..d429e8e --- /dev/null +++ b/_posts/2014-02-05-sierrapost.md @@ -0,0 +1,14 @@ +--- +author: srmoore5 +title: Nitrous Post +layout: post +date: 2014-02-19 +--- + +## Welcome to the Strange Crystal Cave! + +{% include python %} + +print("I'm Python code") + +{% include endpython %} \ No newline at end of file diff --git a/_posts/2014-02-05-sophiatestpost.md b/_posts/2014-02-05-sophiatestpost.md new file mode 100644 index 0000000..ad99433 --- /dev/null +++ b/_posts/2014-02-05-sophiatestpost.md @@ -0,0 +1,15 @@ +--- +author: slaffer +title: Sophia's Test Post Nitrous +layout: post +date: 2014-02-19 +--- + +Test post from Nitrous. Learning to write in command line! + +{% include python %} + +print("This is awesomeness") + +{% include endpython %} + diff --git a/_posts/2014-02-05-test.md b/_posts/2014-02-05-test.md new file mode 100644 index 0000000..9f7f054 --- /dev/null +++ b/_posts/2014-02-05-test.md @@ -0,0 +1,14 @@ +--- +author: libbby +layout: post +title: Libby Test Post +date: 2014-02-19 +--- + +TEXT, BAM + +{% include python %} + +print("I'm python code") + +{% include endpython %} \ No newline at end of file diff --git a/_posts/2014-02-05-testest.md b/_posts/2014-02-05-testest.md new file mode 100644 index 0000000..80b9c36 --- /dev/null +++ b/_posts/2014-02-05-testest.md @@ -0,0 +1,14 @@ +--- +author: xuxiang +title: Xuxiang's test post by nitrous +layout: post +date: 2014-02-19 +--- + +## Hi! + +{% include python %} + +print("I'm Python code") + +{% include endpython %} \ No newline at end of file diff --git a/_posts/2014-02-05-testtesty.md b/_posts/2014-02-05-testtesty.md new file mode 100644 index 0000000..f503b5a --- /dev/null +++ b/_posts/2014-02-05-testtesty.md @@ -0,0 +1,14 @@ +--- +author: sunhwap +title: sunhwa's a very cool title for a test post +layout: post +date: 2014-02-19 +--- + +## Hi ! + +{% include python %} + +print("I am Python code") + +{% include endpython %} \ No newline at end of file diff --git a/_posts/2014-02-05-testytest.md b/_posts/2014-02-05-testytest.md new file mode 100644 index 0000000..145bf64 --- /dev/null +++ b/_posts/2014-02-05-testytest.md @@ -0,0 +1,12 @@ +--- +author: chunxi +title: just a test +layout: post +date: 2014-02-19 +--- +Just a test + +## Hi! + + + diff --git a/_posts/2014-02-05-yonghaotesttest.md b/_posts/2014-02-05-yonghaotesttest.md new file mode 100644 index 0000000..83b8d66 --- /dev/null +++ b/_posts/2014-02-05-yonghaotesttest.md @@ -0,0 +1,12 @@ +--- +author: yonghao +title: Yoooonghao A very cool title for test +layout: post +date: 2014-02-19 +--- + +## It's just a test + +{% include python %} +print("test python") +{% include endpython %} \ No newline at end of file diff --git a/_posts/2014-02-05-zachTest.md b/_posts/2014-02-05-zachTest.md new file mode 100644 index 0000000..86e8467 --- /dev/null +++ b/_posts/2014-02-05-zachTest.md @@ -0,0 +1,12 @@ +--- +author: zbay +title: Dr. Test M.D. +layout: post +date: 2014-02-19 +--- + +{% include python %} + +print("I'm Python code") + +{% include endpython %} \ No newline at end of file diff --git a/_posts/2014-02-09-codingbatsierra.md b/_posts/2014-02-09-codingbatsierra.md index b130455..5f176a9 100644 --- a/_posts/2014-02-09-codingbatsierra.md +++ b/_posts/2014-02-09-codingbatsierra.md @@ -2,7 +2,7 @@ layout: post author: srmoore5 title: Coding Bat Lists/strings/logic/warmup -date: 02/09/14 +date: 2014-02-09 --- Screenshots: @@ -20,6 +20,7 @@ Favorite exercises: String-1 Withoutend + ``` def without_end(str): return str[1:-1] @@ -28,6 +29,7 @@ def without_end(str): List-1 Has23 + ``` def has23(nums): @@ -43,6 +45,7 @@ def has23(nums): Logic-1 Sorta sum + ``` def sorta_sum(a, b): diff --git a/_posts/2014-02-12-sunhwacodingbatexercises2.md b/_posts/2014-02-12-sunhwacodingbatexercises2.md new file mode 100644 index 0000000..020df31 --- /dev/null +++ b/_posts/2014-02-12-sunhwacodingbatexercises2.md @@ -0,0 +1,93 @@ +--- +layout: post +author: sunhwap +title: the seond codingbat exercises +date: 2014-02-12 +--- + +## Screenshot-warm-up 2 + + + +![warmup picture]( http://www.unc.edu/~sunhwa/560/warmup-2.PNG) + + +## Screenshot-string 2 + + + +![string picture]( http://www.unc.edu/~sunhwa/560/string2.PNG) + + + +## Screenshot-list 2 + + + +![list picture]( http://www.unc.edu/~sunhwa/560/list-2.PNG) + + + +## Screenshot-logic 2 + + + +![logic picture]( http://www.unc.edu/~sunhwa/560/logic2.PNG) + + + +## 1st exercise that I liked- + + The first one that I liked is warmup exercise called string_match because even though + my for-loop was almost right syntax wise, I could not initially thnk of the important fact that + the upper bound of the range for for loop has to do with length of the smaller string. So this + was a new learning experience. + + ``` +def string_match(a, b): + length_min = min(len(a), len(b)) + + count = 0 + for i in range(length_min-1): + if a[i:i+2] == b[i:i+2]: + count=count+ 1 + return count +``` +## 2nd one + +The second one that I liked is the string exercise called count_code because it took a while +for me to realize that I made a mistake in putting the upper limit as i+1 rather than i+2 +for "co". So this problem helped me to be very careful about the upper limit of string index. + +``` +def count_code(str): + + count=0 + for i in range(len(str)-3): + if str[i:i+2]=="co" and str[i+3]=='e': + count=count+1 + + return count +``` + +## third one + +The third one that I liked is called make_chocolate because it took a while for me to get it +right because I made a mistake in the nested if of the else statement, and an indentation +error for the last return. Overall, the second codingbat exercises took longer than the +first ones becasue most of them were harder. + +``` +def make_chocolate(small, big, goal): + bigHigh=goal/5 + if big>= bigHigh: + if small>=(goal-bigHigh*5): + return goal-bigHigh*5 + else: + if small >= (goal-big*5): + return goal - big*5 + + return -1 +``` + + diff --git a/_posts/2014-02-14-ChunxiCodingBat2.md b/_posts/2014-02-14-ChunxiCodingBat2.md new file mode 100644 index 0000000..9ac93a1 --- /dev/null +++ b/_posts/2014-02-14-ChunxiCodingBat2.md @@ -0,0 +1,109 @@ +--- +layout: post +author: chunxi +title: Chunxi's CodingBat2 +date: 2014-02-14 +--- + +Post by Chunxi Zhang + +## Chunxi's CodingBat2 + +**Choose three exercise.** + + +**1.String2-xyz_there** + + + This question did take me some time. I thought several different ways to express my idea. But I do not know a method which can + Then I change my thoughts. It could be 2 circumstances. If the 'xyz' is str[0:3], no matter where the '.' is, it will return + True. And if there are '.xyz', it will return false. I can use != to except the '.'. + + + ``` + def xyz_there(str): + for i in range(len(str)): + if str[i] != '.' and str[i+1:i+4] == 'xyz': + return True + if str[0:3] == 'xyz': + return True + return False + ``` + +**2.Logic2-make_bricks** + + + I am impressed with this question is because it took me some time to understand the request. After watching the vedio to understand +what brick means, I begin to code. The code isself is not hard. But it is problematic to know what exactly I want. + + ``` + def make_bricks(small, big, goal): + if goal % 5 >= 0 and goal % 5 - small <= 0 and small + 5*big >= goal: + return True + else: + return False + ``` + + +**3.Logic2-long_sum** + + This question is strightforward. But I spent more time on debugging. The original code of mine is + + ``` +def lone_sum(a, b, c): + + if a == b: + return c + if a == c: + return b + if b == c: + return a + if a == b == c: + return 0 + + else: + return a+b+c + + ``` + +However, it cannot pass the test. At first, I did not what is wrong. Then I read the test carefully and I found out all the problem +happened when a=b=c. So I noticed that the problem is about the order. a = b= c should be ordered first. + + ``` +def lone_sum(a, b, c): + if a == b == c: + return 0 + if a == b: + return c + if a == c: + return b + if b == c: + return a + + else: + return a+b+c + + ``` + + **Pictures** + + **warmup2** + + ![Image](http://farm3.staticflickr.com/2825/12522673384_ba1eac389f_m.jpg) + + **string2** + + ![Image](http://farm6.staticflickr.com/5516/12522685604_d424de12a5_m.jpg) + + **list2** + + ![Image](http://farm8.staticflickr.com/7348/12522205865_50f00c22f2_m.jpg) + + **logic2** + + ![Image](http://farm4.staticflickr.com/3789/12522217755_815f9b86cc_m.jpg) + + + + + diff --git a/_posts/2014-02-14-bdferrcodingbat2a.md b/_posts/2014-02-14-bdferrcodingbat2a.md new file mode 100644 index 0000000..c7236b3 --- /dev/null +++ b/_posts/2014-02-14-bdferrcodingbat2a.md @@ -0,0 +1,184 @@ +--- +layout: post +author: bdferr +title: CodingBat 2 +--- + +I realize I posted these in my first CodingBat post already, but here they are again. + +![Warmup-2 image](http://i.imgur.com/G9jiOfB.png) + +![Logic-2 image](http://i.imgur.com/fxqcvPP.png) + +![String-2 image](http://i.imgur.com/p5Dhx4y.png) + +In the List-2 section, I could not quite finish the sum67 problem, so after quite a bit of time working on it, +I am leaving it for now. As you can see, I did get it to partially work, and I did get the other problems +in that section done. + +![List-2 image](http://i.imgur.com/PyRVMk5.png) + +![Sum67 image](http://i.imgur.com/2KLaTod.png) + +The sum67 problem was particularly maddening, of course. The goal was to remove every item +in a string from a 6 to the next 7, and sum the results (the sum was easy enough). +I had two different versions of it, each of which passed 8 tests but failed the rest. +Both produce lists of the index positions of the 6s and 7s, and use them for iterative string concatenation. +My latest efforts to improve either of them resulted in either no change or error messages. +I actually ended up with more than two versions. +I suspect there is something fundamental which I am missing here. + +My first version manages to identify the 6s and 7s, but does not seem to recognize +the space between them; i.e. in a list like [6, 7, 8, 6, 7] it would return zero, where it should +return 8. It also does not recognize when the 7s are superfluous, i.e. in [9,6,7,7] it would give me +9 rather than 16. It looks like this: + +``` +def sum67(nums): + seven_found = False + n = 0 + start_slices = [] + end_slices = [] + b = 0 + six_count = nums.count(6) + seven_count = nums.count(7) + if nums == []: + return 0 + elif 6 not in nums and 7 not in nums: + return nums + else: + while six_count > 0 or seven_count > 0: + if nums[n] == 6: + start_slices += str(n) + n += 1 + six_count -= 1 + elif nums[n] == 7: + end_slices += str(n) + n += 1 + seven_count -= 1 + else: + n+=1 + for a in start_slices: + for b in end_slices: + nums = nums[:int(a)] + nums[int(b)+1:] + start_slices = start_slices[:int(a)] + start_slices[int(b)+1:] + end_slices = end_slices[:int(b)] + end_slices[int(b)+1:] + return sum(nums) +``` + +I made a second version in response to these problems, but it does not entirely solve them. +The details might be too complicated to fully explain in this post. Basically, though, +I want to (and apparently don't) have a function which can run two simultaneous for loops on two separate lists. +For example, if I have a list called lista [a, b, c, d] and a list called listb [w, x, y, z], I want my code +to generate the slices [a:w], [b:x], [c:y], and [d:z]. I know the slicing is a separate function, +but I need to be able to conection a with w, then b with x, and so on. +Nesting one for loop inside another is what I attempted in my first version, but it does not +seem to quite do the same thing. Instead I believe it generates [a:w], [a:x], [a:y], +a:z], and then [b:w], [b:x], and so on. This explains why what is removed includes what I did not +want to remove, when it is between two strings which I actually did want to remove. +I ultimately attempted several approximations but still can't seem to quite get this double loop function. +Here is one unsuccessful attempt. This version can’t seem to deal with multiple 6s and 7s, +not even recognizing anything beyond the first pair: + +``` +def sum67(nums): + n = 0 + b = 0 + start_slices = [] + end_slices = [] + six_count = nums.count(6) + seven_count = nums.count(7) + if nums == []: + return 0 + elif 6 not in nums and 7 not in nums: + return nums + else: + while six_count > 0 or seven_count > 0: + if nums[n] == 6: + start_slices += str(n) + n += 1 + six_count -= 1 + elif nums[n] == 7: + end_slices += str(n) + n += 1 + seven_count -= 1 + else: + n+=1 + for a in start_slices: + if end_slices[0] < a: # in other words if there is a 7 located before a 6 + end_slices = end_slices[1:] # remove it from the list of 7 positions, + # and don't do anything with it. + else: + nums = nums[:int(a)] + nums[int(end_slices[0])+1:] + if len(start_slices) > 1: + start_slices = start_slices[1:] + else: + start_slices = [] + if len(end_slices) > 1: + end_slices = end_slices[1:] + else: start_slices = [] + return sum(nums) +``` + + +This problem showed me that there are things I do not understand in programming, +even while I seem to understand all the relevant elements for that problem. + +I am sure everyone else will be saying the same thing, +but I honestly do agree with the founder of CodingBat that the MakeBricks problem +is particularly interesting. I initially attempted it using loops, +and got errors attempting a nested for loop. More importantly, though, +I noticed I was advised to do it without any iteration at all, which I found baffling. + +I restrained myself from watching the full video explaining it, and simply proceeded +based on the hint that I should use the modulus operator. After numerous attempts, +I realized that simply applying the modulus to the number 5 was not always appropriate. +If the goal divided by 5 was larger than the number of large bricks available, the result +would be misleading; if the number of small bricks was sufficient to cover the remainder, +it would give the false impression that the goal could be met. I found the use of the modulus +to completely replace iteration very interesting. My code looked like this: + +``` +def make_bricks(small, big, goal): + if small >= goal: + return True + elif big * 5 + small < goal: + return False + elif big != 0 and goal % (big * 5) <= small: + return True + elif big * 5 > goal and (goal % 5 == 0 or goal % 5 <= small): + return True + else: + return False +``` + + +I also enjoyed a similar problem, in which there was a goal number of kilos +of chocolate. One problem was that the instructions were not exactly clear, though. The line +"Return the number of small bars to use, assuming we always use big bars before small bars" +was particularly misleading. What they actually wanted, based on the test results, +was not that the big bars should all be used before beginning with the small bars, +and one test result showed that what they wanted was even farther removed than that: +“make_chocolate(4, 1, 4)” expects an answer of 4, when this clearly requires using no big bars at all. Possibly they forgot to say that big bars can be omitted when the goal is less than 5. +Regardless, I was able to solve this with similar curious applications of the modulus operator +to what I did in the Make Bricks problem. This was my code: + + +``` +def make_chocolate(small, big, goal): + if goal < 5 and small >= goal: + return small + elif goal < 5 and small < goal: + return -1 + elif small + big * 5 < goal: + return -1 + elif goal % (big * 5) <= small: + bars = goal - (big * 5) + return bars + else: + bars = goal % 5 + if small >= bars: + return bars + else: + return -1 +``` diff --git a/_posts/2014-02-14-sophiacodingbatexercises2.md b/_posts/2014-02-14-sophiacodingbatexercises2.md new file mode 100644 index 0000000..76b64cd --- /dev/null +++ b/_posts/2014-02-14-sophiacodingbatexercises2.md @@ -0,0 +1,71 @@ +--- +layout: post +author: slaffer +title: Sophia's CodingBat Marathon Part 2 +--- + +##Three Exercises + +**1. String: end_other** + +*Given two strings, return True if either of the strings appears at the very end of the other string, ignoring upper/lower case differences (in other words, the computation should not be "case sensitive"). Note: s.lower() returns the lowercase version of a string.* + +Many of these exercises were challenging for me. I liked this exercise because the hint provided by codingbat was very useful and I was able to come up with the solution in a relatively short time, which was a pleasant change from some of the other exercises (see below). + +``` +def end_other(a, b): + lower_a = a.lower() + lower_b = b.lower() + if lower_a.endswith(b.lower()): + return True + elif lower_b.endswith(a.lower()): + return True + else: + return False +``` + +**2. Lists: sum13** + +*Return the sum of the numbers in the array, returning 0 for an empty array. Except the number 13 is very unlucky, so it does not count and numbers that come immediately after a 13 also do not count.* + +This is an exercise that I thought I understood the concept but could not figure out the answer. I used my resources and found someone on stackoverflow who also had problems with this exercise, which can be found [here] (http://stackoverflow.com/questions/11059910/skipping-elements-in-a-list-python). Seeing the correct code supplied by a user helped me to better understand the problem. Although it wasn't as satisfying as figuring out the answer myself, walking through this code was a good learning experience. + +``` +def sum13(nums): + sum = 0 + skip = False + for i in nums: + if i == 13: + skip = True + continue + if skip: + skip = False + continue + sum += i + return sum +``` + +**3. Logic: make_chocolate** + +*We want make a package of goal kilos of chocolate. We have small bars (1 kilo each) and big bars (5 kilos each). Return the number of small bars to use, assuming we always use big bars before small bars. Return -1 if it can't be done.* + +A couple of the logic exercises also stumped me and I used this [blog](http://gregorulm.com/coding-bat-python-logic-2/) to help me work through the answers. After trying exercises for awhile and being stuck it was really a big help. On the making chocolate exercise I had not made the connection to add a variable ```maxBig``` that could be used to determine if there was enough big bars to meet the goal. After figuring this logical step out, I was able to modify my code in a way that made sense to me and solved the problem. + +``` +def make_chocolate(small, big, goal): + maxBig = goal/5 + + if small + big*5 < goal or small < goal%5: + return -1 + elif big >= maxBig: + return goal - maxBig*5 + elif big <= maxBig: + return goal - big*5 +``` + +##Screenshots of Checkmarks + +![warmup2](http://i.imgur.com/yk6FTzi.png) +![strings2](http://i.imgur.com/sCZGonm.png) +![lists2](http://i.imgur.com/x561iyJ.png) +![logic2](http://i.imgur.com/Sc05cJa.png) diff --git a/_posts/2014-02-14-yonghao's-codingbat2.md b/_posts/2014-02-14-yonghao's-codingbat2.md new file mode 100644 index 0000000..e4210e8 --- /dev/null +++ b/_posts/2014-02-14-yonghao's-codingbat2.md @@ -0,0 +1,131 @@ +--- +layout: post +author: yonghao +title: yonghao's Second Codingbat's Practice +--- + +# Screenshot: + +**Warmup 2:** + +![Warmup2 image](http://farm8.staticflickr.com/7434/12529756494_b08e97ea26_o.png) + +**String 2:** + +![String2 image](http://farm4.staticflickr.com/3744/12529756534_d129b99e22_o.png) + +**List 2:** + +![List2 image](http://farm4.staticflickr.com/3832/12529404723_27a6c49f18_o.png) + +**Logic 2:** + +![Logic2 image](http://farm4.staticflickr.com/3745/12529756604_dcca04846f_o.png) + +# Comments: + + + +**List 2, sum67** + +I tried several ways and finally make it work. + +At first, I write another def called delete 67, it looks like this: + +``` +def delete67: + pos6=-1 + pos7=-1 + for i in range(len(nums)-1): + if nums[i]==6: + pos6=i + break + for j in range(pos6,len(nums)-1): + if nums[j]==7 and j>pos6: + pos7=j + break + del nums[pos6:pos7+1] +``` +Then I try to call the function in main function, it works for all the test, but failed in "other test". +I dont know what is "other test" and can't solve it, so I change another way. + +My code: + +``` +def sum67(nums): + for i in range(0, len(nums)): + if nums[i] == 6: + nums[i] = 0 + for j in range(i+1, len(nums)): + if nums[j] == 7: + nums[j]=0 + i = j + 1 + break + else: + nums[j]=0 + return sum(nums) + +``` + +The code works. Can anyone help me to find the error in former function? + +**List2 centered_average:** + +My thought: Travel all the elements in list, and each time call min and max method. every time compare the current element with the current min/max number. +And get the new min/max number. After we travel the whole array, we can get the min and max number in the array. And when can use the sum of all the numbers in list minus min and max number. + +My code: + +``` +def centered_average(nums): + min_1=nums[0] + max_1=nums[0] + result=0 + for i in nums: + min_1=min(i,min_1) + max_1=max(i,max_1) + for i in nums: + result+=i + return (result-min_1-max_1)/(len(nums)-2) + +``` + +**Logic 2: Make_Bricks** + +It's a little hard. I try different ways to solve it, and finally, I got idea from the help video and use mod to solve it. +Fitstly, I tried to use a loop to solve it, my code like that: + +``` +for i in range(big): + if 5*i= goal + +``` +It has two steps to judge. +Firstly: judge weather bricks are enough: + +``` +small+5*big>=goal +``` + +Secondly: Judge weather small bricks is enough. + +``` +goal%5 - small <= 0 +``` + +Then the problem is solved. It's a gret idea to use mod, and I think mod will help me in the future! + + +**Logic 2: make_chocolate** + +The problem is similar to make_bricks and I use a similar method to solve it. diff --git a/_posts/2014-02-15-Lei_PythonBasics2.md b/_posts/2014-02-15-Lei_PythonBasics2.md new file mode 100644 index 0000000..88dc104 --- /dev/null +++ b/_posts/2014-02-15-Lei_PythonBasics2.md @@ -0,0 +1,88 @@ +--- +layout: post +author: lei +title: Lei Wang's CodingBat Exercise2 +date: 2014-02-15 +--- + +# The Exercises + +**1. The first one I found hard was the Logic-2 exercise called make_bricks. In some cases, it needs to use lots of little bricks instead of a big brick. Finally, I found it can be simply coded as following.** + +``` +def make_bricks(small, big, goal): + goal = goal - 5*min(big,goal/5) + return goal-small <= 0 +``` + +**2. The second one I liked is the Logic-2 exercise called lone_sum. At first, I thought I should list all situation it might happen as following.** + +``` +def lone_sum(a, b, c): + if a == b == c: + return 0 + elif a == b: + return c + elif a == c: + return b + elif b == c: + return a + else: + return a + b + c +``` + + +**However, we can use 'not in' which make the script much more brief and neat.** + + +``` +def lone_sum(a, b, c): + sum = 0 + if a not in [b,c]: + sum += a + if b not in [a,c]: + sum += b + if c not in [a,b]: + sum += c + return sum + +``` + +**3. I found the most hardest is list-2 exercise called sum67. A lot of cases should be taken into consideration. At first, I came up with a script as following.** + +``` +def sum67(nums): + for i in nums: + if 6 in nums: + six = nums.index(6) + seven = nums.index(7) + for i in range(six,seven+1): + nums.pop(six) + return sum(nums) +``` + +**However, it cannot pass if the first 7 comes before the first 6. Then, after several tries, I got the following solution which works fine!!** + + +``` +def sum67(nums): + sum = 0 + flag = True + for i in nums: + if i == 6: + flag = False + continue + if i == 7 and not flag: + flag = True + continue + if flag: + sum += i + return sum +``` + +# The Screenshots +Here are my screenshots: +![Warmup-1 screenshot] (http://www.unc.edu/~leiw/images/python/warmup2.jpg) +![Lists-1 screenshot] (http://www.unc.edu/~leiw/images/python/list2.jpg) +![Logic-1 screenshot] (http://www.unc.edu/~leiw/images/python/logic2.jpg) +![Strings-1 screenshot] (http://www.unc.edu/~leiw/images/python/string2.jpg) diff --git a/_posts/2014-02-15-libbycodingbat2.md b/_posts/2014-02-15-libbycodingbat2.md new file mode 100644 index 0000000..c065e41 --- /dev/null +++ b/_posts/2014-02-15-libbycodingbat2.md @@ -0,0 +1,62 @@ +--- +title: Libby's Coding Bat exercises, Part Deux +author: libbby +layout: post +--- + +# The Exercises +Some of these were real doozies. I would have been entirely lost on some, were it not for the long winded people on stackoverflow who like to correct each other & provide detailed explanations. + +### 1. String-2: double_char +This was one of the easier ones for me - I got all green on the first go. If only the logic problems went so painlessly... + +_Given a string, return a string where for every char in the original, there are two chars._ + +``` +def double_char(str): + result = '' + for letter in str: + result = result + letter*2 + return result + +``` + +### 2. Logic-2: make_bricks +Oh dear oh dear oh dear. This problem. +For something that is 6 lines of code, it was incredibly hard to work out. +The first thing we need to do, is determine if there actually enough bricks total to meet the goal, whether or not they are the right sizes. If not, it's an automatic False. +If there are enough, we need to then determine what the remainder is when you divide the goal by 5. If there are enough small bricks to cover the remainder, it's True. +Otherwise, False. + +_We want to make a row of bricks that is goal inches long. We have a number of small bricks (1 inch each) and big bricks (5 inches each). Return True if it is possible to make the goal by choosing from the given bricks. This is a little harder than it looks and can be done without any loops._ + +``` +def make_bricks(small, big, goal): + if goal > small + big*5: + return False + elif (goal%5 <= small): + return True + else: return False +``` + +### 3. Logic-2: no_teen_sum +This one took a little while, because for some reason I was getting hung up on what now looks like a really simple conditional. Just goes to show that taking a break can be VERY helpful when coding. + +_Given 3 int values, a b c, return their sum. However, if any of the values is a teen -- in the range 13..19 inclusive -- then that value counts as 0, except 15 and 16 do not count as a teens. Write a separate helper "def fix_teen(n):"that takes in an int value and returns that value fixed for the teen rule. In this way, you avoid repeating the teen code 3 times (i.e. "decomposition"). Define the helper below and at the same indent level as the main no_teen_sum()._ + +``` +def fix_teen(n): + if(n>12 and n < 20): + if(n != 15 and n != 16): + n = 0 + return n +def no_teen_sum(a, b, c): + return (fix_teen(a) + fix_teen(b) + fix_teen(c)) +``` + +# The Screenshots +Here are my screenshots: +![Warmup-2 screenshot] (http://i972.photobucket.com/albums/ae206/fluffbrain/INLS560/screen_warmup2.png) +![Lists-2 screenshot] (http://i972.photobucket.com/albums/ae206/fluffbrain/INLS560/screen_list2.png) +![Logic-2 screenshot] (http://i972.photobucket.com/albums/ae206/fluffbrain/INLS560/screen_logic2.png) +![Strings-2 screenshot] (http://i972.photobucket.com/albums/ae206/fluffbrain/INLS560/screen_string2.png) diff --git a/_posts/2014-02-15-lyonscodingbatp2.md b/_posts/2014-02-15-lyonscodingbatp2.md new file mode 100644 index 0000000..6fa1f97 --- /dev/null +++ b/_posts/2014-02-15-lyonscodingbatp2.md @@ -0,0 +1,127 @@ +--- +layout: post +author: allen +title: Allen Codingbat Exercises Part 2 +date: 2014-02-15 +--- + +These Codingbat exercises were a bit more complicated than the last set. But most +of them were still pretty short, even if they took longer to figure out. Here's +the screenshots + +## Warmups 2 + +![Warmup Checklist](http://i.imgur.com/rE4d9cN.png) + +I completed the Warmups. + +##Strings 2 + +![Warmup Checklist](http://i.imgur.com/r3mcHCz.png) + +I completed the Strings + +##Lists 2 + +![Warmup Checklist](http://i.imgur.com/F57XrrU.png) + +I completed the Lists + +##Logic 2 + +![Warmup Checklist](http://i.imgur.com/n5JI1qx.png) + +I completed the Logic! + +And here are 3 exercises I thought were interesting and/or challenging and/or +the first three exercises because I was lazy and didn't want to look around for +the ones that were actually difficult or interesting. + +##string_splosion + +* +Given a non-empty string like "Code" return a string like "CCoCodCode".* + +I just like the word stringsplosion. + +{% include python %} + +def string_splosion(str): + result = "" + for i in range(len(str)+1): + result = result + str[:i] + return result + +print string_splosion('Code') +print string_splosion('abc') +print string_splosion('ab') + +{% include endpython %} + +##array123 + +*Given an array of ints, return True if .. 1, 2, 3, .. appears in the array somewhere. * + +I like this problem because it shows how important it is to test for every possible +case that might be entered. In this problem I was able to get a checkmark and +complete the problem by doing this: + +``` +def array123(nums): + if 1 in nums and 2 in nums and 3 in nums: + return True + return False +``` + +However this ignores a really obvious case which is if the numbers 1, 2, and 3 +are all in the array but not in the order 1, 2, 3. Weirdly, codingbat did not test +for that case and so I was able to complete the problem using code that doesn't work +for all cases. + +Here's the actual solution: + + +``` +def array123(nums): + for i in range(len(nums)-2): + if nums[i]==1 and nums[i+1]==2 and nums[i+2]==3: + return True + return False +``` + +Output: + +``` +array123([1, 1, 2, 3, 1]) → True +array123([1, 1, 2, 4, 1]) → False +array123([1, 1, 2, 1, 2, 3]) → True +``` + +##string_match + +*Given 2 strings, a and b, return the number of the positions where they contain the same length 2 substring. So "xxcaazz" and "xxbaaz" yields 3, since the "xx", "aa", and "az" substrings appear in the same place in both strings.* + +This one tripped me up for a bit because the problem forgot to mention that one +string could be longer than the other one. So I was getting a lot of index out of +range results. After figuring that out, the problem was a fairly simple for loop +with a boolean expression to check the substrings. + +``` +def string_match(a, b): + count = 0 + shorter = min(len(a), len(b)) + for i in range(shorter-1): + if a[i] == b[i] and a[i+1] == b[i+1]: + count += 1 + return count +``` + +Output: + +``` +string_match('xxcaazz', 'xxbaaz') → 3 +string_match('abc', 'abc') → 2 +string_match('abc', 'axc') → 0 +``` + +That's my stuff! diff --git a/_posts/2014-02-16 madelinecodingbat2.md b/_posts/2014-02-16 madelinecodingbat2.md new file mode 100644 index 0000000..cc24caa --- /dev/null +++ b/_posts/2014-02-16 madelinecodingbat2.md @@ -0,0 +1,63 @@ +--- +layout: post +author: madeline +title: Madeline's Codingbat Post 2 +--- + +![] http://i.imgur.com/l3sQqbS.png + +This is not me at my most brilliant, but I did my best. + +## cat_dog + +Return True if the string "cat" and "dog" appear the same number of times in the given string. + +I found the answer to this one online. str.count is a built-in function. The reason there are not more of these is because Python would require almost infinite built-in functions to do the things required of it. + +``` +def cat_dog(str): + if str.count("dog") == str.count("cat"): + return True + else: + return False +``` + +## lone_sum + +Given 3 int values, a b c, return their sum. However, if one of the values is the same as another of the values, it does not count towards the sum. + +Since there are only three values in this one, I simply went through each scenario and used if statements for them. + +``` +def lone_sum(a, b, c): + if a == b == c: + return 0 + if a == b: + return c + if a == c: + return b + if b == c: + return a + else: + return a + b + c +``` + +## lucky_sum + +Given 3 int values, a b c, return their sum. However, if one of the values is 13 then it does not count towards the sum and values to its right do not count. So for example, if b is 13, then both b and c do not count. + +Because there were only 3 values, I only had to go through the scenarios to find the sums. I am sure a loop would have been better. + +``` +def lone_sum(a, b, c): + if a == b == c: + return 0 + if a == b: + return c + if a == c: + return b + if b == c: + return a + else: + return a + b + c +``` diff --git a/_posts/2014-02-16-Laura-codBat2.md b/_posts/2014-02-16-Laura-codBat2.md new file mode 100644 index 0000000..789fed0 --- /dev/null +++ b/_posts/2014-02-16-Laura-codBat2.md @@ -0,0 +1,48 @@ +--- +layout: post +author: laura +title: CodingBat2 +date: 2014-02-16 +--- + +Here is the picture +![CodingBat2 Screenshot](http://puu.sh/6Z2b3.png "CodingBat2") + +##Interesting 1 +###Python > String-2 > end_other +Question: Given two strings, return True if either of the strings appears at the very end of the other string, ignoring upper/lower case differences (in other words, the computation should not be "case sensitive"). Note: s.lower() returns the lowercase version of a string. + +With all the adding and slicing going on in this series, it was nice to use some simple code. + +``` +def end_other(a, b): + a = a.lower() + b = b.lower() + return (b.endswith(a) or a.endswith(b)) +``` + +##Interesting 2 +###Python > List-2 > big_diff +Question: Given an array length 1 or more of ints, return the difference between the largest and smallest values in the array. Note: the built-in min(v1, v2) and max(v1, v2) functions return the smaller or larger of two values. + +Again, simplicity rules. + +``` +def big_diff(nums): + return max(nums) - min(nums) +``` + +##Interesting 3 +###Python > List-2 > count_evens +Question: Return the number of even ints in the given array. Note: the % "mod" operator computes the remainder, e.g. 5 % 2 is 1. + +This helped me understand getting to even and odd elements in a string + +``` +def count_evens(nums): + count = 0 + for element in nums: + if element % 2 == 0: + count += 1 + return count + ``` diff --git a/_posts/2014-02-16-blucka12-codingbat2.md b/_posts/2014-02-16-blucka12-codingbat2.md new file mode 100644 index 0000000..0d52b9c --- /dev/null +++ b/_posts/2014-02-16-blucka12-codingbat2.md @@ -0,0 +1,54 @@ +--- +layout: post +author: blucka12 +title: Codingbat Exercise +--- + +``` +def lone_sum(a, b, c): +``` + + #first sign of green, brought to you by: + # lone_sum = int(a + b + c) + # return (a + b + c) + #then I worked on eliminating the variables that must be excluded, adding the "else" statement at the end: + +``` +lone_sum = int(a + b + c) + + if a == b: + return (c) + if a == c: + return (b) + if b == c: + return (a) + else: + return (a + b + c) +``` + + #that got me most of the way, with one red box left + + + + #I got an error for (3,3,3) ->0, and had to go back to the beginning and insert: + +``` + lone_sum = int(a + b + c) + + if (a == b) and (a == c): + return 0 + if a == b: + return (c) + if a == c: + return (b) + if b == c: + return (a) + + else: + return (a + b + c) +``` + + + #Yay + +Check out the io page here: http://blucka12.github.io/spring2014/ diff --git a/_posts/2014-02-16-jessicascodingbat2post.md b/_posts/2014-02-16-jessicascodingbat2post.md new file mode 100644 index 0000000..ee9eecf --- /dev/null +++ b/_posts/2014-02-16-jessicascodingbat2post.md @@ -0,0 +1,106 @@ +--- +layout: post +author: jskaa +title: Jessica's Coding Bat Post Part II +--- + +#Firstly, Those Glorious Screenshots + +###Warmup II + +![Warmup II Screenshot](http://puu.sh/6YW9l.png "Warmup II") + +###String II + +![String II Screenshot](http://puu.sh/6YWcE.png "String II") + +###List II + +![List II Screenshot](http://puu.sh/6YWeA.png "List II") + +###Logic II + +![Logic II Screenshot](http://puu.sh/6YWbr.png "Logic II") + + +#The Interesting Bits + +###Logic II: make_chocolate + +I don't know why I struggled with this one, when it was so similar to the previous make_bricks problem in the same set. +I think it was mostly just getting tripped up with the information given to me and my new variable which I had defined. I spent +over 10 minutes changing pieces of the code and getting a bunch of reds, but after breaking out the pencil and paper, +it was smooth sailing. It really helps to write out the math sometimes, even if it is very simple! + +My solution ended up being: + +``` +def make_chocolate(small, big, goal): + max_big = goal / 5 + + if big>=max_big: + if small >= (goal-(max_big*5)): + return goal-(max_big*5) + else: + return -1 + elif big=goal-(big*5): + return goal-(big*5) + else: + return -1 +``` + +There is probably a way of writing this which is much shorter and more efficient, but this way makes all the +calculations very clear, which is quite nice for a beginner like me. + +###List II: sum67 + +This one gave me the most trouble, but at least I learned something cool in the process! For the previous sum13 problem, +I came up with what may be a sort of patchwork answer by finding all items where were 13 in the array, and setting those, +as well as the next immediate item in the array equal to 0, then summing up the array of integers. However, I couldn't +do that for this one, because obviously I don't know how many numbers to get rid of. I first tried slicing, but it got +pretty messy and I scratched that. So, what to do? Well, I went and bothered a programmer friend of mine for some hints. +He gave me a bit of a hint to create a boolean variable which would either sum or not sum the item at that index based +upon it being True or False. Eureka! (or not so much a sudden 'Eureka' as a mistake-filled 10 minutes of trying to think +through what in the world I was doing. It's much easier when things are verbose! + +My end code was: + +``` +def sum67(nums): + skipping = False + sum = 0 + for i in range(len(nums)): + if nums[i] == 6 and not skipping: + skipping = True + + elif nums[i] == 7 and skipping: + skipping = False + + elif not skipping: + sum += nums[i] + return sum +``` + +Once again, there might be a more succinct way of writing it, but this is nice and easy for anyone to glance at and +understand. + +###String II: end_other + +Good thing we had that hint! Before clicking on the hint, I was preparing to figure out a way to go through each few +items and then compare the strings. I'm not even sure how I was planning on doing that! Luckily Python has several +very nice methods which are there to make our lives easier. Just a nice little example of how knowing what tools you +have available can make things much easier! + +My code was: + +``` +def end_other(a, b): + a_lower = a.lower() + b_lower = b.lower() + return a_lower.endswith(b_lower) or b_lower.endswith(a_lower) +``` + +Nice and simple! + + diff --git a/_posts/2014-02-16-juliesecondbat.md b/_posts/2014-02-16-juliesecondbat.md new file mode 100644 index 0000000..abce5d7 --- /dev/null +++ b/_posts/2014-02-16-juliesecondbat.md @@ -0,0 +1,53 @@ +--- +layout: post +author: julie +title: Julie's Second Coding Bat Exercise +--- + +First, here's my checkmarks: + +![Turtle Image](http://i.imgur.com/JuPqneq.png) +![Turtle Image](http://i.imgur.com/Baj9FiR.png) +![Turtle Image](http://i.imgur.com/mQaRugX.png) +![Turtle Image](http://i.imgur.com/QogGbkv.png) + +As you can see, I couldn't figure out the sum 67 one. + +The first one I thought was interesting was the string exercise **end_other.** With this exercise and others, it took me a while to realize that I needed to use the string methods, but once I did, everything was a lot easier. I realized that for this one I first had to turn all the strings into all lower case so that it could comepare them. Here is the code: + + +``` +def end_other(a, b): + a = a.lower() + b = b.lower() + if b.endswith(a) or a.endswith(b): + return True + else: + return False +``` + + +I also liked the **lucky_sum** one because I thought it was pretty easy and I figured it out right away, although I wonder if there is a shorter way to solve it rather than going through every possibility: + + +``` +def lucky_sum(a, b, c): + if a == 13: + return 0 + elif b == 13: + return a + elif c == 13: + return a + b + else: + return a + b + c +``` + +Finally, I liked the **big_dif** exercise because I was proud of myself for coming up with such a short, easy solution: + +``` +def big_diff(nums): + return max(nums) - min(nums) +``` + + + diff --git a/_posts/2014-02-16-secondcodingbatsierra.md b/_posts/2014-02-16-secondcodingbatsierra.md new file mode 100644 index 0000000..24e5863 --- /dev/null +++ b/_posts/2014-02-16-secondcodingbatsierra.md @@ -0,0 +1,56 @@ +--- +layout: post +author: srmoore5 +title: Coding Bat 2 +date: 2014-02-16 +--- + + +Screenshot + +![codingbat2](http://farm3.staticflickr.com/2812/12575600995_61167fc5a3.jpg) + + +3 Interesting Exercises + +Logic 2 lucky_sum +- simple, logical and fun + + +``` + +def lucky_sum(a, b, c): + if a == 13: + return 0 + elif b == 13: + return a + elif c == 13: + return a + b + else: + return a + b + c + +``` + +String 2 count_hi +I forgot how to do this one for a moment. + +``` +def count_hi(str): + a = str.split('hi') + return len(a) - 1 + +``` + +Warmup 2 array123 + + +``` +def array123(nums): + # Note: iterate with length-2, so can use i+1 and i+2 in the loop + for i in range(len(nums)-2): + if nums[i]==1 and nums[i+1]==2 and nums[i+2]==3: + return True + return False + + ``` + diff --git a/_posts/2014-02-19-nitrouspostklm.md b/_posts/2014-02-19-nitrouspostklm.md new file mode 100644 index 0000000..f929ca1 --- /dev/null +++ b/_posts/2014-02-19-nitrouspostklm.md @@ -0,0 +1,9 @@ +--- +layout: post +author: katielmeyer +title: Nitrous test post +date: 2014-02-19 +--- + + +Another Nitrous test... \ No newline at end of file diff --git a/_posts/2014-02-19-simpleblogklm.md b/_posts/2014-02-19-simpleblogklm.md new file mode 100644 index 0000000..c50f583 --- /dev/null +++ b/_posts/2014-02-19-simpleblogklm.md @@ -0,0 +1,87 @@ +--- +layout: post +author: katielmeyer +title: Simple Flask blog +date: 2014-02-19 +--- + +My blog is currently live on heroku: http://silshack-katielmeyer.herokuapp.com/ + +When I first tried to deploy the blog in class I got an 'application error' when I tried to view the app. After Grant fixed the environment setup script, +I followed the instructions on the smartypant's blog under Trouble, and was annoyed that it didn't same to make any difference: the error was still +there. It's really convenient that Grant handled all the complexity behind the app to make it easier, but the downside of skipping that complexity +is that you can't really debug if you're not learning the process yourself. So I figured since it was only a few short steps anyway, I'd scrap the whole +thing and follow the steps again, assuming it was my error and I'd missed something. It was only after I got the new blog app on heroku that I realized +I'd just forgotten to push the changes from the fixed scripts to heroku... + +Anyway, now that it's up there, I really like this app! It's certainly no WordPress, the name 'Simple' is very fitting. But it does +just about everything you'd need a little blog to do. + +One weird thing I noticed: I uploaded a JPG of a piglet through the browser admin interface (because, why not) into my first post. It worked fine. +I pulled the udpates from heroku, then I changed my font in the settings.py config file, and pushed back to heroku. Somehow that broke +the image link. I checked the simplhack uploads folder and saw it wasn't there, so I uploaded it to that directory through nitrous, committed, pushed. +(I've had similar issues at work with version control software, Rational Team Concert, not transferring images). No luck. Here's where a little more +complexity in the admin interface might be useful. + +UPDATE: About five minutes after writing that I figured out the filename the blog post was referencing was one it had assigned to the upload image. +When I manually changed it to match the filename of the image that was actually in the uploads directory, it worked fine. So maybe there's still +a problem with pulling down images from the heroku instance of the app into nitrous, but I guess you can push them into heroku from nitrous. + +I played around a bit in the CSS, changing some of the text formatting. I didn't like the red hover text, so I switched it to blue in layout.css. + + +I also wanted some special formatting on the blog title text, so I added a new class for it on the h1 element in the layout template, and +got rid of the line break element (
) to bring the tagline up a bit... + +``` +
+

{{ config.BLOG_TITLE }}

+ ``` + + ...Then added styles for it in layout.css. + +``` + +h1.blog-title a{ + font-size: 60px; + font-family: 'Shadows Into Light', serif; + color: #555; + border-bottom: none; + line-height: 55px; +} +h1.blog-title a:hover { + color:#04E0CA; +} + +``` + +And I wanted a special Google font (Shadows into Light) for that blog title, so I had to tack it into on the layout template. + +``` + + + +``` + +Finally, to play around with the layout I nixed the fixed sidebar (so it'll scroll down with the posts) and increased the sidebar width. Since this app +uses Bootstrap (a 12-column responsive framework, http://getbootstrap.com/) I could do that easily in the layout.html template by just changing +the classes of the div elements for the sidebar and main content. + +For the sidebar: + +``` + +
+ +``` + +For the main content: + +``` + +
+ + +``` + +Since my sidebar isn't fixed anymore, I got rid of the 'hidden phone' columns between the sidebar and main content. diff --git a/_posts/2014-02-19-thetestiness.md b/_posts/2014-02-19-thetestiness.md new file mode 100644 index 0000000..24b0cb8 --- /dev/null +++ b/_posts/2014-02-19-thetestiness.md @@ -0,0 +1,16 @@ +--- +layout: post +author: blucka12 +title: The Tastiness, Baybay! +date: 2014-02-19 +--- + +``` +Here we go again, baby!!! + +#I am certain that I will forget something, but it will work out... + +#I'm feeling fairly uplifted by the smoothness of this Nitrous business... + +``` + diff --git a/_posts/2014-02-20-Laura-SimplePost.md b/_posts/2014-02-20-Laura-SimplePost.md new file mode 100644 index 0000000..41f7522 --- /dev/null +++ b/_posts/2014-02-20-Laura-SimplePost.md @@ -0,0 +1,11 @@ +--- +layout: post +author: laura +title: Laura Post about Simple +date: 2014-02-20 +--- +## Simple.py Post + + Thankfully Grant helped me finish the set-up with simple.py and nitrous. I am doing this post from the Nitrous command line and it was not as hard as I thought it would be. As for making my first Simple post, it is pretty straitfoward. + +Here is the link to my Simple post: http://silshack-githublasher09.herokuapp.com/?page=0. diff --git a/_posts/2014-02-20-mandysimpleblogpost.md b/_posts/2014-02-20-mandysimpleblogpost.md new file mode 100644 index 0000000..129f668 --- /dev/null +++ b/_posts/2014-02-20-mandysimpleblogpost.md @@ -0,0 +1,25 @@ +--- +layout: post +author: agooch +title: Mandy's Simple Blog Post Adventure +--- + +Here is my blog: http://silshack-agooch.herokuapp.com/. It isn't much, but it's functional. + +As for my process, I can honestly say I was doing very well until getting to the ./setupenv1.sh portion of the exercise. Since it was busted, I was unable to finish my assignment in class. This meant I had to pick up from where I left off, but I ran into more issues when Nitrous kept giving me errors. + +I decided to just scrap everything and start over, because it was getting frustrating. After this, my code worked perfectly and I was able to push everything through to the heroku master. + +I will freely admit that it took me a bit to figure out where to go from there. I went into the simple.py file, but was not sure what I was supposed to do. Anyway, I realized at some point that I needed to checkout my actual app page. I went there and added the /admin to the URL to log in. + +The interface is really simple, so it was pretty easy to figure out. I created a basic post and used the drag and drop feature to add a picture that was sitting on my work computer. + +As for the bonus section, well, I didn't really want to mess up the app's layout too badly, so all I did was edit some of the colors in the layout.css file. I also added an image to the 404 template that I found on Google. Nothing too big, but it was nice to see the edits reflected in my page after pushing them through Nitrous. + +Note: I did have an issue at one point when editing. I changed some colors to the CSS layout page and pushed it through. When I went back to my blog the image of my dog was no longer visible. I'm not sure why this happened and couldn't find anything in my code, so I just deleted the post and created another one. + +I got my color codes here: http://www.huecode.com/ + +Here is the 404 image: + +![404 Image](http://i.imgur.com/4foYoqY.jpg) diff --git a/_posts/2014-02-20-zbaySimple1.md b/_posts/2014-02-20-zbaySimple1.md new file mode 100644 index 0000000..3a91917 --- /dev/null +++ b/_posts/2014-02-20-zbaySimple1.md @@ -0,0 +1,12 @@ +--- +layout: post +author: zbay +title: Zach's First Simple Post +date: 2014-02-20 +--- + +I made my first post on SimpleHack. It's nothing much, as you'd expect for a first post. You can find my post at [this link](http://silshack-zbay.herokuapp.com/). + + +As I understand it, I executed some scripts that set up a blogging application on top of a database in a cloud environment. At first, I thought that I had to code within simple.py in order to make a post. This seemed a far from simple task, and required some serious code comprehension. More careful reading of the _instructions_, however, clarified that I merely had to log in as an admin to make a post. What a relief! +Truth be told, I'm fuzzy on how Heroku works. I'm sure I'll figure it out as we work on it in through class. diff --git a/_posts/2014-02-21-ThuMaiSimpleHack.md b/_posts/2014-02-21-ThuMaiSimpleHack.md new file mode 100644 index 0000000..f63b682 --- /dev/null +++ b/_posts/2014-02-21-ThuMaiSimpleHack.md @@ -0,0 +1,28 @@ +--- +author: tlchristian +title: Thu-Mai's Simple Blog Post Post +layout: post +date: 2014-02-21 +--- + +This week was an interesting exercise in the mechanics of pushes and pulls. I am a very visual person, so I'm glad that Elliott provided diagrams explaining how data get moved between our individual repositories to the primary class site. It helped me tremendously in understanding what this git business is all about. Thanks for that. + +After Grant's on-the-fly debugging, I was able to easily go through the process of setting up my instance of Simple onto Heroku. Simple it is. I checked out the .css files to see if I could hack the layout and make pretty colors and fonts. I was able to make some color changes by playing with the code below in the layout.css file: + +``` +body { + background: #fff; + color: #222; +} +``` + +I quickly realized that this defeats the purpose of the whole Simple layout concept. Minimalism it is. (Though at the same time, I am digging what Katie did with her Simple blog--a nice balance of minimalism *and* style.) + +I also have to point out that tech folks have awfully good customer service. I had some issues with my nitrous.io box hanging up. Apparently, there was a huge traffic surge in our area at the time, which likely caused my box to be unable to connect for a while. All was well just a few minutes after I sent them a note. Very cool. + +And [here is my first Simple Blog post](http://silshack-tlchristian.herokuapp.com/). Kids and iPhoto are hilarious! + + +--- + + diff --git a/_posts/2014-02-21-herokusierra.md b/_posts/2014-02-21-herokusierra.md new file mode 100644 index 0000000..7292e63 --- /dev/null +++ b/_posts/2014-02-21-herokusierra.md @@ -0,0 +1,21 @@ +--- +layout: post +author: srmoore5 +title: Heroku Nitrous Sierra Post +date: 2014-02-21 + +--- +Here is a link to my Heroku Blog: http://silshack-srmoore5.herokuapp.com/?page=0 + +The process of creating a Heroku blog seemed simple. Over time I became frustrated +but I later realized that internet connectivity issues at UNC was causing the problem! +After much refreshing, pulling, adding and typing incorrect commands--my blog appeared +and it worked. Annoying, but worth it? Yes. And I do enjoy typing my posts in Nitrous instead of +Github which requires an excessive about of committing. I always edit my work many times throughout +the process and Github is not very friendly towards excessive editors. + +Fortunately, being able to access Nitrous and Heroku on any computer saved the day when I was unable +to use the internet on my mac. Thanks to help from Grant--I am done! I'd like to try creating more apps and +see how they interact with one another. I do have a second app, but I'm not entirely certain how to +use them together without confusing myself. + diff --git a/_posts/2014-02-21-sunhwaherokupost.md b/_posts/2014-02-21-sunhwaherokupost.md new file mode 100644 index 0000000..148c0e7 --- /dev/null +++ b/_posts/2014-02-21-sunhwaherokupost.md @@ -0,0 +1,42 @@ +--- +layout: post +author: sunhwap +title: sunhwa's heroku first post +date: 2014-02-21 +--- + +After SSH key was added to my Heroku account, I was able to go on to my heroku site: +http://silshack-sunhwa.herokuapp.com. The site let me type my first post when I added /admin to this url. +I made some attempts to make a few changes to CSS layout codes to hope to get the site to look better but failed. +Then I later realized thanks to Grant's help that I have to do git push for the changes to be reflected on Heroku site. +So to make a change in background color to Heroku site, I inserted the background color code in the layout.html: + +``` +