This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
libraryaddict's profile picture

CC Coding Challange - Closed due to lack of interest

Started by libraryaddict, 16 May 2012 - 08:06 AM
libraryaddict #1
Posted 16 May 2012 - 10:06 AM
This forum is full of pro elite people ready to test their skills right?
Gonna hack the government database or display "hello world!" on their screen!

Why not do this instead..

Each week I will post a objective in here.
First person to get the objective wins for the week!

There is no prize but for knowing you were a better coder that week then everyone else…

The objectives will not be 10minutes easy as that would not be as fun would it?

I am allowed to enter this :\

The winner of the last week can mail me with a request for the next week's contest.

If you know a program or API which will win you this challenge in 10seconds flat..
Try not to.

Even if you made a program already which does this.

That is not a valid entry.
This is a coding challenge and not a google challenge.


Winners will get their name in the winners list, Along with their code.

You can also publish your code as your own in a separate topic.

I do not have any right to your code :P/>/>


Post your code in this topic with
Spoilerand
 tags or use pastebin

Unless specified. You do not need to make this game multi-computer

The next round will start on Sunday and the round will always end on Sunday or when a winning entry is submitted.



Challenge of the week


Create a writing tool and a reading tool to read it.

So I could write a book and read it


Previous Winners


Create a hangman game: Cloudy - http://pastebin.com/vFifMTKf

Create a mailing system: No entries

Create a ping pong game: No entries

Create a reading and writing tool: No entries
Cloudy #2
Posted 16 May 2012 - 03:37 PM
I'll enter. Are we to post our script, or wait until the end to post? I think the latter makes more sense - otherwise people may just look at code for reference and deliberately try and beat the previous person.
BigSHinyToys #3
Posted 16 May 2012 - 05:40 PM
looking to clarify here is this for multi player same terminal or multi player different terminals if second then is direct connect from computer to computer or computer sever computer. will it need a in build dictionary is AI opponent required.
ComputerCraftFan11 #4
Posted 16 May 2012 - 06:02 PM
I'll enter.

Making one with a computer, and multiplayer (1 player types the word)
libraryaddict #5
Posted 16 May 2012 - 08:40 PM
Updated the OP.

You do not need to have the game run on 2 computers
You could have the whole game on one computer.
You post the code in this topic with the tags
Spoilerand
 to allow readability.

Also Cloudy its the first person to post with code that works
Dirkus7 #6
Posted 16 May 2012 - 09:02 PM
I'm entering too, i am working on a 2-computer version
You do not need to have the game run on 2 computers
You could have the whole game on one computer.
I started a few minutes before this was posted
Cloudy #7
Posted 16 May 2012 - 09:20 PM
Also Cloudy its the first person to post with code that works

Well in that case…

Hangman:
http://pastebin.com/vFifMTKf

Sample dictionary:
http://pastebin.com/vFTuAWPE

Put dictionaries in same folder as the hangman file, with name of blah.dict - it will ask you which to use on startup.

Does this mean I win? :P/>/>
libraryaddict #8
Posted 16 May 2012 - 09:30 PM
Also Cloudy its the first person to post with code that works

Well in that case…

Hangman:
http://pastebin.com/vFifMTKf

Sample dictionary:
http://pastebin.com/vFTuAWPE

Put dictionaries in same folder as the hangman file, with name of blah.dict - it will ask you which to use on startup.

Does this mean I win? :P/>/>

Yes you won this week!
Dirkus7 #9
Posted 16 May 2012 - 10:31 PM
Congratulations Cloudy!

I will try next week :P/>/>
PixelToast #10
Posted 17 May 2012 - 01:24 AM
i win because your argument is in valid because i have no fault because i did it right so… yea
ComputerCraftFan11 #11
Posted 17 May 2012 - 02:23 AM
If we have a rednet contest then… I'll make one easily since i made a bunch
If it's http then… D:
MathManiac #12
Posted 19 May 2012 - 04:11 AM
I'm entering :P/>/> This is going to be epic. Waiting for next week is epic. Hmm… I think I might be overusing "epic".
libraryaddict #13
Posted 20 May 2012 - 12:32 PM
Updated
dandman999 #14
Posted 20 May 2012 - 05:22 PM
Entering ;D I've got the mail bit finished (after not noticing it kept overwriting 'message' with "received", and spending an hour staring at the mail server script, when it was the client (oh, and spelling received wrong 8 times)). All I have to do now is the attachments… (But I think I might have to use the HTTP api for that…)
libraryaddict #15
Posted 21 May 2012 - 01:49 AM
Entering ;D I've got the mail bit finished (after not noticing it kept overwriting 'message' with "received", and spending an hour staring at the mail server script, when it was the client (oh, and spelling received wrong 8 times)). All I have to do now is the attachments… (But I think I might have to use the HTTP api for that…)

