Page 4 of 4

Re: Programming Practice

Posted: Tue Mar 24, 2009 6:13 pm
by BlueMonkey5
yea, youre totally right... i'm getting too nit-picky. i'm just gonna get them both and check them both out. whichever one sticks, we'll see.

Re: Programming Practice

Posted: Thu Mar 26, 2009 5:07 am
by Ewan
BlueMonkey5 wrote:LOL... nice. yea that sounds really cool. it's actually a big comfort hearing that you failed the first two times (as twisted as that sounds), because I failed two times at programming too! so wow, that actually does inspire me some and gives me hope that i can give it another whack. thanks!

But here's a good question if anyone knows- is darkbasic similar to C++? so basically, if i start off learning darkbasic, will it be an easy switch to learn C++? if it is, it would be worth while to do that and then make the switch. if they are similar, alongside being useful, learning darkbasic would also be practice when switching to C++. it would be like learning something to help getting started with that. but if they're totally different, i would just start off with C, and maybe play around with darkbasic on the side to see what it's all about.
You should probably watch this: http://www.youtube.com/watch?v=zAgpsks2 ... 98&index=0 and the next two ;)

Re: Programming Practice

Posted: Thu Mar 26, 2009 7:14 pm
by BlueMonkey5
cool, thanks :D

Re: Programming Practice

Posted: Fri Mar 27, 2009 7:06 am
by Arce
Make an executable output it's own source.

Good luck. ^.^

Re: Programming Practice

Posted: Fri Mar 27, 2009 2:40 pm
by dandymcgee
Arce wrote:Make an executable output it's own source.

Good luck. ^.^
Omg. :shock:
Quines are EVIL!

Re: Programming Practice

Posted: Sat Mar 28, 2009 10:21 am
by M_D_K
Arce wrote:Make an executable output it's own source.

Good luck. ^.^
I was talking to avansc about that one time(I was going to submit it here as a challenge)

Re: Programming Practice

Posted: Sat Mar 28, 2009 7:19 pm
by Ewan
M_D_K wrote:OK I have one for yout all. Now it seems alot of programmers(experienced ones too) have problems figuring this one out.

OK so here it is
Click here to see the hidden message (It might contain spoilers)
Print the numbers from 1 to 100 if the number is a multiple of 3 print foo, if it is a multiple of 5 print bar, if its both print foobar. BTW you'll be printing foo,bar,etc instead of the number

Seems easy but I know people who have been scratching their respective heads on this. When I heard of it I figured it out in like 10 seconds ;)

EDIT: You don't have to make it recursive but bonus points if you do.
Good Luck.
Did that, interesting little challenge. For me anyway :lol:

I haven't tested it completely, the numbers look right though.

Code: Select all

#include <iostream>
#include <stdio.h>
#include <math.h>

using namespace std; 

int main()
{
    double intpart;
    double a;
    

    for (double n = 1;n < 101;n++)
    {
        a = modf (n/3,&intpart);
        if (a == 0)
        {
           cout << "foo";
        }
        a = modf(n/5,&intpart);
        if (a==0)
        {
           cout << "bar ";
        }
        {
        cout << n << endl;
        }
        
    }
    system("PAUSE");
    return 0;
}

Re: Programming Practice

Posted: Sun Mar 29, 2009 1:18 am
by LuciDreamTheater
dandymcgee wrote:
Arce wrote:Make an executable output it's own source.

Good luck. ^.^
Omg. :shock:
Quines are EVIL!
Here's a twist: Write a program that reads in a text file and determines whether it is it's own source code. (Note: Cannot read the source file).

Re: Programming Practice

Posted: Mon Mar 30, 2009 3:24 pm
by dandymcgee
anothrguitarist wrote: Here's a twist: Write a program that reads in a text file and determines whether it is it's own source code. (Note: Cannot read the source file).
What kind of sick twisted person thinks up something like this? :evil: :lol:

Re: Programming Practice

Posted: Mon Mar 30, 2009 7:28 pm
by Arce
M_D_K wrote:
Arce wrote:Make an executable output it's own source.

Good luck. ^.^
I was talking to avansc about that one time(I was going to submit it here as a challenge)
That was the #4 program for the competition I won last weekend.

It's a team challenge. Each team is 4 members and can only have one laptop. Programs can be written in any language. You have 2 hours to complete 4 programs and present them to a panel of judges.

They are sorted in order of difficulty. Ours were something like this:

1) Read in a comma separated list of words. Display each word only once, but increase the size for the amount of repetitions of the word entered.

Example input:
this,this,this,this,small,gay,gay,hi,sup,hi
Example Output:
this, small, sup , gay, hi

Should handle spacing correctly. Order of output does not matter.

2) Read a maze into an array. 'X' denotes a wall (unwalkable space), 'O' a walkable position, 'S' starting point, and 'E' ending point. Assume that no maze has circles/repeating spots. Write a program to display the coordinates (in order) that one would have to follow to reach the end of the maze. You cannot backtracks (repeat coordinates). Only traverse in cardinal directions.

Example input:

Code: Select all

X X S X X X X X X X 
X X O X X X X X X X
X X O O O O O X X X 
X X O X X X O O X X
X X O O O O X X X X 
X X X X X O X X X X
X X X X X O X X X X
X X X O O O O O X X
X X X O X X X O X X
X X X X X X X E X X
Output: (too lazy to type, fuck you.)

3) Some dipshit has problems sorting .txt files on his desktop. He needs you to help him out. Write a program to parse through all text files on the desktop, read in 3 space-separated words from that files, and rename the files to those three words (replacing spaces with underscores and ignore non-alphanumeric characters characters). If there is less than three words in the file, only use the words that are found. If there is already a file with the existing name, prefix the name numerically (rename the first with a 1, second with a 2, etc).

