Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Java Homework

Name: Anonymous 2007-04-09 13:17 ID:HpLdMw06

Ok /prog/, this is very simple.

You're going to do my programming homework. Because want you to.

This is very simple... Work + No Spare Time = No Homework Done

So here's the deal: I supply to you my Java Homeworks and you'll do it.
If you're unable to do it, feel free to post whatever you like.
If you're a fucking coding god, you will post your ultimate solution, and face the criticism from other coding gods, including moot.

Cruel Leonidas demanded that you stand. I require only that you kneel.

Name: Anonymous 2007-04-09 13:27 ID:nDUlYiO3

This is madness. (Or Java, whichever word you prefer)

Besides, my dick is so long, I have a cramp in my upper leg. I can't kneel for you.

Name: Anonymous 2007-04-09 13:53 ID:fXVbnq6z

We will do your Java homework IN HASKELL.

Name: Anonymous 2007-04-09 14:47 ID:NUcXnUpj

And Python!

Name: Anonymous 2007-04-09 16:16 ID:HpLdMw06

>>3
>>4

It has something to do with outputs in the console.
I'll translate the shit after my dinner at Chez Enfer, with 300 hot chicks.

Name: Anonymous 2007-04-09 16:51 ID:Heaven

>>5
System.out.print(shit);

Name: Anonymous 2007-04-09 17:47 ID:8q50gCgB

>>5

If you're eating dinner out, and not ordering pizza in, you'll never be a programmer.  Sacrifice your social life now, or be condemned to a career filled with VB6 and legacy code.

Name: Anonymous 2007-04-09 18:47 ID:/1w4xrfa

I will do your programming homework.

I am a coding god.

It will be done.

Name: Anonymous 2007-04-09 19:41 ID:HpLdMw06

>>7
We have a programming class here that is mandatory to every course. I'm not going to be a programmer.

Name: Anonymous 2007-04-09 19:53 ID:N/BlYyRO

>>1
he didnt even post any homework
I was going to do it to troll people

Name: Anonymous 2007-04-09 20:08 ID:HpLdMw06

>>8

Here it is, then, mister god:

-- You have to write a Java program that draws numbers in the computer screen, old calculator LED style. Counsider a screen with infinite lines and a max of 80 columns.

-- Input data:
The input file of this program contains several lines, one for each number being shown in the screen.
Each line has 2 integer numbers: S (where S is (1 <= S <= 10)) and N (where N is (0 <= N)). N is the number that will be written in the screen. S is the size of the characters.

-- Output data:
The screen prints (LED style ) the numbers in the file, using S symbols "-" for the horizontal segments and S "|" for the vertical segments. Each numerical digit ocupies exactly S+2 columns and 2S+3 lines.

