C Board  

Go Back   C Board > Community Boards > Contests Board

Reply
 
LinkBack Thread Tools Display Modes
Old 12-22-2007, 01:09 AM   #1
Rampaging 35 Stone Welsh
 
abachler's Avatar
 
Join Date: Apr 2007
Posts: 2,929
New years challenge!

Using only assembly and a single beep() statement, write a program that plays a familiar christmas tune.

You cant use a table of values. You have to calculate the next note and duration through some algorithm.

You can obviously use the Beep() in a loop to play the notes.

Happy Holidays and good luck
__________________
He is free, you say. Ah! That is his misfortune… These men… [have] the most terrible, the most imperious of masters, that is, need. … They must therefore find someone to hire them, or die of hunger. Is that to be free? - Simon Linguet
abachler is offline   Reply With Quote
Old 12-22-2007, 07:35 AM   #2
Chinese pâté
 
foxman's Avatar
 
Join Date: Jul 2007
Location: Canada
Posts: 406
This looks hard. By the way, in which header file is Beep defined ? I don't find it in the standard header files, only find it in <windows.h>... huh.

Help me
foxman is offline   Reply With Quote
Old 12-22-2007, 09:32 AM   #3
The superheterodyne.
 
twomers's Avatar
 
Join Date: Dec 2005
Location: Ireland
Posts: 2,205
I don't get it ... why only assembly? This site assemblyprogramming?
__________________
I blag!
twomers is offline   Reply With Quote
Old 12-22-2007, 07:47 PM   #4
Woof, woof!
 
zacs7's Avatar
 
Join Date: Mar 2007
Location: Australia
Posts: 3,139
I don't even have a system speaker It's broken.

Ohh and yes... why assembly?
__________________
"I.T. gets the chicky-babes" - M. Kelly
bakefile | vim
zacs7 is offline   Reply With Quote
Old 12-23-2007, 12:44 AM   #5
Deathray Engineer
 
MacGyver's Avatar
 
Join Date: Mar 2007
Posts: 3,211
Hope I picked a song that is allowed. Easy note arrangement.
__________________
MacGyver is offline   Reply With Quote
Old 12-23-2007, 01:13 AM   #6
Wheres the lesbians?
 
mike_g's Avatar
 
Join Date: Oct 2006
Location: UK
Posts: 1,219
An ASM only challenge on a C board is just stupid. Why don't we do it in Malbolge? Makes no difference to me o_0
mike_g is offline   Reply With Quote
Old 12-24-2007, 09:19 AM   #7
Rampaging 35 Stone Welsh
 
abachler's Avatar
 
Join Date: Apr 2007
Posts: 2,929
Quote:
Originally Posted by mike_g View Post
An ASM only challenge on a C board is just stupid. Why don't we do it in Malbolge? Makes no difference to me o_0
inline assembly is a part of most modern C/C++ compilers. Wheres the challenge in an easy contest? This is a contest for intermediate/advanced programmers, not noobs. And if it makes no difference to you, then you are OK with the contest the way it is.

Beep() is in <windows.h> Sorry I dont knowlinux well enough to suggest a similar function there.

Song selection will play a role in the contest, since different techniques may be more suitable to some songs than others.
__________________
He is free, you say. Ah! That is his misfortune… These men… [have] the most terrible, the most imperious of masters, that is, need. … They must therefore find someone to hire them, or die of hunger. Is that to be free? - Simon Linguet

Last edited by abachler; 12-24-2007 at 09:35 AM.
abachler is offline   Reply With Quote
Old 12-24-2007, 10:05 AM   #8
Wheres the lesbians?
 
mike_g's Avatar
 
Join Date: Oct 2006
Location: UK
Posts: 1,219
Well I guess I 2 noob. I might have had a go in C, but have fun all the same

Or can we post code after compiler optimization?
mike_g is offline   Reply With Quote
Old 12-24-2007, 10:12 AM   #9
Chinese pâté
 
foxman's Avatar
 
Join Date: Jul 2007
Location: Canada
Posts: 406
Anyway, i believe the hard part of this challenge isn't about the fact it has to be written in assembly, but that you need to find some sort of "algorithm" to calculate the next note and duration. This is what i believe the tricky part, i don't really have any idea and/or enough knowledge to think of something who could achieve this for something as complex as a song. But the term "algorithm" is rather large and incrementing an index and looking in a table is an algorithm...

Anyway.

I guess only "IA-32 assembly" will be accepted, right ?
foxman is offline   Reply With Quote
Old 12-24-2007, 10:46 AM   #10
Rampaging 35 Stone Welsh
 
abachler's Avatar
 
Join Date: Apr 2007
Posts: 2,929
Quote:
Originally Posted by mike_g View Post
Or can we post code after compiler optimization?
As long as the assembly is from code you wrote, this is acceptable.

