# Thread:

1. ## algorthims

i need to verify that the following algorthims works on the list 2, 3,6,2,6

Begin
input $x_1$ $x_2$... $x_n$
count := 0
for i:= 2 to n do
begin
for j:=1 to (i-1) do
begin
if $x_i = x_j$ then
begin
count := count +1
end
end
output count
end

much thanks

2. What's it supposed to do? If you are counting duplicates, that's not it. Try 2 3 6 2 6 5 5 5 5 to disprove it.

3. it is meant to count the number of pairs of integers in a list

4. In your universe of inputs, will there EVER be more than two of any single integer?

Your algorithm will produce 3 from 2 2 2. If the trio condition never occurs, then perhaps you are done.

5. Originally Posted by TKHunny

Your algorithm will produce 3 from 2 2 2. If the trio condition never occurs, then perhaps you are done.

i don't understand that how can you get 2 2 2, when there are only two 2's in the list

6. I'm reviewing your algorithm, not your data. I made up my own data.

Why would you need an algorithm to count pairs if the data you provided was the entire universe of data? Just count them. Pair of 2's Pair of 6's. There, 2 pairs. Done.

Should your algorithm work with ANY data, or just some clear subset, such as that you have provided? If it needs to work on ANY data, then you'll get some double counting. If you can guarantee that there never will be a trio or a quartet or worse, then perhaps you are done.

7. it only need to work with the subsetthat i gace of 2.3.6.2.6

many many thanks
{"extraction_info": {"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 4, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0}, "config": {"markdown_headings": true, "markdown_code": true, "boilerplate_config": {"ratio_threshold": 0.3, "absolute_threshold": 10, "end_threshold": 15, "enable": true}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "github"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "english_confidence": 0.9363287687301636, "perplexity_flag": "middle"}