4) Write a quin. A program that outputs it's own source.

Surprisingly, we got first place trophies. I had a kind or argument with a judge over #2, and he didn't like our #4 solution. :lol:

Will be going to state for this one, too. (in addition to the level editor stuff). I'll let ya know if I get any loot! Also, lemme know if anybody else here thinks they can get all 4 done in 2 hours (I almost call bullshit on that).

I ended up doing one in Blitz, one in Java, one in C++, and one in nothing/Java/C++. :lol:

Re: Programming Practice

Posted: Tue Mar 31, 2009 10:13 pm
by MarauderIIC
<bored>
Here's how I'd do them, for the interested :P
Arce wrote: That was the #4 program for the competition I won last weekend.

It's a team challenge. Each team is 4 members and can only have one laptop. Programs can be written in any language. You have 2 hours to complete 4 programs and present them to a panel of judges.

They are sorted in order of difficulty. Ours were something like this:

1) Read in a comma separated list of words. Display each word only once, but increase the size for the amount of repetitions of the word entered.

Example input:
this,this,this,this,small,gay,gay,hi,sup,hi
Example Output:
this, small, sup , gay, hi

Should handle spacing correctly. Order of output does not matter.
Click here to see the hidden message (It might contain spoilers)
#include <map>
using namespace std;

map<string, int> myMap;
myMap[word from file]++;
size = map<string, int>::iterator i.second();

2) Read a maze into an array. 'X' denotes a wall (unwalkable space), 'O' a walkable position, 'S' starting point, and 'E' ending point. Assume that no maze has circles/repeating spots. Write a program to display the coordinates (in order) that one would have to follow to reach the end of the maze. You cannot backtracks (repeat coordinates). Only traverse in cardinal directions.

Example input:

Code: Select all

X X S X X X X X X X 
X X O X X X X X X X
X X O O O O O X X X 
X X O X X X O O X X
X X O O O O X X X X 
X X X X X O X X X X
X X X X X O X X X X
X X X O O O O O X X
X X X O X X X O X X
X X X X X X X E X X
Output: (too lazy to type, fuck you.)
Click here to see the hidden message (It might contain spoilers)
A*
No loops mean you can do a tree -- DFS (or a BFS...)
Or you could do an algo that tries all left, then all up, then all down, then all right. But you'd have to keep track of where you've been.
3) Some dipshit has problems sorting .txt files on his desktop. He needs you to help him out. Write a program to parse through all text files on the desktop, read in 3 space-separated words from that files, and rename the files to those three words (replacing spaces with underscores and ignore non-alphanumeric characters characters). If there is less than three words in the file, only use the words that are found. If there is already a file with the existing name, prefix the name numerically (rename the first with a 1, second with a 2, etc).
Click here to see the hidden message (It might contain spoilers)
I could maybe do this in linux using execlp and ls, grep, mv.

4) Write a quin. A program that outputs it's own source.
I dunno. Google tells me how to do it though.

</bored>

Re: Programming Practice

Posted: Mon Apr 06, 2009 1:04 am
by eatcomics
MarauderIIC wrote:<bored>
Here's how I'd do them, for the interested :P
Arce wrote: That was the #4 program for the competition I won last weekend.

It's a team challenge. Each team is 4 members and can only have one laptop. Programs can be written in any language. You have 2 hours to complete 4 programs and present them to a panel of judges.

They are sorted in order of difficulty. Ours were something like this:

1) Read in a comma separated list of words. Display each word only once, but increase the size for the amount of repetitions of the word entered.

Example input:
this,this,this,this,small,gay,gay,hi,sup,hi
Example Output:
this, small, sup , gay, hi

Should handle spacing correctly. Order of output does not matter.
Click here to see the hidden message (It might contain spoilers)
#include <map>
using namespace std;

map<string, int> myMap;
myMap[word from file]++;
size = map<string, int>::iterator i.second();

2) Read a maze into an array. 'X' denotes a wall (unwalkable space), 'O' a walkable position, 'S' starting point, and 'E' ending point. Assume that no maze has circles/repeating spots. Write a program to display the coordinates (in order) that one would have to follow to reach the end of the maze. You cannot backtracks (repeat coordinates). Only traverse in cardinal directions.

Example input:

Code: Select all

X X S X X X X X X X 
X X O X X X X X X X
X X O O O O O X X X 
X X O X X X O O X X
X X O O O O X X X X 
X X X X X O X X X X
X X X X X O X X X X
X X X O O O O O X X
X X X O X X X O X X
X X X X X X X E X X
Output: (too lazy to type, fuck you.)
Click here to see the hidden message (It might contain spoilers)
A*
No loops mean you can do a tree -- DFS (or a BFS...)
Or you could do an algo that tries all left, then all up, then all down, then all right. But you'd have to keep track of where you've been.
3) Some dipshit has problems sorting .txt files on his desktop. He needs you to help him out. Write a program to parse through all text files on the desktop, read in 3 space-separated words from that files, and rename the files to those three words (replacing spaces with underscores and ignore non-alphanumeric characters characters). If there is less than three words in the file, only use the words that are found. If there is already a file with the existing name, prefix the name numerically (rename the first with a 1, second with a 2, etc).
Click here to see the hidden message (It might contain spoilers)
I could maybe do this in linux using execlp and ls, grep, mv.

4) Write a quin. A program that outputs it's own source.
I dunno. Google tells me how to do it though.

</bored>
<bull>Oh man! You really showed marcel that it's possible! </bull>