August 21, 2019, 11:23:34 pm

News:

The account sign-up bug has been fixed.



Alternatively, join us on Discord.

Tweetjam

Started by Juju, July 18, 2016, 11:37:37 pm

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Juju

July 18, 2016, 11:37:37 pm Last Edit: July 18, 2016, 11:42:08 pm by Juju
Post your best code here. Only requirement: the code must fit on a tweet. 140 characters or less.

No deadline, no winner, multiple participations allowed, must be a full program written by you. Use the [code] tag to put your code in and specify the language and what it does. You might even use the karma buttons to vote on the entries, if you want, and even improve on other entries. Have fun.
Read Zarmina!
YUKI-CHAAAANNNN
In the beginning there was walrii. In the end there will be walrii. All hail our supreme leader :walrii: --Snektron



if you wanna throw money at me and/or CodeWalrus monthly it's here

DJ Omnimaga

That seems interesting. I think this was done before elsewhere but I forgot where. Maybe it was one of the Cwick contests or something. What are the platform restrictions?

Now I wonder if a full game can be coded under 140 characters of code...

Juju

Pretty sure we had a bunch of contests with that restriction. but this time, it's the only one. (That and the usual code golf and common sense rules.) No platform restriction. It was done on the Lexaloffle BBS for PICO-8 carts too, for the record.
Read Zarmina!
YUKI-CHAAAANNNN
In the beginning there was walrii. In the end there will be walrii. All hail our supreme leader :walrii: --Snektron



if you wanna throw money at me and/or CodeWalrus monthly it's here

DJ Omnimaga

Aah thanks for explaining. I wasn't sure anymore.

calcplays

The Oregon Trail for Python 2.7

l=[" "]
while l[-1]!="":
    l+=[raw_input("Name: ")]
raw_input("You depart!")
for j in l[1:-1]:
    raw_input(j+" has dysentery.")

Directions: You and your wagon party are about to venture across the frontier to build a new life in the Wild West.
Enter in the names of your party members and advance with an empty name.
Then, carefully traverse and survive in your journey across the United States. Press enter to advance.

Juju

July 20, 2016, 03:57:18 am #5 Last Edit: July 20, 2016, 04:47:50 am by Juju
Code (woooo.rb) Select
s=IO.new(3,"w")rescue File.open(File::NULL,"w")
print"w"
8.times{print"oo"
188.times{(0..255).each{|i|s.print i.chr}}}
puts


Fits on a tweet exactly. (That's a bonus in this thread.) It's in Ruby, save it as woooo.rb, run it like this:

Code (Linux) Select
ruby woooo.rb 3> >(aplay -q -r48000 -)
Code (macOS) Select
brew install sox
ruby woooo.rb 3> >(play -q -c 2 -b 8 -e unsigned -t raw -r 48k -)

Code (Windows) Select
¯\_(ツ)_/¯

Enjoy a 8-second sawtooth tone while the terminal seems happy. Bonus: remove the poor excuse of a reversed heart that is 3> and everything after (which should be the command you use to play raw sound from stdin) and it goes silent. Wrote this to demonstrate outputting text and sound to stdout at the same time, isn't that great? Could have used stderr as well (which would be 2> instead of 3>, but if you omit 2> and everything after it would output garbage in the terminal instead of doing nothing), but I wanted to demonstrate the use of file descriptor numbers greater than 2.

EDIT:
Code (bash) Select
curl -s https://mobile.twitter.com/juju2143/status/755613582776229888|xmllint --xpath '//div[@data-id="755613582776229888"]/div' --html -|sed 's/<[^>]*>//g'|ruby 3> >(aplay -q -r48000 -)

Run this on your Linux terminal, it downloads the above code from Twitter and runs it. That line also fits exactly in a tweet.
Read Zarmina!
YUKI-CHAAAANNNN
In the beginning there was walrii. In the end there will be walrii. All hail our supreme leader :walrii: --Snektron



if you wanna throw money at me and/or CodeWalrus monthly it's here

DJ Omnimaga

July 20, 2016, 05:41:42 am #6 Last Edit: July 20, 2016, 05:59:34 am by DJ Omnimaga
Here's a TI-BASIC game. Exactly 140 characters large (or 99 bytes on-calc with the program name)

AxesOff
ZTrig
For(Z,0,9³
randInt(⁻8,8→A
Line(A,2,A+1,2
For(θ,Z²,9³
End
Line(A,2,A+1,2,20
Input
If A≠int(X
Then
Disp "PTS:",Z
Return
End
End




Basically you have to memorize where the line appears then click at the matching X position. Yay for the Input command with no argument. :P I attached the file below for those who wants to try it.

JWinslow23

July 20, 2016, 07:52:21 am #7 Last Edit: July 20, 2016, 07:56:36 am by JWinslow23
My entry is in TI-BASIC. With the program name "T" (for Tweetjam :P ), this is exactly 140 bytes on-calc, and it works on both color and mono calcs.

It's a Stacker-type game.

The pieces move rapidly back and forth. Press 2nd to stack your pieces.

Land your pieces not on the stack, and you lose one piece. Lose all your pieces and it's game over. Get to the top and you win.



ClrHome
DelVar A8→H
5→L
While H and Ans
A+1
Ans-2Ans(Ans+L=13→A
1+abs(Ans
Output(H,Ans," "+sub("*****",1,L)+" 
If getKey=21
Then
If H=8 or Ans<B+M and Ans>B-L
Then
Ans→B
H-1→H
L→M
Else
L-1→L
End
End
End
If Ans
Disp "W

I suppose I went a bit overboard with the game choice, but that's me trying to fit an actual game into 140 bytes! :D

DJ Omnimaga

Nice, but doesn't tweetjam count 140 as individual characters rather than tokens? Because in this case your code is 218 characters (for example, Output( is 7 characters). ???


DJ Omnimaga

Maybe there is a way. :P good job nonetheless, though. I wonder if an RPG can be done under 1 KB of code...

c4ooo

Quote from: JWinslow23 on July 20, 2016, 01:28:47 pm
Oh, this is strictly CHARACTERS?

That changes everything. I'll get to remaking a game.

Just open the program in a hex editor and convert it to base 256, that way your program will still fit into a tweet ;)

Juju

The goal is to fit the code on one tweet on Twitter, so of course it's 140 characters. Unless you manage to post it tokenized on Twitter, that is. That gives me an idea.
Read Zarmina!
YUKI-CHAAAANNNN
In the beginning there was walrii. In the end there will be walrii. All hail our supreme leader :walrii: --Snektron



if you wanna throw money at me and/or CodeWalrus monthly it's here

c4ooo

Twitter counts characters as bytes so I estimate you would be able to get over 250 bytes in a tweet. (Not all combinations of bits are valid UTF characters)
And then of course you can tweet an image (containg your code in a PNG format), which will allow you even more bytes, but that's probly cheating :P

Juju

Quote from: c4ooo on July 20, 2016, 08:07:26 pm
And then of course you can tweet an image (containg your code in a PNG format), which will allow you even more bytes, but that's probly cheating :P
That probably wouldn't work if Twitter do some sort of conversion after uploading the image. I'm not sure, but Facebook definitely does it.
Read Zarmina!
YUKI-CHAAAANNNN
In the beginning there was walrii. In the end there will be walrii. All hail our supreme leader :walrii: --Snektron



if you wanna throw money at me and/or CodeWalrus monthly it's here

Powered by EzPortal