I know looking into a table is an algorithm, but thats just way too easy. Finding a function that produces values you use is a bit more of a challenge, and is of course the interesting part of the contest.

Ill give you a hint on a way to solve it on the 26th if noone has made an entry or suggested another means.
__________________
He is free, you say. Ah! That is his misfortune… These men… [have] the most terrible, the most imperious of masters, that is, need. … They must therefore find someone to hire them, or die of hunger. Is that to be free? - Simon Linguet
abachler is offline   Reply With Quote
Old 12-25-2007, 06:03 AM   #11
Woof, woof!
 
zacs7's Avatar
 
Join Date: Mar 2007
Location: Australia
Posts: 3,139
What if it connects to MSN and we type in the song ourselves?
__________________
"I.T. gets the chicky-babes" - M. Kelly
bakefile | vim
zacs7 is offline   Reply With Quote
Old 12-25-2007, 08:25 AM   #12
and the Hat of Clumsiness
 
GanglyLamb's Avatar
 
Join Date: Oct 2002
Posts: 1,101
This is how I would do this: ( probably not the best way but still ).

See the song as a function with a period T (which is the duration of the song). Now use fourier ... ( I would actually define the function in maple, piecewise, then let maple do its magic and go for n=1 to n=1000). Then take this function, write it in assembler using some sort of lookup table for the sin and cosine. Afterwards, for the minimal amount of time a note is being played for instance 0.1 second, step trough the function (the mathematical expression), round to the nearest reall note which is also defined somewhere... and output using beep.

Its not a lookup method , unless you say that the function actually is a lookup table or something... but then again, every piece algorithm can be defined in that way....

::edit::

Thinking about this, it would actually take quite some time to determine the fourier approximation....

On the other hand the objective; using an algorithm can easily be done, by just substracting, adding, division etc of the start note its frequency..., of course this would result in something quite big (depending how many notes te be played but still). Then the question is again what is an algorithm, it would be more specific if you would say , write a method, that takes as input the note to start with for this or this song, depending on this note, shift the complete tone of the song one up or one down or whatever... then it would require something more complicated (taking into account you can not use lookup tables).

Anyhow, im not competing in this in any way just wanted to spill my thoughts on it .

Last edited by GanglyLamb; 12-25-2007 at 08:47 AM.
GanglyLamb is offline   Reply With Quote
Old 12-26-2007, 08:58 AM   #13
Rampaging 35 Stone Welsh
 
abachler's Avatar
 
Join Date: Apr 2007
Posts: 2,929
Quote:
Originally Posted by zacs7 View Post
What if it connects to MSN and we type in the song ourselves?
If you plan to sit at your computer 24 hours a day for several days in the hopes of doing that at exactly the moment I decide to run your entry and in the hopes that I run it on a computer with an internet connection instead of a hardened system, well, be my guest.

Now I promised a clue as to one method of doing this, so here goes.

X = (X * K) MOD P

Ill provide another hint tomorrow. Remember, the method im hinting at is only one of many that will work.
__________________
He is free, you say. Ah! That is his misfortune… These men… [have] the most terrible, the most imperious of masters, that is, need. … They must therefore find someone to hire them, or die of hunger. Is that to be free? - Simon Linguet

Last edited by abachler; 12-26-2007 at 09:03 AM.
abachler is offline   Reply With Quote
Old 12-27-2007, 12:27 PM   #14
Registered User
 
Tonto's Avatar
 
Join Date: Jun 2005
Location: New York
Posts: 1,465
Without supreme cleverness, I can't see how to do this.

Option I see is to basically encode the song into a discrete fourier transform, which is not far from a mere table of values.

This doesn't make any sense

X = (X * K) MOD P

X = 5, K = 2, P = 3

Like what? Is that not a mathematical equation in the traditional sense?

Rather a sequence X sub N = (X sub N-1 * K) MOD P?
__________________

╔╗╔╦══╦╗╔╦══╦╗
║╚╝║╔╗║╚╝║╔╗║║
║╔╗║╠╣║╔╗║╠╣╠╣
╚╝╚╩╝╚╩╝╚╩╝╚╩╝

codez http://code.google.com/p/zxcvbn/
Tonto is offline   Reply With Quote
Old 12-28-2007, 06:15 AM   #15
Banned
 
Join Date: Nov 2007
Posts: 678
why it has to be in assembly?
manav is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Delete Files Older than 2 years Dragoon_42 C++ Programming 10 05-17-2007 04:13 PM
Converting seconds to years, months etc... ^xor C Programming 7 08-06-2005 11:30 PM
Where will programming be in 30 years ? mrpickle A Brief History of Cprogramming.com 27 01-08-2004 05:42 AM
Requesting a challenge RealityFusion C++ Programming 8 08-18-2003 08:24 PM
Video Games Industry. 5 years left. ethic A Brief History of Cprogramming.com 26 12-10-2002 10:52 PM


All times are GMT -6. The time now is 09:14 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.0 RC2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22