Jump to content

Coding challenge


snakey
 Share

Recommended Posts

  • Replies 237
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Posted Images

Coding challenge number 2:

The stockmarket crysis (pseudo-) prophecy.

Write a program or piece of code that:

1. Takes an initial Value of a Stock.

2. Takes the aimed value of the Stock

and predicts the time it will take for the stock to rise to your desired value.

The program should do many of these calculations (100) , and give you an average value of how many days to expect.

Now for the rules:

The Percent in- or de-crease cannot just be random e.g. +10, 2, -13 +5, +6, -24.

These must be "weighted". Think gaussian curves and probability.

The program must make use of modern pc hardware: multiple cores or multiple threads.

The program can be written in ANY language, even in assembler if you want or can.

The most efficient program wins. Meaning the program that can return an average value of 100 calculations the fastest and most efficient, and fulfills all of the above, wins.

It seems this program is already out in the wild and being used by many brokers, but it's probably shareware and +1000$, otherwise I can't explain the current situation on the markets.

Pseudo because, of course we know stock markets seem random but they actually react to events in the industry and in politics and so on, this program will never give you a reliable source of information for your portfolio.

Hope this was understandable.

Should be interesting. :D

Link to comment
Share on other sites

Lols! Sorry but do u think this is for a small programing challenge? I mean the coding of this program could take months! I suggest someone else makes a challenge, this one is not realistic i u ask me! The challenges should be something u can make in (at most) 2-3 weeks, not something u could sell for 1000$!

Link to comment
Share on other sites

  • 3 weeks later...
  • 3 months later...

Time to get this back up!

Here's the challenge I mentioned a while ago: A game in 100 lines of code.

The Rules:

-Any language

-Any kind of game

-The submission should simply be 100 (or less) lines of text

-Even empty lines are counted - to simplify

-No additional files (unless your language/environment absolutely requires it)

-Using only standard libraries is allowed

-The above rules can bent or broken if you have a good reason

It's not about how much code can you fit in 100 lines, try making it readable.

There is no deadline, and everyone who submits something will be a winner.

Because I think you're all n00bs, who can't even write "Hello World" in under 100 lines ;P

Here's my 100 line Arkanoid in Java to motivate you:

package java101;

import java.awt.Color;
import java.awt.Graphics;
import java.awt.event.MouseEvent;
import java.awt.event.MouseMotionListener;
import java.util.Random;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.SwingWorker;

public class Main {
    static GamePanel panel;
    static int ball_x=13000,ball_y=15000,ball_vx=0,ball_vy=200,ball_last_x,ball_last_y,paddle_x
=130,paddle_width=64,game_state=0,points=0,lives=3;

    public static void main(String[] args) {

       JFrame window = new JFrame();
       window.setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        panel =new GamePanel();
       for (int x=0;x<10;x++ )
        for (int y=0;y<10;y++ ){
            if(x>0&&x<9&&y>0)panel.field[x][y]=new Random().nextInt();}
       window.add(panel);
       window.setSize(320, 260);
       window.setResizable(false);
       window.setVisible(true);
       window.setTitle("Arkanoid 101");
       window.addMouseMotionListener(new MouseMotionListener(){
            public void mouseDragged(MouseEvent e) {
               Main.game_state=1;}
            public void mouseMoved(MouseEvent e) {
               Main.paddle_x=e.getX()-32;
               if (Main.paddle_x<0)Main.paddle_x=0;
               if (Main.paddle_x>320-Main.paddle_width)Main.paddle_x=320-Main.paddle_width;
               Main.panel.repaint();}
        });
        SwingWorker time = new SwingWorker() {
        @Override
        protected Object doInBackground() throws Exception {
            while (true){
            if (game_state==1&&lives>0){
            ball_last_x=ball_x;
            ball_last_y=ball_y;
            ball_x+=ball_vx;
            ball_y+=ball_vy;
            if (ball_last_x/100!=ball_x/100||ball_last_y/100!=ball_y/100)Main.panel.repaint();
            if (ball_x/100-2<=0||ball_x/100+2>=310)ball_vx=-ball_vx;
            else if (ball_y/100-3<=0)ball_vy=-ball_vy;
            else if (ball_y/100+3>=200)
             if(ball_x>=paddle_x*100&&ball_x<=(paddle_x+paddle_width)*100){ball_vy=-ball_vy;
                ball_vx=(ball_x/100-paddle_x-paddle_width/2)*5;
                ball_vx=  (ball_vx<0) ? ball_vx-50 : ball_vx+50;
                ball_vy=  (ball_vx<0) ? ball_vx-50 : -ball_vx-50;
                }
                else{
                    lives--;
                    Main.game_state=0;
                    Main.ball_x=13000;
                    Main.ball_y=15000;
                Main.ball_vx=0;
                Main.ball_vy=200;}
            else if(ball_y<10000&&ball_y>300&&ball_x<31700&&ball_x>300){
                if (panel.field[ball_x/3200][(ball_y/100-3)/10]!=0)destroy_block(0,-3);
                else if (ball_y<9000&&panel.field[ball_x/3200][(ball_y/100+3)/10]!=0)destroy_block(0,3);
                else if (panel.field[(ball_x/100-2)/32][ball_y/1000]!=0)destroy_block(-2,0);
                else if (panel.field[(ball_x/100+2)/32][ball_y/1000]!=0)destroy_block(2,0);}}
            Thread.sleep(10);}
           }};
    time.run();
    }

   static void destroy_block(int x, int y){
        panel.field[(ball_x/100+x)/32][(ball_y/100+y)/10]=0;
        ball_vx=  (x!=0) ? -ball_vx : ball_vx;
        ball_vy=  (y!=0) ? -ball_vy : ball_vy;
        points+=Math.abs(ball_vx/10)+Math.abs(ball_vy/10);
    }
}

 class GamePanel extends JPanel{

     int field[][]=new int[10][10];
    @Override
   public void paintComponent(Graphics g){
        g.setColor(Color.WHITE);
         g.fillRect(0, 0, 320, 240);
        for (int x=0;x<10;x++ )
        for (int y=0;y<10;y++ ){
            g.setColor(new Color(Integer.MAX_VALUE-field[x][y]));
            g.fillRect(x*32, y*10, 32, 10);
        }
         g.setColor(Color.BLACK);
         g.fillRect(Main.paddle_x, 200, Main.paddle_width, 10);
         g.drawOval(Main.ball_x/100-2, Main.ball_y/100-2, 5, 5);
         g.drawString("Lives: "+Main.lives+" Points: "+Main.points, 0, 220);
         if (Main.game_state==0&&Main.lives>0) g.drawString("Click and drag to start", 100, 120);
         if (Main.lives==0) g.drawString("GAME OVER", 100, 120);
     }
}

Link to comment
Share on other sites

  • 11 years later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • Recently Browsing   0 members

    No registered users viewing this page.


×
×
  • Create New...