programming question

go big blue

New Member
i dont really know if anyone on this website can help me or not, but i am trying to create a program that will identify numbers from a list. i will try and break it down so you can understand.

lets say that i have 3 columns...in each column there are 10 numbers 1 - 10. (the numbers will not be this simplified, and they will be larger)

1 1 1
2 2 2
3 3 3
4 4 4
5 5 5
6 6 6
7 7 7
8 8 8
9 9 9
10 10 10

i would like to have a program that would let me know how many 3's there are, and how many 7's there are. is there a program that i can use for this, or can i create a system in microsoft excel? any help on this would be greatly appreciated!

:)
 
Excel would likely be an option. I can't help you that much with it though. Look into simple if statements and you can create something rudimentary.

You could always write a program to do this. Rather easily, in fact. If this isn't a school project, I could help you out.
 
no, its not a school project, as i am probably older than you are! lol. i just have a particular project that i am trying to do and not really sure how to proceed with it. i am really good at math, but not writing programs to do things. thanks for the reply, and any help you provide would be great!
 
What kind of file will you be reading from? Is it just a text file with numbers in it? And is it strictly just 3's and 7's you are looking for, or would you eventually like to specify what you are looking for?
 
well, as far as the file, i would input the numbers on a weekly basis. not just 3's and 7's. it would be all numbers 1 - 100. and basically, i would like to see how many times each number is posted, as i will have weeks and weeks of numbers posted. so if i have 100 weeks, and the number 37 is in there 3 times, but the number 38 is in there 47 times, i would like to be able to track that.
 
well, as far as the file, i would input the numbers on a weekly basis. not just 3's and 7's. it would be all numbers 1 - 100. and basically, i would like to see how many times each number is posted, as i will have weeks and weeks of numbers posted. so if i have 100 weeks, and the number 37 is in there 3 times, but the number 38 is in there 47 times, i would like to be able to track that.

What type of file though? text file, word file, excel file?
 
i guess it would start as an excel file, but i could do it as a word file if it would be easier. there really is no set type.
 
i guess it would start as an excel file, but i could do it as a word file if it would be easier. there really is no set type.

The file type doesn't matter. I imagine if you are keeping a record of numbers, excel would be easiest. I'll look into both options (excel and a program).

I already whipped up something that counts numbers from a regular text file.
 
ok, cool! thank you very much! its time for bed now, since i have a long day tomorrow, but i will check back sometime tomorrow afternoon for a reply. i really appreciate the help!

also, on a side note.. i really like your tag line about friends are like trees. thats awesome! lol
 
Alright. Next time you jump on, tell me a bit more about it so I can get a better idea of what to do. Namely, what type of numbers and how you are keeping track of them (like, do you have several rows/columns of numbers that mean different things, or is it just a giant group of numbers, or what have you).
 
Excel has a built-in function called COUNTIF() that will count the number of times a particular value occurs within a range.

In your example of 10 rows with 3 columns, you could create your spreadsheet with the rows/columns representing your numbers, then create another area on your spreadsheet that looked like this:

Col1 Col2

"1 Count =" =countif(A1:C10, 1)
"2 Count =" =countif(A1:C10, 2)
"3 Count =" =countif(A1:C10, 3)
etc...

In the calculation =countif(A1:C10, 1) A1 would represent the row/column of your first number and C10 would represent the row/column of your last number. These values would be different depending on how many rows/columns your actual data has.

Your example only goes to 10 but you said the actual data would be between 1 and 100 so you would need to do the countif function for every number between 1 and 100. Hopefully they'll be whole numbers and not something like 3.75, 52.07, 99.8, etc...

This is probably the simplest way of accomplishing what you want.
 
Last edited:
Excel has a built-in function called COUNT() that will count the number of times a particular value occurs within a range.

You could setup a loop from 1-100 using the COUNT function and count how many times each number from 1-100 occurred within the range of rows/columns you specify.

I hate you. Haha. Yeah, I found that. But, I've been looking for a small programming project to pass the time.
 