You can do attachments ingame, Not really sure how you could seperate it from the email itself. Perhaps a divider.

For example.

This is one I made

function sendFile(filename, ID) -- Opens a file and sends it as a single string
  if fs.exists(filename) then
    local fp = io.open( filename, "r" )
    local content = ""
    for line in fp:lines() do
	  content = content..line.."n"
    end
    fp:close()
    rednet.send(ID, content)
  else  
    error("Need to define a file name which exists")
  end
end

function writeFile(line, filename) -- Receives a string and writes it into a file. Best with sendFile
  local fp = io.open( filename, "w" )
  fp:write(line)
  fp:close()
end
MathManiac #16
Posted 21 May 2012 - 02:15 AM
And it's due in a week? I need more experience.
gmt2001 #17
Posted 21 May 2012 - 11:39 PM
To do the attachments in-game simply make a protocol for sending length-defined strings as part of the e-mail message. This would even allow having multiple attachments. Here is an example of what an entire e-mail transmission might look like


--EMAIL
To: user01@mail.24.cc
From: user02@mail.24.cc
Subject: A letter
Here is that letter i promised you
--ATTACHMENT
Filename: letter01.txt
Length: 44
Dear sir,
have a nice day
sincerely,
user02
Here the to and from addresses are the account-name@mail.mail-server-id.cc where mail-server-id is the numerical id of the mail server computer from os.getComputerId()
Attachments are marked by the –ATTACHMENT line and you include the exact length of the contents of the attachment, including CR/LF before the body. By reading that exact number of characters you have the attachments contents. Using this you can define multiple attachments in succession. The only thing that is missing from the example is a way to ensure no-one can mess up the parsing of the message by including the key words in the e-mail addresses, subject, or message body. The attachments do not pose this threat since you have the length identifier to use for parsing them. To prevent e-mail addresses from causing a problem you can simply make having any character other than a-z, 0-9, dash, (-) and underscore (_) not allowed and then block anyone from using –ATTACHMENT as an email address or have the parser know it cant be an attachment sincce you havent gotten to the body yet. For the subject and body you could replace certain characters like the dash (-) and colon ( : ) with html codes. Thus if you had a message like this

--EMAIL
To: user01@mail.24.cc
From: user02@mail.24.cc
Subject: A letter
Dear sir:
Here is that letter i promised you
--ATTACHMENT
Filename: letter01.txt
Length: 44
Dear sir,
have a nice day
sincerely,
user02

It could be transmitted like this

--EMAIL
To: user01@mail.24.cc
From: user02@mail.24.cc
Subject: A letter
Dear sir:
Here is that letter i promised you
--ATTACHMENT
Filename: letter01.txt
Length: 44
Dear sir,
have a nice day
sincerely,
user02

By replacing colons and dashes with the html code the person cant accidentally or intentionally mess with the parsing of the keywords for each section as the decoding of the html codes back into their origional characters would be done after you seperated the message into its parts. Again you would only do this replacing in the subject and body while e-mail addresses would simply make the keywords illegal and the attachments would be covered by the use of the sent length.
ComputerCraftFan11 #18
Posted 22 May 2012 - 02:00 AM
I made one but I don't feel like posting it here… I'll do it next week :P/>/>
Pinkishu #19
Posted 26 May 2012 - 09:40 PM
Hmm when does this week end? this sunday, right? so tomorrow?
libraryaddict #20
Posted 27 May 2012 - 03:19 AM
Ends in about 7 hours
Pinkishu #21
Posted 27 May 2012 - 03:43 PM
2 computers meaning? each player sits at their own pc?
libraryaddict #22
Posted 28 May 2012 - 07:09 AM
Yep

Don't really want someone to control your paddle do you?
libraryaddict #23
Posted 03 June 2012 - 02:17 PM
Come on guys!
This next one should be pretty easy to knock up!
Pinkishu #24
Posted 03 June 2012 - 02:26 PM
Lol I don't get it… isn't that like a text editor? :)/>/>
kazagistar #25
Posted 03 June 2012 - 03:44 PM
I recommend you leave older weeks open. Make it less of a competition, and more like Project Euler, where you can grab a challenge and see how many you want to complete.

Also, yeah, the newest one seems silly. How does this differ from "edit"?
libraryaddict #26
Posted 03 June 2012 - 08:29 PM
I recommend you leave older weeks open. Make it less of a competition, and more like Project Euler, where you can grab a challenge and see how many you want to complete.

Also, yeah, the newest one seems silly. How does this differ from "edit"?

It would be pretty similar, I agree. But I do think it would be different as the one writing the story may want to keep his formatting, automatic word wrapping would be there too I imagine.

As no one entered the last 2 weeks I thought I might as well do a easy one for this week.
Pinkishu #27
Posted 04 June 2012 - 01:51 AM
So not sure if i'll finish this one - its a ton of work :)/>/> I just wrote 144 lines to print a single word..