Tag Archives: javascript

ImageCoding Club today.

There’s a chance I may be getting more takers for my ‘Codecademy’ – based coding club at FSCC soon. Several students have shown interest and I look forward to opening up the class towards becoming a more open space with students (including myself) pursuing a number of projects simultaneously. 

If anyone (local, at least) is interested in joining our group, please feel free. We take all comers and look forward to building our numbers with anyone interested in learning, teaching or challenging themselves.

If you’re not local, I’d still be interested in hearing from you if you’d like to start an online learning community tied to codecademy, code school, or any other online resource.

Leave a comment

Posted by on August 30, 2013 in Uncategorized


Tags: , , , , , , , , , , , ,

New Coding Challenge – The Quincunx!

ImageThe Quincunx – A triangular pegboard that will create a nice normal distribution as balls are dropped from the top and bounce down randomly over the triangular array of pegs.

Society’s greatest achievement, The Price Is Right, demonstrates the use of a plinko board in this video with the most excited player ever.

The coding challenge is to design a quincunx that demonstrates each of the following four points… No animation is required, simply (1)show the board as an array of X’s with a (2) user-determined number of rows (1-20) and the (3)resulting bins filling with integers as a (4)user-determined number of balls (1-100,000) is dropped. This time, I’m awarding prizes to the cleanest, most clearly documented entries in each language represented on Codecademy (Ruby, JS, Python).

As always, the prizes are bragging rights, presentation of your code on my blog with full attribution to you and a promo copy of any of my eBooks on iPad for you to share with the youngster in your life (or keep yourself). Each of my books presents educational material  in the form of a story (Heracles and the Gas Laws, Sisyphus and the Laws of Motion, Zombies and Fractions).

Happy Coding!

(submit your entries as links in the comments below)

Leave a comment

Posted by on July 10, 2013 in Uncategorized


Tags: , , , , , , , , ,


ImageI mention codecademy all the time here and rant about how great a way it is to learn a variety of languages and markups online, on your own time and free. I’ve been following both the web programming track and the Ruby tracks aggressively lately (I’m on a 20 day streak presently). However, I have to also mention another free site that does much the same thing. RubyMonk offers free online courses in Ruby (and Python, under PythonMonk). The Monk websites are clean, well structured and provide an element of atmosphere as well.

Unfortunately, RubyMonk does not provide a forum where I can pitch my project challenges – er, I mean Koans. But if you are learning Ruby or Python with the Monk, please feel free to come here from time to time to see if there are any simple programming challenges open.

Leave a comment

Posted by on June 28, 2013 in Uncategorized


Tags: , , , , , , , , ,

Winding down Coding Challenge I

ImageI’ve received several entries answering my coding challenge to demonstrate / test Goldbach’s Conjecture that all even numbers > 4 are the sum of two primes. So far python has been the language of choice for entries.


I will be closing down this challenge as of June 30 at 11:59pm.

Once I take a look at the entries, I’ll award the prize, a copy of my iBook, In Parts to the winner and post the code here with a walkthrough to show how the problem was tackled as well as any interesting comparisons between entrants.

Leave a comment

Posted by on June 26, 2013 in Uncategorized


Tags: , , , , , , , , , , , , ,

Coding Challenge II: Make Mine a MASTERmind

ImageDon’t worry, Coding Challenge I is still open, but someone was writing about games to develop in the codecademy discussion groups. 

A while ago, when I was first following the JavaScript pathway, there, I decided to write a MasterMind program. Many of the versions I saw prohibited players from using the same number/color more than once, but I felt that was a cop-out. My solution works, but as usual for me, had some tortuous logic.

So, here’s the challenge:

In any language, write a MasterMind game where the computer chooses the numbers and the user deduces them.