ok, ill try to explain. what i am doing is logging numbers, trying to find a certain pattern, persay. below is an attachment that i copied from my desktop. this is in excel, but like i say, there doesnt have to be any certain way. you can see how i have it set up. that is kind of what im looking for, but i wish to do it automatically when i input the numbers. so at the end of a week, lets say i input 45, 87, 23, 1, and after that the columns should add these numbers to the existing ones.

i think you will understand once you see the file. thanks once again for the help!
 

Attachments

  • book.JPG
    book.JPG
    32.2 KB · Views: 37
ok, well i posted the other not seeing strollin's post, but im kinda confused at how to type it. is there a way you could explain a little bit more in detail? sorry, i just dont mess around that much with this stuff. i know how to autosum and dinky stuff like that, but this seems a bit more complex. i really appreciate the help from both of you!

p.s. there are no fraction numbers, only whole numbers.
 
ok, well i posted the other not seeing strollin's post, but im kinda confused at how to type it. is there a way you could explain a little bit more in detail? sorry, i just dont mess around that much with this stuff. i know how to autosum and dinky stuff like that, but this seems a bit more complex. i really appreciate the help from both of you!

p.s. there are no fraction numbers, only whole numbers.

Okay. Here is the exact function you need:

Code:
=COUNTIF(From:To, num)

From:to, of course is the range. Just specify where it should start and where it should end. num is just the number you want to keep count of. So, in your example to count the number of 1's you would do in cell H3:

Code:
=COUNTIF(A3:D6, 1)

Of course, as you add more numbers, you'll want to increase the range. Do the exact same for each number, only changing 1 to whatever number you are counting.
 
i do believe that is going to work. i will start inputing that sometime tomorrow and come back and let you know how it turned out. thanks once again guys for all the help! i always knew there were smart people who arent a**holes! lol
 
Instead of keep increasing the range as you add numbers, you can set the range to as large as you anticipate it will ever be. In your example with 4 columns A-D, you could set the range to A3: D1000 (leave out space between : and D), for instance, and not have to adjust the range unless you added more than 1000 rows. Excel is smart enough to ignore cells with no data but as you add the next row it's data will automatically be included.

I'm going to suggest that you specify the calculation as =countif($A$3:$D$1000, F3). If you put that into H3 (as written), you can copy and paste it to H4 thru H102 and it will not need any editing. The $ signs make the cell reference absolute, as opposed to relative. If you leave the $ signs out and copy/paste, Excel will automatically change the cell references to relative terms (one cell up, 2 cells left) as opposed to referencing a particular cell. When you copy that calculation, as written, from H3 to H4, Excel will automatically change the F3 reference to F4 but the $A$1:$D$1000 will remain the same so it will look like this in cell H4, =countif($A$3:$D$1000, F4). If you copy it to cells H4 to H102 it will always reference the same range but will always look two cells to the left for the number value.

Column F should include all numbers from 1 to 100, unless there is some reason why you know certain numbers will never be used. Excel has a data fill feature so all you need to do is put 1 in F3 then hilite the cell and drag it to F102 and use the data fill feature to fill the series to 100.

Hopefully, you read this post before you go manually typing that calculation over and over again.
 
Last edited:
that works BEAUTIFULLY! it wil take me a little time to input the numbers that i already have, but so far it does EXACTLY what i wanted! thank you guys so much for the help! this will save me a thousand years of calculating! lol

once again, thank you!
 
The program to do this would be pretty simple.

Computer randomly selects a number between 1 & 15
Top of loop
Ask the user for their guess.
After each guess check to see if the guess matches computer number
If match, winner, tell user, exit program.
If no match, tell user, increment guess count.
If guess count = 3, looser, tell user, exit program
otherwise return to top of loop

That's the basic logic, you'll need to figure out how to do it in the programming language you are studying.
 
The program to do this would be pretty simple.

Computer randomly selects a number between 1 & 15
Top of loop
Ask the user for their guess.
After each guess check to see if the guess matches computer number
If match, winner, tell user, exit program.
If no match, tell user, increment guess count.
If guess count = 3, looser, tell user, exit program
otherwise return to top of loop

That's the basic logic, you'll need to figure out how to do it in the programming language you are studying.

Is this in the right thread?
 
Back
Top