• Login
sketchucation logo sketchucation
  • Login
πŸ€‘ SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

Ruby Challenge!

Scheduled Pinned Locked Moved Developers' Forum
26 Posts 8 Posters 2.9k Views 8 Watching
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    Jim
    last edited by 28 Nov 2007, 23:51

    I was curious about the behavior of UI.play_sound. On my system, window 2000 pro, I wrote the core of the challenge as follows:

    
    Dir["c;\winnt\media\*"].each {|s| UI.play_sound(s)}
    
    

    This played all the sounds simultaneously. Is the behavior the same for everyone?

    Hi

    1 Reply Last reply Reply Quote 0
    • R Offline
      RickW
      last edited by 28 Nov 2007, 23:51

      That's what I got...

      RickW
      [www.smustard.com](http://www.smustard.com)

      1 Reply Last reply Reply Quote 0
      • R Offline
        RickW
        last edited by 28 Nov 2007, 23:52

        Okay, round 2 is closed. TIG and I each got it down to 84 characters with the following code:

        @tig said:

        c=0;Dir["C:/WINDOWS/Media/*v"].each{|w|UI.play_sound w;UI.inputbox([w],["#{c+=1}"])}

        @rickw said:

        i=0;Dir["C:/WINDOWS/Media/*v"].each{|f|UI.play_sound f;puts"#{i+=1}: #{f}";sleep(3)}

        I could have squeezed it to 83 by removing the space after the : in the puts statement, but decided against it.

        Thanks to everyone who worked on this - it was a fun challenge, and we should do another one next month πŸ˜„

        RickW
        [www.smustard.com](http://www.smustard.com)

        1 Reply Last reply Reply Quote 0
        • R Offline
          RickW
          last edited by 28 Nov 2007, 23:52

          Too late for deadline, but a shorter (77 characters) solution:

          i=0;Dir["C:/WINDOWS/Media/*"].each{|f|UI.play_sound f;puts [i+=1,f];sleep(3)}

          If anyone can reduce it from here, please post and enlighten us all πŸ˜„

          RickW
          [www.smustard.com](http://www.smustard.com)

          1 Reply Last reply Reply Quote 0
          • D Offline
            daiku
            last edited by 28 Nov 2007, 23:53

            OBFUSCATORS! You should be trying to make it MORE readable, not less! (switch to high, crackly voice) You young punks don't know how good you've got it! Why, back in my day, all we had was ones and zeros. And sometimes we didn't even have zeros, and we had to use the letter O!

            πŸ˜‰ πŸ˜‰ πŸ˜‰

            Clark Bremer
            http://www.northernlightstimberframing.com

            1 Reply Last reply Reply Quote 0
            • J Offline
              Jim
              last edited by 28 Nov 2007, 23:53

              @rickw said:

              Too late for deadline, but a shorter (77 characters) solution:

              i=0;Dir["C:/WINDOWS/Media/*"].each{|f|UI.play_sound f;puts [i+=1,f];sleep(3)}

              If anyone can reduce it from here, please post and enlighten us all πŸ˜„

              
              i=0;Dir["/WINDOWS/Media/*"].map{|f|UI.play_sound f;p i+=1,f;sleep 3}
              
              

              That would be 68? πŸ˜‰

              Hi

              1 Reply Last reply Reply Quote 0
              • R Offline
                RickW
                last edited by 28 Nov 2007, 23:54

                Nice job Jim! πŸ˜„

                Clark, that was too funny πŸ˜†

                RickW
                [www.smustard.com](http://www.smustard.com)

                1 Reply Last reply Reply Quote 0
                • T Offline
                  TIG Moderator
                  last edited by 28 Nov 2007, 23:54

                  Tweaking Jim's..

                  i=0;Dir["/*/Media/*v"].map{|f|UI.play_sound f;p i+=1,f;sleep 3}
                  

                  That would be 63... AND it only plays wav files, not falling over on midi's etc... (62 otherwise)

                  TIG

                  1 Reply Last reply Reply Quote 0
                  • J Offline
                    Jim
                    last edited by 28 Nov 2007, 23:55

                    @tig said:

                    Tweaking Jim's..

                    i=0;Dir["/*/Media/*v"].map{|f|UI.play_sound f;p i+=1,f;sleep 3}
                    

                    That would be 63... AND it only plays wav files, not falling over on midi's etc... (62 otherwise)

                    Alright TIG!

                    A note about using Dir[""]: I didn't specify a file ending because I have files that end in .WAV. These files do not get played because they end in capital letters. The shortest way to get ALL the files was o use *.

                    Hi

                    1 Reply Last reply Reply Quote 0
                    • R Offline
                      RickW
                      last edited by 28 Nov 2007, 23:56

                      hmm... the last two solutions won't play on my machine.

                      RickW
                      [www.smustard.com](http://www.smustard.com)

                      1 Reply Last reply Reply Quote 0
                      • J Offline
                        Jim
                        last edited by 28 Nov 2007, 23:56

                        @rickw said:

                        hmm... the last two solutions won't play on my machine.

                        Both work for me.

                        Hi

                        1 Reply Last reply Reply Quote 0
                        • romboutR Offline
                          rombout
                          last edited by 14 Aug 2008, 00:02

                          interesting this stuff does anyone know how to stop a file from playing in UI

                          1 Reply Last reply Reply Quote 0
                          • M Offline
                            morisdov
                            last edited by 14 Aug 2008, 11:09

                            rombout look here - stopping UI.play_sound ? -
                            http://www.sketchucation.com/forums/scf/viewtopic.php?f=180&t=10352&p=68452#p68452

                            1 Reply Last reply Reply Quote 0
                            • romboutR Offline
                              rombout
                              last edited by 16 Sept 2008, 18:20

                              yeah i already knew that one. But thanx anyway, did you already found different solution

                              1 Reply Last reply Reply Quote 0
                              • 1
                              • 2
                              • 2 / 2
                              • First post
                                Last post
                              Buy SketchPlus
                              Buy SUbD
                              Buy WrapR
                              Buy eBook
                              Buy Modelur
                              Buy Vertex Tools
                              Buy SketchCuisine
                              Buy FormFonts

                              Advertisement