Jump to content

Give the above person a error - Game


Sniffy

Recommended Posts

I'd normally be against threads like this on a forum, and so against this thread. But, if rules are properly developed and lain down, this has potential of being a good game thread. It's also relevant to the forum's topic (coding), and it's good practise for finding errors when coding. Can someone make some clear and easy-to-understand rules?

Link to comment
Share on other sites

Yup. It does, which is why I think the initial rules + my suggestion would be best. In any case, the topic would have to be cleaned...Post model:

  1. The first poster starts with a problem (task) to solve. At the end of his/her post, (s)he will add a language or (preferrably) a list of languages.
  2. Every next poster first MUST solve the problem at hand.
  3. After the problem is solved, that same poster MAY create a new problem. The new problem SHOULD be in the language the previous poster has specified as his/her (list of) language(s).
  4. The poster solving the issue MUST include a (list of) language(s) that (s)he would like to see as the next problem, regardless of whether (s)he created a new problem or not.

Rules:

  1. No one is allowed to have two answers in a row!*
  2. Only one problem at a time. Don't post new issues before the current one is solved!**
  3. When you create a new problem, let it be only one problem, not several problems in one post. That is, one file to work on (be it with one or more mistakes in it), not several files.
  4. When the error is not in syntax, but semantics, descibe what is the code supposed to do, or give further details. It will be up to the solver to see what the code does as is and where is that semantical error.***

* In the worst case, this will make it 4 players' game.** For simpler cases, you may directly write a new problem, before the issuer has confirmed that you solved the issue. For more complicated problems, this is still optional, but highly reccomened.*** For example, ".menu:hover" and ".menuhover" are both valid CSS selectors, but they select two different things. In a case like this you could say "This is applied over this (X)HTML: <a class="menu">link</a>" or you could say "One character away from the desired mouse effect".

Link to comment
Share on other sites

Okay, sounds good.So say I make a problem, and another person solves it, that other person would make a problem according to my knowledge?
What you write in your list doesn't have to be your knowledge, but rather what you want to see next. I'm suggesting this, because knowledge of languages changes much slower then preferences. So at one point you might want to see other people struggle with PHP, while the next time you decide you want to watch some XML action, etc.In any case, you won't be answering the next problem.
Link to comment
Share on other sites

You start this time.Wait, I'll do it.PHP:

<%php$the_match = $_PoST['match'];$34regex = "#^[a-zA-Z0-9]+$";if(preg_match($34regex, $the_match)){echo "Match Valid";}else{echo "Invalid Match";}%>

Following UP:XML + XSLTASP

Link to comment
Share on other sites

Hey! You asked for such a problem on purpose! You knew I'll reply next and that I can best come up with an issue like that, admit it :) .The PHP script must begin with "<?php" and end with "?>". Also, I'm not sure, but I think the fixed POST variable is case sencetive. In preg_.*() functions, regular expressions must be enclosed by "/" and so the completely working code should be:

<?php$the_match = $_POST['match'];$34regex = "/#^[a-zA-Z0-9]+$/";if(preg_match($34regex, $the_match)){echo "Match Valid";}else{echo "Invalid Match";}?>

I'm not sure about the "<%php" though. It might be legal, after adjusting the server.Anyhow, let me start with pure XML, so that there could be someone to solve it...Make the following a well formed XML document, without adding new nodes. Rename the existing ones by will if needed for the sake of well formdness. Avoid removing nodes, unless the only other way is adding a node. The rest is irrelevant:

<?xml ver="1' utf-8"?>><root element><elemene><!--OMG. This won't be read.... -- Help --><elemenet/></element><1atri barti="ute"/></elemene><1atri>barti<ute/></ati><</elemene></root element>

I'm intentionally making it really broken, so that you couldn't simply launch it into the browser and be guided by error messages.NEXT (in order of preference): CSS, XHTML, PHP.

Link to comment
Share on other sites

Since I started I cannot answer this problem, but I can still comment. I never knew preg_match() had to have the // delimeters.So would ereg_match() work for ## delimeters?And yes I did know that you would post next. :)

Link to comment
Share on other sites

Since I started I cannot answer this problem, but I can still comment. I never knew preg_match() had to have the // delimeters.So would ereg_match() work for ## delimeters?And yes I did know that you would post next. :)
You broke rule #2 of section #1 of Boen's rules. *whistles*Err...Okay, since I totally ###### at XML, I'll give it a try. :):D:D
<?xml version="1.0" encoding="utf-8" ?>  <rootelement>	<element>	  <element />	  <atri barti="ute" />	  <atri>barti</atri>	</element>  </rootelement>

My first XML document. I'm so proud. :)Okay. For my problem, I'll go for CSS:

//This is a class|manife [drawers: 23	px;//Omg what to do//jonas: cool; //I ran out of attributes. :P}//This is an id-go {z-index: 30%;position: relative;]//I'm done.

Hah. Fix it up, man!Next:JavaScript, PHP, or XHTML, listed by preference.;D

Link to comment
Share on other sites

I can't answer that one, but scince I'm the author of the last question, I'm able to comment on your answer.It's actually wrong, though what you show is truly a well formed XML document.

  • You're missing one node, which was the only node in the sample to have perfectly well formed content and be well formed itself.
  • You've removed a whole node, just because of an error in it's contents (a text node). You should have edited the contents, not remove the whole node and it's parent because of that.
  • You've renamed nodes which had valid names. For example "elemenet", "elemene" and "element" are all well formed, and scince the last one is not present in the XML at all, one of the other two (depending on the well formdness) should have been used.

You did fixed the more obvious errors though, so it would be easy for anyone to guess the right answer from here on. Go on...

Link to comment
Share on other sites

Just to go back to this:

<?php$the_match = $_POST['match'];$34regex = "/#^[a-zA-Z0-9]+$/";if(preg_match($34regex, $the_match)){echo "Match Valid";}else{echo "Invalid Match";}?>

PHP variable names cannot begin with a number. That would need to be fixed as well.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...