The program must assure that all whitespaces of each numerical digit (the spaces that don't have "|" or "-"“, have the proper " " (space).

Between do consecutive numerical digits of a same number should exist a column of spaces. If there's 2 numbers in a row that are the same, they must be separeted with a space.

EXAMPLE:

2 12345
3 67890
4 0012345678901234
A saída será:
      --   --        --
   |    |    | |  | |  
   |    |    | |  | |  
      --   --   --   --
   | |       |    |    |
   | |       |    |    |
      --   --        --

 ---   ---   ---   ---   ---
|         | |   | |   | |   |
|         | |   | |   | |   |
|         | |   | |   | |   |
 ---         ---   ---      
|   |     | |   |     | |   |
|   |     | |   |     | |   |
|   |     | |   |     | |   |
 ---         ---   ---   ---

 ----   ----          ----   ----          ----   ----   ----   ----   ----    
|    | |    |      |      |      | |    | |      |           | |    | |    |   
|    | |    |      |      |      | |    | |      |           | |    | |    |   
|    | |    |      |      |      | |    | |      |           | |    | |    |   
|    | |    |      |      |      | |    | |      |           | |    | |    |   
                      ----   ----   ----   ----   ----          ----   ----    
|    | |    |      | |           |      |      | |    |      | |    |      |   
|    | |    |      | |           |      |      | |    |      | |    |      |   
|    | |    |      | |           |      |      | |    |      | |    |      |   
|    | |    |      | |           |      |      | |    |      | |    |      |   
 ----   ----          ----   ----          ----   ----          ----   ----    

 ----          ----   ----                                                     
|    |      |      |      | |    |                                             
|    |      |      |      | |    |                                             
|    |      |      |      | |    |                                             
|    |      |      |      | |    |                                             
               ----   ----   ----                                              
|    |      | |           |      |                                             
|    |      | |           |      |                                             
|    |      | |           |      |                                             
|    |      | |           |      |                                             
 ----          ----   ----        



Welcome to India!

Name: Anonymous 2007-04-09 21:03 ID:kH/CbOmx

>>3

Or Prolog, or Scheme.  Just not a worthless mindfuck like Java.

4chan /prog/.  Helpful as ever.

Name: Anonymous 2007-04-09 21:21 ID:ehFLAFbU

$120/hr for programming training.

Name: Anonymous 2007-04-09 21:27 ID:HpLdMw06

>>11

That's what happens when you don't eat beef. Morons.

Name: Anonymous 2007-04-09 22:00 ID:QxMUFpnv

>>11
Your homework is from that shitty codegolf.com page?

Name: Anonymous 2007-04-10 3:09 ID:oF3ehT5j

>>12
Fuck Scheme. 

No seriously, I fucking hate Scheme.

Name: Anonymous 2007-04-10 3:44 ID:bQtu3QZF

As promised, here's your homework:

module Main where

import Char (digitToInt)
import Data.List (intersperse, transpose)
import System.IO

import Prelude hiding (Left, Right)

data Position = Left | Right | Both
data Digit = Digit Bool Position Bool Position Bool

digit :: Int -> Digit
digit 0 = Digit True  Both  False Both  True
digit 1 = Digit False Right False Right False
digit 2 = Digit True  Right True  Left  True
digit 3 = Digit True  Right True  Right True
digit 4 = Digit False Both  True  Right False
digit 5 = Digit True  Left  True  Right True
digit 6 = Digit True  Left  True  Both  True
digit 7 = Digit True  Right False Right False
digit 8 = Digit True  Both  True  Both  True
digit 9 = Digit True  Both  True  Right True

horiz :: Int -> Bool -> [String]
horiz n False = [replicate n ' ']
horiz n True  = [replicate n '-']

vert :: Int -> Position -> [String]
vert n pos = replicate n $ vert' n pos

vert' n Left  = "|" ++ replicate (n-1) ' '
vert' n Right =        replicate (n-1) ' ' ++ "|"
vert' n Both  = "|" ++ replicate (n-2) ' ' ++ "|"

showDigit :: Int -> Digit -> [String]
showDigit n (Digit t u m l b) =
    hor t ++ ver u ++ hor m ++ ver l ++ hor b
    where hor = horiz n
          ver = vert n

showDigits :: Int -> [Int] -> String
showDigits n = concat .
               map ((++ "\n") . concat . intersperse " ") .
               transpose . map (showDigit n . digit)

mongleLine :: String -> String
mongleLine (n:' ':digits) = showDigits
                            (digitToInt n)
                            (map digitToInt digits)
mongleLine x = ""

main :: IO ()
main = getContents >>= mapM_ (putStr . mongleLine) . lines


>>16
What does this have to do with the topic? Or is this just your way to say "I've read SICP"?

Name: Anonymous 2007-04-10 5:27 ID:Hy49oqDy

>>17
Needs more $.

Name: Anonymous 2007-04-10 5:41 ID:bQtu3QZF

>>18
Sorry, I'm broke. I could barely afford the one $.

Name: Anonymous 2007-04-10 6:00 ID:V9G9BCuJ

>>14 kuttiya

>>15
Nope. My teacher often steals these from european universities or he makes them, when he's in a good mood.
There's no Java coding gods in here?

Name: Anonymous 2007-04-10 6:36 ID:qIQdBsAH

>>20
coding gods does not do Java

Name: Anonymous 2007-04-10 6:51 ID:d1pXCURF

I would do this but I have a shitload of homework.

I'll give you a hint: Queues.

Name: Anonymous 2007-04-10 7:21 ID:dMc4lajH

>>17
Coding god

>>21
Truth

Name: Anonymous 2007-04-10 8:33 ID:V9G9BCuJ

Name: Anonymous 2007-04-10 11:30 ID:bQtu3QZF

HOW DOES CODING GODS KNOW WHAT JAVA IS?

Name: Anonymous 2007-04-10 12:22 ID:dMc4lajH

Because god knows the devil

Name: Anonymous 2007-04-10 14:06 ID:RIw09X2R

WWWHHHHYYYYYYYYYY ARENTT YOU GUUUUUUUYS DDDDOOOOOING MY HOOOOOOMEWOOOOOOORDKK!~!@~~~

Name: Anonymous 2007-04-10 15:14 ID:zFywYjEm

DO IT IN C, CODE GODS! ENLIGHT OUR SOULS WITH THE FIRST LANGUAGE!

Name: Anonymous 2007-04-10 15:42 ID:AXCZaZK3

>>17
What kind of asshole using the dot operator with a space on each side?

You . Dumb

Name: Anonymous 2007-04-10 15:45 ID:1t3kJ6mu

>>29
If you don't put spaces it looks similar to using a function from an external module using its fully qualified name.

Name: Anonymous 2007-04-10 16:00 ID:Heaven

>>29
What kind of asshole using the pipe operator with a space on each side?

You | Dumb


What kind of asshole using the concatenation operator with a space on each side?

You ++ Dumb

What kind of asshole using the dollar sign operator with a space on each side?

You $ Dumb



What kind of asshole using the equals operator with a space on each side?

You = Dumb

Name: Anonymous 2007-04-10 16:29 ID:kbihfNmm

>>28
I did something similar to the OP's homework for a micro processor a few years back. How do I found old project?

Name: Anonymous 2007-04-10 16:46 ID:AXCZaZK3

wow..... I just realized the code posted is in Haskell.

I'm slow.

Name: Anonymous 2007-04-10 16:56 ID:Heaven

>>33
The most epic failure in the history of /prog/.

Name: Anonymous 2007-04-10 16:58 ID:AXCZaZK3

>>34
Sad part is I know Haskell.

It's been awhile.

Name: Anonymous 2007-04-10 18:17 ID:SVF9Hm6x

>>31
What kind of fucking idiot posts shit like this on /prog/ ?

Name: Anonymous 2007-04-10 18:21 ID:Heaven

>>17
What kind of fucking idiot posts shit like this on /prog/ ?

Name: Anonymous 2007-04-10 21:57 ID:Heaven

>>33
sup slowpoke

Name: Anonymous 2007-04-11 7:57 ID:vvxwPClh

NEEDS MORE ANSWERS

Name: Anonymous 2007-04-11 9:59 ID:iVmnI21Z

Run it with a filename as the command line argument.
import java.io.*;
import java.util.*;
public class YourHomework {
    private static final boolean flags[][]={
        {true,true,true,false,true,true,true},
        {false,false,true,false,false,true,false},
        {true,false,true,true,true,false,true},
        {true,false,true,true,false,true,true},
        {false,true,true,true,false,true,false},
        {true,true,false,true,false,true,true},
        {true,true,false,true,true,true,true},
        {true,false,true,false,false,true,false},
        {true,true,true,true,true,true,true},
        {true,true,true,true,false,true,true}
    };
    private static void printDigitLine(int n,int size,int line) {
        char l=' ',c=' ',r=' ';
        if (line==0) {
            if (flags[n][0]) c='-';
        } else if (line<=size) {
            if (flags[n][1]) l='|';
            if (flags[n][2]) r='|';
        } else if (line==size+1) {
            if (flags[n][3]) c='-';
        } else if (line<=2*size+1) {
            if (flags[n][4]) l='|';
            if (flags[n][5]) r='|';
        } else if (flags[n][6]) c='-';
        System.out.print(l);
        for (int i=0;i<size;i++) System.out.print(c);
        System.out.print(r);
    }
    public static void main(String args[]) {
        if (args.length==0) {
            System.out.println("must be run with a filename argument");
            return;
        }
        try {
            BufferedReader in=new BufferedReader(new FileReader(args[0]));
            String l;
            StringTokenizer t;
            int size;
            String digits;
            int maxperline;
            int lines;
            int bound;
            while ((l=in.readLine())!=null) {
                t=new StringTokenizer(l);
                size=Integer.parseInt(t.nextToken());
                digits=t.nextToken();
                maxperline=81/(size+3);
                lines=digits.length()/maxperline+1;
                for (int i=0;i<lines;i++) {
                    for (int j=0;j<2*size+3;j++) {
                        bound=Math.min(digits.length(),(i+1)*maxperline);
                        for (int k=i*maxperline;k<bound;k++) {
                            printDigitLine(digits.charAt(k)-'0',size,j);
                            if (k<bound-1) System.out.print(' ');
                        }
                        System.out.print('\n');
                    }
                    System.out.print('\n');
                }
            }
        } catch (Exception e) {
            System.out.println(e.getMessage());
        }
    }
}

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List