Jump to content

aebstract

Members
  • Posts

    1,105
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

aebstract's Achievements

Advanced Member

Advanced Member (4/5)

0

Reputation

  1. //$n=$_POST['t']; because you have // in front of it?
  2. It's not homework. It's just for a game online, for fun. It does give you a list of numbers in a row, and $n is the number of numbers that are in that row. I've solved the game through the code I have, but now I'm trying to shorten it as much as possible and use better methods to accomplish the task. It's just a fun learning thing, and can be done in any way you choose. The code I provided was the way I solved it, but I know there are other possibilities and better options which is why I'm looking for help on some of it. I don't really know why I would need $n, unless like you said to go through that many iterations instead of pulling in all numbers. I know it mentions in the instructions something about it pulling in all numbers and that you can change it. I have tried to look in to the STDIN and those functions being used (they were provided to begin the game basically) but haven't found anything that really makes me understand how it's working. I tried the fscan code and it makes my code fail every test case, even though I'm not calling $n anywhere in my code. So I'm kinda lost as to what fscan is really doing I guess. Here is the entire game: Rules Write a program that prints the temperature closest to 0 among input data. If two numbers are equally close to zero, positive integer has to be considered closest to zero (for instance, if the temperatures are -5 and 5, then display 5). Game Input Your program must read the data from the standard input and write the result on the standard output. Input Line 1: N, the number of temperatures to analyze Line 2: The N temperatures expressed as integers ranging from -273 to 5526 Output Display 0 (zero) if no temperatures are provided. Otherwise, display the temperature closest to 0.
  3. <?php fscanf(STDIN,"%d",$n); $t = explode(" ", stream_get_line(STDIN, 256 + 1, "\n")); ?> This is how I get my original array, I don't have access to the source numbers beyond this. I'll play around with what you posted and see if I can figure something out.
  4. Because I don't know how to do a check to determine the correct option like that.
  5. An output of the array would look identical to what I showed as an example. Basically trying to find the closest value to 0 and if the closest value is the same positive and negative like -2 and 2, I need to output the positive.
  6. I have an array of numbers, something like: 1 > 5 2 > 10 3 > -2 4 > -6 5 > 3 I need to sort this array so that it is in numerical order IGNORING the negative signs. A correct ouput would be this order: -2 3 5 -6 10 Right now I am having to basically duplicate my array and then use str_replace to remove the - and then sort the list keeping my keys in tact with the values, that way I can go back and compare to my original array. I could use one array and do away with all of the extra if I knew a way to do this sort. Thanks in advance!
  7. I have a string that is unformatted and has a lot of commas in it. How would I add a \n linebreak after every 4th comma?
  8. I have this in my .htaccess RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^([[:alnum:]_]+)/$ /index.php?page=$1 [NC,L] RewriteRule ^([[:alnum:]_]+)/([[:alnum:]]+)/$ /index.php?page=$1&var1=$2 [NC,L] RewriteRule ^([[:alnum:]_]+)/([[:alnum:]]+)/([[:alnum:]]+)/$ /index.php?page=$1&var1=$2&var2=$3 [NC,L] RewriteRule ^([[:alnum:]_]+)/([[:alnum:]]+)/([[:alnum:]]+)/([[:alnum:]]+)/$ /index.php?page=$1&var1=$2&var2=$3&var3=$4 [NC,L] RewriteRule ^([[:alnum:]_]+)/([[:alnum:]]+)/([[:alnum:]]+)/([[:alnum:]]+)/([[:alnum:]]+)/$ /index.php?page=$1&var1=$2&var2=$3&var3=$4&var4=$5 [NC,L] When I go to: url.com/Category/Intakes/ everything works fine url.com/Category/Motor Mounts/ I get 404 Not Found I know it's something to do with the space, cause I can manually type in anything without a space and it will go, anything with a space and 404. I'm unsure how to fix the regex to fix it though.
  9. Hello, I am not sure this is the correct location for this, but I think it is.. should be, hopefully. We have an inventory control software that has a firebird sql based database, we have the odbc driver installed. This is on a windows server 2008 machine on our LAN. I need to access the information in that database from our web host so that I can use inventory counts on our website. I've got some very slight ideas of what to do but I have never done anything like this and for the most part am lost. Would really really appreciate any help I could get!
  10. That's nice and all, but I don't know how to target only the sections that have similar ETs to switch, rather than sort the entire array.
  11. I have an array, and to make it easy let's say they have 2 values: ET and SPEED Here is an example chart of the array printed out: KEY ET SPEED 8 5.2 60 3 5.3 60 1 5.4 70 7 5.4 60 9 5.4 90 6 5.5 60 5 5.6 60 2 5.6 65 4 5.7 60 I need to take this array and each group that has a matching ET, put them in order based on SPEED. The corrected chart should be like this: KEY ET SPEED 8 5.2 60 3 5.3 60 9 5.4 90 1 5.4 70 7 5.4 60 6 5.5 60 2 5.6 65 5 5.6 60 4 5.7 60 Just not sure of how to only arrange the section that need to be. Keys stay the same, just the order changes.
  12. I'll give your code a try and take a look at it. I was referring to q1s, etc and used X as a variable for them, sorry about that. I wasn't even thinking to mention it but, q1 q2 q3 would be lowest, but it's weird how it works. There is a target, say 4.70. You're trying to get as close as possible to that without going under, which I have taken and sorted out by creating an indexH and indexL. I didn't mention the L because I can do the same thing with it as I do with the H. There are 3 qualifying passes, if you run a 4.71 and then your other passes go under 4.70, you're still in a top spot because of your "best" time being that above 4.70 but very close to it. Hope that makes sense. I threw your code in to my 'compare' function, it didn't seem to change the results. Here is a link so you can see the output: http://www.outlawracing.com/index.php?page=ladders&event=8 If you look under the class '5.30 index' I'm pretty bad with doing custom functions like this, but the bq is set as the "best qualifying time" and is the one that needs to be used for comparison against the others
  13. Oops! Forgot, this might help: function compare ($a, $b) { if (!array_key_exists('bq', $a) || !array_key_exists('bq', $b)) return -1; if ($a['bq'] == $b['bq']) return 0; return $a['bq'] > $b['bq'] ? 1 : -1; // switch to reverse the ordering }
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.