Results 1 to 7 of 7
Thread: Equation Numbers
-
09-29-2009, 07:16 PM #1Web Hosting Master
- Join Date
- Apr 2005
- Posts
- 697
Equation Numbers
Hello all,
Working on another project and I would definitely need some help, I will povide examples below... If anyone cold help, I would really appreciate it.
I have set of numbers from my results in mysql:
Code:1 2 234 489 1546 4764 4666 87979 454645 6456464 54766246
Code:1 2 234 489 1546 4564 4666 87979 454645 6456464 54766246
Code:Before: 1|5|4|6 4|7|6|4 4|6|6|6 After: [14][5-7][46][46].
At the end of the day, I would like the final results to look like below:
Code:1 2 234 489 1546 4764 4666 87979 454645 6456464 54766246
Code:[1-2]. [24][38[49]. [14][5-7][46][46]. 87979. 454645. 6456464. 54766246.
-
09-29-2009, 08:15 PM #2Web Hosting Master
- Join Date
- Mar 2009
- Posts
- 2,222
I have read this post three times; as I understand it, it is nothing to do with equations.
What you start with is some groups of digits; within a group, each line has the same number of digits.
1
2
234
489
1546
4764
4666
87979
454645
6456464
54766246
And what you want to end up with is one output line for each group.
[1-2].
[24][38[49].
[14][5-7][46][46].
87979.
454645.
6456464.
54766246.
Each line has one item for each column in its corresponding group.
Each output line has one entry for each column in the corresponding input group.
Each entry is of the form [x...z] where "x...z" are all the digits in order that appear in the input column.
However, there the input column has three or more numerically adjacent digits, they are represented by a range such as "5-8" meaninf "5678".
And if there is only a single digit in the input column, the brackets "[" and "]" are omitted.
That's all easy enough. You just need to write the program.
So in pseudocode, and omitting detail of recognising ends of groups:
Code:for each group for each line in group set digitarray to 0 for each column in line set digitarray.columndigit to 1 end of column loop end of line loop set outstring to null set digitarray.10 to 0 to simplify logic for each digit from 0 to 9 if digitarray.digit = 0 then iterate else set temp to digit for digit from digit+1 to 9 if digitarray.digit = 0 then leave innerloop else temp = temp || digit2 end of inner digit loop if length(temp) > 2 then temp = "[" || left(temp,1) || "-" right(temp,1) || "]" outstring = outstring || temp end end outer digit loop output outstring || "." end of group loop
-
09-29-2009, 08:56 PM #3Web Hosting Master
- Join Date
- Apr 2005
- Posts
- 697
Tim,
Thank you for your help. I will look into this right now to see if I can pull it out of the database and get this done. If I were to have it all in a table, I would I go about pull it all out and have this set of codes you've just written for me.
Thanks again in advance...
-
09-29-2009, 09:55 PM #4Web Hosting Master
- Join Date
- Mar 2009
- Posts
- 2,222
-
09-30-2009, 01:46 AM #5Web Hosting Master
- Join Date
- Apr 2005
- Posts
- 697
Here's what I got thus far, please guide me thru this:
Code:<?php $con = mysql_connect("localhost","numbers","numbers"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("numbers", $con); $gxlc_db = mysql_query("SELECT ccodes FROM original limit 2000") or die(mysql_error()); while($gxlc = mysql_fetch_array($gxlc_db)) { $ccode = $gxlc['ccodes']; for each $ccode[] for each line in group set digitarray to 0 for each column in line set digitarray.columndigit to 1 end of column loop end of line loop set outstring to null set digitarray.10 to 0 to simplify logic for each digit from 0 to 9 if digitarray.digit = 0 then iterate else set temp to digit for digit from digit+1 to 9 if digitarray.digit = 0 then leave innerloop else temp = temp || digit2 end of inner digit loop if length(temp) > 2 then temp = "[" || left(temp,1) || "-" right(temp,1) || "]" outstring = outstring || temp end end outer digit loop output outstring || "." end of group loop
-
09-30-2009, 02:27 AM #6Web Hosting Master
- Join Date
- Mar 2009
- Posts
- 2,222
-
09-30-2009, 03:10 AM #7Web Hosting Master
- Join Date
- Apr 2005
- Posts
- 697
I wouldn't know where to even begin... I don't even know php that well... was hoping for someone to rescue me...
Similar Threads
-
The Planet | The Equation for Great Hosting: These Deals + Our Service
By KHazard in forum Dedicated Hosting OffersReplies: 4Last Post: 04-18-2008, 10:31 AM -
numbers
By Frimon86 in forum Running a Web Hosting BusinessReplies: 7Last Post: 07-22-2006, 03:00 PM -
1-800 Numbers
By L.C. in forum Web Hosting LoungeReplies: 5Last Post: 12-15-2004, 10:44 PM -
Finish this Equation.....
By talon39 in forum Running a Web Hosting BusinessReplies: 4Last Post: 08-04-2003, 06:10 PM -
the support equation
By greengunboat in forum Running a Web Hosting BusinessReplies: 9Last Post: 01-15-2002, 12:46 PM