RSS

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: , , , , , , , , ,

RubyMonk

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)

 
7 Comments

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
break;
} //end ‘size of array
}//end outer loop
}//end program

/* output
0
1
2
3
testing if j = j
testing if k = a
4
5
6
7
8
9
testing if j = j
testing if a = a
testing if l = c
10
11
12
13
testing if j = j
testing if g = a
14
15
16
testing if j = j
testing if k = a
17
18
19
20
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: , , , ,