1. use numbers (four of them,#s1-4, randomly chosen by the computer), rather than colors

2.  that allows multiple uses of the same numbers, i.e. ‘1122’

3. provides appropriate feedback to the user to help them close in on the correct sequence.

4. keeps track of the number of turns taken

5. (optional) can also be played with 2 users -or- user sets the code and computer guesses

6. (optional) allow user to select # of positions and range of numbers used.


simple code trumps tangly code. I prefer languages I can read (C++, javascript, python) but all are welcome.

Leave a comment

Posted by on June 22, 2013 in Uncategorized


Tags: , , , , , , , ,

Coding Challenge

Recently, there have been a couple new revelations about number theory published in Science Within the article was a pair of theories about prime numbers that I had never heard before, one of which was:

Goldbach’s conjecture, [which] makes two assertions: that every even number greater than 2 is the sum of two primes, and that every odd number greater than 5 is the sum of three primes.

I thought it would be fun to start with the first part of this problem and write a program to accept user input in the form of an even integer > 2  and then look for the two primes whose sum is equal to the user provided:

Goldbach_partitions_of_the_even_integers_from_4_to_28_300pxprime1 + prime2 = user input

where prime1 and prime2 may be any prime number (even the same number twice)

I could easily see this escaping the processing power of my machine if the numbers get high, but I think it shouldn’t be too hard to at least write a code that could look for them and demonstrate whether this worked with known input.

Are you up for a quick challenge?

zombie locker

Learn Fractions with Zombies

If so, submit your documented answer here as a comment. Feel free to use any language you would like (I just did it in C++, but I’m eager to see better answers than my own). My favorite submissions will win a free copy of  my iBook, In Parts, Tales of Fractional Zombies, which you can enjoy yourself or regift to a youngster in your life who wants a fun way to learn the concept of fractions.

You can use these links as resources to help check your work:

prime numbers       prime checker

If you are new to coding and are looking for a coding environment to work in, check out this posting for help setting up a C++ coding environment using Xcode (on your mac)


Posted by on June 19, 2013 in Codecademy, Coding


Tags: , , , , , , , , , , , , ,

Codecademy Problem

ImageI’ve mentioned many time on this blog how I am a big fan of codecademy. I think this is an excellent way to develop some coding skills in a simple hand-held way. I’ve been following the javascript track for some time and really enjoy it. Recently, Ruby and Python tracks have been introduced, although I have only given each one minimal attention so far. In the future, I am hoping to concentrate on the web programming elements in order to provide some context for the javascript work.

Presently, I have been stuck on a problem that should be easy, but the walkthrough does not seem to guide you in the right direction. The problem is intended to take a string of text and search for your name within this text. I think the difficulty arises from the fact that the walkthrough sounds like you should be solving the whole problem, but may actually be asking for less. 

Below, with a few extra details, I present a solution that effectively gets the job done. I’ve included some documentation so you can see what I was thinking as well as some debugging aids to visualize what the program is doing at each step.
ImageThis solution will get a ‘pass’ for the problem, but I am wondering how this might be simplified.
If you can simplify this solution, please leave a comment and I will update the code if significant advances are made.

/*jshint multistr:true */

var text = “hdajkslhgjalhjghjklhjackfghjdskghjkdfajlk”;  //the text we search through
var myName = “jack”;                                                  //what we are looking for
var hits = [];                                                                  //array storing match
var j=0;                                                                         //a counter for myName array

/////////first loop for match with myName[0]////////////
for (i=0;i< text.length;i++){
console.log(i); // enumerates position in text array
if (text[i] === myName[j]){

//////advances position in myName array, second loop continues search/////
for(var j=i;j<i +myName.length;j++){
console.log(“testing if”,text[j],” = “,myName[j-i]); //shows match test
if(text[j] != myName[j-i]){
hits.length = 0; //if no match, hits array is cleared
j=0; //array position in myName is reset
break; //exits inner loop
} //end ‘if no match’

if (text[j] === myName[j-i]){ //for each match, letter is pushed
hits.push(text[j]); //onto hits array
} //end ‘if match’
} //end inner loop

/////if reach size of myName array ////////
if (hits.length === myName.length){
console.log(“we found your name: “, hits); //output match
} //end ‘size of array
}//end outer loop
}//end program

/* output
testing if j = j
testing if k = a
testing if j = j
testing if a = a
testing if l = c
testing if j = j
testing if g = a
testing if j = j
testing if k = a
testing if j = j
testing if a = a
testing if c = c
testing if k = k
we found your name: [ ‘j’, ‘a’, ‘c’, ‘k’ ]


Leave a comment

Posted by on June 12, 2013 in Uncategorized


Tags: , , , ,

Code School Hall Pass

Code school is currently offering 48 hours of free access to their site. Code School has video classes covering Ruby, JavaScript, iOS and HTML. I just started mine tonight and I’m hoping to get a lot out of it and see if its something I can get more value from. If you’re interested in coding, I highly recommend looking into this site and also Codecademy

1 Comment

Posted by on March 18, 2013 in Uncategorized


Tags: , , , , ,

Two minutes into my latest coursera lecture….

Two minutes into my latest coursera lecture (introduction to interactive programming in python) the instructor indicated his frustration in javascript programming saying that it’s a terrible language. This may be the case… so far I don’t have a lot to compare against, but I have been enjoying learning JS in codecademy and I’m dying to know why he thinks so.

If you have experience programming in javascript and python (or other languages…ruby?) let me know if you agree with the above statement and what makes you think so. As a new programmer I am interested in learning as much as possible – if I can understand what faults people see in these languages I think that would be very instructive.



Posted by on October 25, 2012 in Uncategorized


Tags: , , , , , , , , ,

Stuck at 98%

I’ve been procrastinating – with a lot of things really.

The one that brought me to writing this is that I am 98% finished the codecademy Javascript course with only the Blackjack game remaining. And I’ve already put a lot into that as well. I just need to get off my lazy ass and finish it. Instead, I’ve allowed myself to get distracted by the new courses in python and ruby. I think I’m going to have to set aside a night and get this finished though.

The problem has been that I put javascript aside for long enough that I’m starting to forget the syntax. I think tonight I’ll print out a couple of my old syntax guides (perhaps update them and post them here) and get back in the saddle.

I also have an ePublishing workshop coming up this Thursday. My (biology) class has been given the day off and I’ve hired a babysitter so that I can go. In my mind it is a good way to network with some people who are interested in ePublishing but not comfortable enough to jump in and hopefully learn some things too.

I’ll be taking the iPad with The Thirteenth Labor of Heracles as a demonstration of a finished product and I’m hoping to have The Curse of Sisyphus far enough along that it can be demonstrated as well. I like the way The Curse is coming along – it incorporates more self-testing opportunities than the Thirteenth Labor. I’m also looking into how to develop my own widgets (another project! Great!), but realistically, I recognize that this is probably a long way off for me. I would love to be able to develop a more versatile version of the interactive image widget to use with mathematical equations.

Oh right, I’m also supposed to preparing for an exam! I’ve written all of about ten questions so far and haven’t even looked at my Jeopardy – review yet. And then the lab… damn. I did make that promise didn’t I?

Well, let’s just see how things go one day at a time.

One last thing: My wife is away for what amounts to two weeks. Day one – two minutes after she left: Dingleberry on the dog. I don’t think the cat has realized what’s up yet because I haven’t found any surprises.

1 Comment

Posted by on October 16, 2012 in Uncategorized


Tags: , , , , , , , , , , , ,