Need some JavaScript puzzles

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Oltmans

    Need some JavaScript puzzles

    Hi guys,
    I'm learning JavaScript and I need some puzzles that can make me a
    better JavaScript programmer. I mean I'm looking out for programming
    puzzles (e.g. Project Euler or TopCoder) but I'm looking out for
    language specific puzzles that can make me a top-notch JavaScript
    programmer. a) Any puzzles you can recommend? b) Any programs that you
    can suggest that can make me learn JavaScript internals in greatest
    depth.

    Please recommend anything. I know some very best programmers lurk
    around here so any help will be appreciated. Moreover, to people
    who've been using JavaScript for sometime, please recommend programs
    that you wish you had done earlier to understand internals in a better
    way. Thanks in advance.
  • Thomas 'PointedEars' Lahn

    #2
    Re: Need some JavaScript puzzles

    Oltmans wrote:
    I'm learning JavaScript and I need some puzzles that can make me a better
    JavaScript programmer. I mean I'm looking out for programming puzzles
    (e.g. Project Euler or TopCoder) but I'm looking out for language
    specific puzzles that can make me a top-notch JavaScript programmer. a)
    Any puzzles you can recommend?
    You will not become what you aspire to be by solving trivial puzzles. Find
    a *real-world problem* that you want to solve. Try to solve it using an
    ECMAScript implementation like JavaScript. There is no better exercise,
    even if the scripted solution turns out not to be the best approach to solve
    that particular problem.
    b) Any programs that you can suggest that can make me learn JavaScript
    internals in greatest depth.
    Programs?
    Please recommend anything. I know some very best programmers lurk around
    here so any help will be appreciated.
    I do not think they just *lurk* *here*.
    Moreover, to people who've been using JavaScript for sometime, please
    recommend programs that you wish you had done earlier to understand
    internals in a better way. Thanks in advance.
    I can recommend Mozilla Thunderbird to subscribe to, read, and post to
    comp.lang.javas cript using your real name.


    PointedEars
    --
    Prototype.js was written by people who don't know javascript for people
    who don't know javascript. People who don't know javascript are not
    the best source of advice on designing systems that use javascript.
    -- Richard Cornford, cljs, <f806at$ail$1$8 300dec7@news.de mon.co.uk>

    Comment

    • Oltmans

      #3
      Re: Need some JavaScript puzzles


      You will not become what you aspire to be by solving trivial puzzles.  Find
      a *real-world problem* that you want to solve.  Try to solve it using an
      ECMAScript implementation like JavaScript.  There is no better exercise,
      even if the scripted solution turns out not to be the best approach to solve
      that particular problem.
      Point taken. On a serious note, can you recommend some projects that I
      should be working on in my spare time? Any ideas that you have. Thanks
      in advance.

      Comment

      • Steve Swift

        #4
        Re: Need some JavaScript puzzles

        Oltmans wrote:
        Please recommend anything. I know some very best programmers lurk
        around here so any help will be appreciated. Moreover, to people
        who've been using JavaScript for sometime, please recommend programs
        that you wish you had done earlier to understand internals in a better
        way. Thanks in advance.
        Well, one recommendation would be to lurk around here. You'll get a
        never-ending supply of "why doesn't this work?" questions. Since you'll
        be facing some of these (of your own making), skill in working out why
        something doesn't work can be quite handy. I probably spend more time on
        the one thing that doesn't work than I do on the few things coded by me
        that do work.

        --
        Steve Swift


        Comment

        • Thomas 'PointedEars' Lahn

          #5
          Re: Need some JavaScript puzzles

          Oltmans wrote:
          >You will not become what you aspire to be by solving trivial puzzles. Find
          >a *real-world problem* that you want to solve. Try to solve it using an
          >ECMAScript implementation like JavaScript. There is no better exercise,
          >even if the scripted solution turns out not to be the best approach to solve
          >that particular problem.
          >
          Point taken. On a serious note, can you recommend some projects that I
          should be working on in my spare time? Any ideas that you have. Thanks
          in advance.
          There are several open-source projects you could generally contribute to,
          however I am afraid that without more-than-pedestrian knowledge you could
          neither appreciate your participation in those projects as you would like
          to, nor would it be likely that you could make a considerable contribution
          to them.

          IMHO, programming languages can be learned best like natural languages: by
          using them in everyday life. Therefore, I (seriously) suggested you try to
          use scripting to solve *your* problems first, those which bug *you* the
          most. Start with the ones that look simple on the outset. Find them to be
          more complex than you thought. Do not let yourself be discouraged, and take
          your time to solve them eventually. Then use the experience gained to solve
          even more complex problems.

          When (not: if) you get stuck in the process, read *again* everything about
          the topic that you can get your hands on (electronic material is cheapest
          and readily available, but not always best; books are more expensive and
          tend to be bad). Read it again. What is most important: Do not fall for
          self-proclaimed gurus; compare your sources, verify what they are saying.
          Look into the message, not at the messenger. If anything still remains
          unclear, ask smart questions[1] about it.

          This is how I started learning the languages a decade ago and it is still
          serving me well.


          HTH

          PointedEars

          P.S.
          Please shorten, but do not remove attribution lines for quotations you leave in.
          ___________
          [1] <http://catb.org/~esr/faqs/smart-questions.html>
          --
          realism: HTML 4.01 Strict
          evangelism: XHTML 1.0 Strict
          madness: XHTML 1.1 as application/xhtml+xml
          -- Bjoern Hoehrmann

          Comment

          • Hal Rosser

            #6
            Re: Need some JavaScript puzzles


            "Oltmans" <rolf.oltmans@g mail.comwrote in message
            news:8c661acb-a57c-4b45-ba72-b79e33d7fbc6@l6 4g2000hse.googl egroups.com...
            Hi guys,
            I'm learning JavaScript and I need some puzzles that can make me a
            better JavaScript programmer. I mean I'm looking out for programming
            puzzles (e.g. Project Euler or TopCoder) but I'm looking out for
            language specific puzzles that can make me a top-notch JavaScript
            programmer. a) Any puzzles you can recommend? b) Any programs that you
            can suggest that can make me learn JavaScript internals in greatest
            depth.
            >
            Please recommend anything. I know some very best programmers lurk
            around here so any help will be appreciated. Moreover, to people
            who've been using JavaScript for sometime, please recommend programs
            that you wish you had done earlier to understand internals in a better
            way. Thanks in advance.
            OK -
            Create a Bingo Game
            or a Checkers game
            or a Calculator like the windows accessories calculator
            or a number-to-words (like writing a check) program without getting help
            or all the above.
            or if you like recursion, look at the "towers of Hanoi" puzzle.(google it)


            Comment

            • dhtml

              #7
              Re: Need some JavaScript puzzles

              Oltmans wrote:
              Hi guys,
              I'm learning JavaScript and I need some puzzles that can make me a
              better JavaScript programmer. I mean I'm looking out for programming
              puzzles (e.g. Project Euler or TopCoder) but I'm looking out for
              language specific puzzles that can make me a top-notch JavaScript
              programmer. a) Any puzzles you can recommend? b) Any programs that you
              can suggest that can make me learn JavaScript internals in greatest
              depth.
              >
              Please recommend anything. I know some very best programmers lurk

              Only the best lurkers here!
              O_o
              :-D
              around here so any help will be appreciated. Moreover, to people
              who've been using JavaScript for sometime, please recommend programs
              that you wish you had done earlier to understand internals in a better
              way. Thanks in advance.

              1. write a function return the binary representation of a given number
              in "ON" and "OFF". For example, if the input is 47 (101111 in binary),
              it should return "ON OFF ON ON ON ON".

              Comment

              • Jorge

                #8
                Re: Need some JavaScript puzzles

                On Sep 24, 3:14 am, dhtml <dhtmlkitc...@g mail.comwrote:
                >
                1. write a function return the binary representation of a given number
                in "ON" and "OFF".  For example, if the input is 47 (101111 in binary),
                it should return "ON OFF ON ON ON ON".


                --
                Jorge.

                Comment

                • Jorge

                  #9
                  Re: Need some JavaScript puzzles

                  On Sep 24, 3:14 am, dhtml <dhtmlkitc...@g mail.comwrote:
                  >
                  1. write a function return the binary representation of a given number
                  in "ON" and "OFF".  For example, if the input is 47 (101111 in binary),
                  it should return "ON OFF ON ON ON ON".
                  [x] done: http://preview.tinyurl.com/3unmha

                  --
                  Jorge.

                  Comment

                  • Dr J R Stockton

                    #10
                    Re: Need some JavaScript puzzles

                    On Sep 23, 9:01 pm, Thomas 'PointedEars' Lahn <PointedE...@we b.de>
                    wrote:
                    Oltmans wrote:
                    You will not become what you aspire to be by solving trivial puzzles.  Find
                    a *real-world problem* that you want to solve.
                    NO. Real-world problems are generally either trivial or complex, and
                    neither is appropriate for practice. OP, choose instead problems
                    which, at your current state of knowledge, are on the verge of
                    difficulty. When you approach the ability to do a real-world non-
                    trivial problem that you want to solve, set it aside; the risks of
                    including someting bad and not realising it or not bothering to fix it
                    are too great. Instead, choose a problem of sufficient fifficulty
                    which you do not need to solve, so that you can throw away the
                    solution. Don't assume premature competence.

                    Tackle problems that you really need to solve only when you know
                    enough to be reasonably sure of making a good job of them.
                    Please shorten, but do not remove attribution lines for quotations you leave in.
                    Ignore that : people give attributions for a purpose, and full
                    attributions are useful in various ways that Thomas Lahn does not
                    understand. Remember, be is not psychologically normal, as is obvious
                    from reading a selection of his replies. Perhaps he is the Kaiser
                    reincarnated; perhaps something worse.

                    --
                    (c) John Stockton, near London, UK. Posting with Google.
                    Mail: J.R.""""""""@ph ysics.org or (better) via Home Page at
                    Web: <URL:http://www.merlyn.demo n.co.uk/>
                    FAQish topics, acronyms, links, etc.; Date, Delphi, JavaScript, ....|

                    Comment

                    • showellshowell@gmail.com

                      #11
                      Re: Need some JavaScript puzzles

                      On Sep 23, 8:50 am, Oltmans <rolf.oltm...@g mail.comwrote:
                      Hi guys,
                      I'm learning JavaScript and I need some puzzles that can make me a
                      better JavaScript programmer. [...]
                      >
                      [...] please recommend programs
                      that you wish you had done earlier to understand internals in a better
                      way. Thanks in advance.
                      One of the first Javascript programs that I wrote lives here:

                      http://webstervanrobot.com/ (only tested on Firefox)

                      The program implements a small programming language on top of
                      Javascript that allows a robot to move around a grid of streets and
                      avenues.

                      It got me acquainted with the following concepts:

                      creating objects
                      manipulating DOM
                      parsing strings
                      implementing data structures
                      responding to events
                      setting up callbacks and responding to them
                      variable scoping (this, var, etc.)
                      cross-browser pain (which I have punted on so far)

                      If you're learning Javascript, this might be a fun program to hack on,
                      because it's all self-contained and not tied to any domain, and I'm
                      hoping to make it a useful program. It really is a "Javascript
                      program," as opposed to code that lives within a larger system, for
                      better or worse.

                      Some challenges:

                      1) Make it work on a browser other than Firefox.
                      2) Change the world to be rendered on a canvas instead of tables.
                      3) Add scrolling to the world.
                      4) Add new capabilities for the robot.
                      5) Add new syntax to the programming language.
                      6) Simply play around with the code, try to restructure it to your
                      liking.
                      7) Get the program to have a mode where you can click on it to see
                      the internal data structures that define the world.

                      Yes, I'm subversively asking for help with my program, but the program
                      was written with the intention of helping people learn Javascript (and
                      programming in general). It's free software.

                      Cheers,

                      Steve


                      Comment

                      • Jorge

                        #12
                        Re: Need some JavaScript puzzles

                        On Sep 23, 5:50 pm, Oltmans <rolf.oltm...@g mail.comwrote:
                        >
                        Please recommend anything.
                        Have you seen Douglas Crockford's videos already ?

                        Measure, monetize, advertise and improve your apps with Yahoo tools. Join the 200,000 developers using Yahoo tools to build their app businesses.


                        --
                        Jorge.

                        Comment

                        • Douglas Crockford

                          #13
                          Re: Need some JavaScript puzzles

                          Oltmans wrote:
                          Hi guys,
                          I'm learning JavaScript and I need some puzzles that can make me a
                          better JavaScript programmer.
                          Dmitri showed me this one:

                          Define function add such that

                          add(3)(4)

                          returns 7.

                          Comment

                          • Jorge

                            #14
                            Re: Need some JavaScript puzzles

                            On Sep 27, 3:08 am, Douglas Crockford <nos...@sbcglob al.netwrote:
                            Oltmans wrote:
                            Hi guys,
                            I'm learning JavaScript and I need some puzzles that can make me a
                            better JavaScript programmer.
                            >
                            Dmitri showed me this one:
                            >
                            Define function add such that
                            >
                                 add(3)(4)
                            >
                            returns 7.
                            javascript:aler t((function add (p) { var a=p; return function (p)
                            { return a+p } })(3)(4))

                            --
                            Jorge

                            Comment

                            • Conrad Lender

                              #15
                              Re: Need some JavaScript puzzles

                              On 2008-09-27 03:18, Jorge wrote:
                              >Define function add such that>
                              > add(3)(4)
                              >returns 7.
                              >
                              javascript:aler t((function add (p) { var a=p; return function (p)
                              { return a+p } })(3)(4))
                              You don't need to create an extra variable.

                              function add (first) {
                              return function (second) {
                              return first + second;
                              }
                              }

                              But hey!
                              Don't spoil the fun for the OP by posting the solution!

                              @Douglas:
                              I'd also appreciate more puzzles if you know any. This kind of (simple
                              but interesting) problem is a godsend when you're teaching kids.

                              The only thing I've seen recently that comes close to a puzzle is this
                              website:



                              You need to enter the correct password, that's all. No rewards :-) It's
                              not pretty, rather the opposite, but if you like obfuscation, it might
                              be interesting. Syntax highlighting helps.


                              - Conrad

                              Comment

                              Working...