/    Sign up×
Community /Pin to ProfileBookmark

I am a COMPLETE Beginner–Easy Counting Program?

As I said, I am a COMPLETE beginner at Java, as in I have never done a program in my life. However, I would like to better myself by learning this useful tool. I came across this problem that Im sure uses javascript. Could you please tell me the code to do this and possibly explain?

How many ways are there to choose a set from the following set of variables given that:
1) a set may NOT contain variables with the same letter OR the same subscript (eg, a set may not be {A_1, A_4,B_2} OR {B_2, E_2,})
2) Z may NOT be with A_1, B_2, or C_3
3) we can have an empty set or a set with any amount of variables in it, given the above restrictions hold true

The variables are {A_1, B_2, C_3, A_4, D_1, B_5, E_2, C_6, F_3, G_4, D_7, H_5, E_8, I_6, F_9, Z}
(16 variables in total)

Can someone PLEASE give me this code? I would really love to know this art, and especially this program!

to post a comment
JavaScript

9 Comments(s)

Copy linkTweet thisAlerts:
@bluggaauthorOct 22.2009 — anyone please???
Copy linkTweet thisAlerts:
@mityaOct 22.2009 — If you're a total beginner, then this task is too hard for you and will serve no purpose us doing it and explaining it.

The standard way to learn JS is to first understand its syntax, learn the buzzwords, then start with some simple string functions and work your way up.
Copy linkTweet thisAlerts:
@justinbarneskinOct 22.2009 — I had a look at this yesterday and decided upon a number x!

where x is the array of variables length

Then apply the conditions with a loop to delete those disqualified

<SCRIPT type="text/javascript">

var s='A_1,B_2,C_3,A_4,D_1,B_5,E_2,C_6,F_3,G_4,D_7,H_5,E_8,I_6,F_9,Z'; s=s.split(',')

var possiblesets=1;

for(i=1;i<=s.length;i++){possiblesets=possiblesets*i}

document.write(possiblesets)

</SCRIPT>
Copy linkTweet thisAlerts:
@bluggaauthorOct 23.2009 — Oh! Thanks a lot, justin! After going through some tutorials, I think I understand that!

So this program satisfies the given constraints? If not, how would we make it?
Copy linkTweet thisAlerts:
@justinbarneskinOct 23.2009 — In the code I gave, possiblesets is a number too big to handle with my logic (and my computer.)

I must not be thinking right, there must be a different way to it.
Copy linkTweet thisAlerts:
@bluggaauthorOct 23.2009 — Well by mathematics the maximum number we could have would be 2^16 (not including restriction). So how would you input the restrictions into the code?
Copy linkTweet thisAlerts:
@bluggaauthorOct 24.2009 — Can someone please help me with this?
Copy linkTweet thisAlerts:
@JMRKEROct 24.2009 — It would be more helpful to us if you would explain the purpose of the exercise.

Is it a homework assignment?

What do the 'set' values represent: A_1, A_2, etc?


Do you have a more concrete example of what they mean?

And why do you have them initialized in an associative array with {} instead of a normal array with []?

Also, are you asking in the right forum? Your post #1 talks about 'Java' and 'javascript'. Which language is needed to satisfy the requirements? They are different.

As a stated 'COMPLETE beginner', you might have bitten off more that you should chew!

We might be able to help if we can know what you are trying to accomplish as there might be a better way to do it from the start.
Copy linkTweet thisAlerts:
@justinbarneskinOct 24.2009 — This might be interesting to a math nerd. Check around the Internet for a more

apt forum. I searched "math permutation" and am not convinced we can solve this.

Even when I consider applying the filters before building the array of qualified sets,

I still have to initiate each of 20922789888000 possibilities, and the more I looked at it,

thats a conservative estimate.
×

Success!

Help @blugga spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...