r/codegolf • • Jul 21 '20

A 256byte ZXSpectrum intro in Z80 assembler. Created in 10 days from scratch

8 Upvotes

Straight from the demoscene: https://www.pouet.net/prod.php?which=86340

Winner of the Flashparty 2020 256 byte retro intro competition.

Earlier this month, i gave myself a 10 day challenge to learn Z80 assembler and see if i could create a 256 byte intro for the ZX Spectrum. I must admit it was quite intense to learn a new assembler language from scratch at my age, but as you can see it is quite doable if you put your mind to it. While not as elaborate as our MS-DOS tiny intros, I am still quite pleased with the result given my prior experience level with Z80. It contains 4 different effects, 4 different colorschemes and AY sound.

For those interested: You can find out our other 256 byte productions (For MS-DOS mostly) at: https://www.pouet.net/groups.php?which=14389


r/codegolf • • Jun 14 '20

Haiku - Visual Poetry in 256 bytes

8 Upvotes

A 256 byte intro by Marquee Design, Straight from the Demoscene (@ party 2020)

https://www.pouet.net/prod.php?which=85866


r/codegolf • • May 15 '20

How uch shorter can this JS "disease simulator" get?

8 Upvotes

This was formerly a test for class we had 2 hours to work on. Me and a friend joked about giving our solution to the Prof as short as possible....... We did not but afterwards I worked on this and this is how short I can do: (815 789 771 745 713 694 (thx @pie3636) characters)

q=Array,g=Math.random,C=console,s=C.log,L="length",a=(e,t)=>[...q(t)].map(()=>[...q(e)].map(()=>".")),b=e=>(e[0|g()*e[L]][0|g()*e[0][L]]="X",e),c=(e,t,r=[])=>(e.map((x,l)=>{x.map((y,o)=>{if("X"==y){for(a=l-1;a<=l+1;a++)for(h=o-1;h<=o+1;h++)0<=a&&a<e[L]&&0<=h&&h<e[0][L]&&(a^l||h^o)&&"."==e[a][h]&&g()<t&&r.push([a,h]);e[l][o]="O"}})}),r.map(t=>e[t[0]][t[1]]="X"),e),d=(e,t,r=0,a=0,l=0,o="=".repeat(2*e[0][L]))=>{s(`= Day ${t} ${o.slice(0,o[L]-(8+t.toString()[L]))}`),e.map(e=>{t="";e.map(e=>{t+=e+" ","."==e?r++:"X"==e?a++:l++}),s(t)}),s(`Healthy: ${r}\nSick: ${a}\nRecovered: ${l}`)},e=31,p=.3,m=a(20,20);m=b(m);i=1,t=setInterval(()=>{i==e&&clearInterval(t),C.clear(),m=c(m,p),d(m,i),i++},100)

But I'm very interested in how much shorter it still can get..

Note: the parameters in the end (e, p, m) shall still be changable from "outside".

Here is my original TypeScript file for better understanding of the code.

Edit: cut it down to 789 771 745 713 694


r/codegolf • • May 17 '19

A Flappy Bird demake with entire HTML file and javascript code in less than a tweet!

Thumbnail
killedbyapixel.itch.io
8 Upvotes

r/codegolf • • Mar 29 '19

Awesome trio of 1k javascript programs I made for js1k

8 Upvotes

Hi, everyone, I've been making games for about 20 years but just recently got into js code golf. Lucky it was just in time to enter js1k. Being unemployed, I'm working like a madman to produce as much as I can. Over the past like 2 weeks I've already made 3 of the best programs of my career, all under 1k of javascript. I'd love to talk more about it, or if you can find some extra space saving I missed, it's not to late for me to make changes! Also I'm going to try to crank out 1 more game today and tomorrow, wish me luck!

"Queen's Gambit" - Robotrom meets chess.

"ZzFX" - Sound effect generator. (just submitted yesterday, official submission pending)

"The Digit Dilemma" - Sukoban meets 1024 puzzle game

"Infinite Yin Yangs" - A recursive yin yang lava lamp

And an extra bonus, my 1 tweet spiral machine for ShaderToy...

define S(v)step(.5,fract(vat))

define mainImage(c,p)vec2 r=iResolution.xy,u=99.(p.xy-r/2.)/r.x;float P=6.28,t=.01iTime,A=atan(u.y,u.x),a=A+Pfloor(length(u)-A/P+.5),s=S(.5),v=S(1.);c=vec4(v-sv*.5)+vec4(sv)cos(P(.002a+t+vec4(1.,.6,.3,1.)));


r/codegolf • • Mar 19 '19

rgb to hex, JS, 64 chars

8 Upvotes
 rh=(r,g,b)=>'#'+((1<<24)+(r<<16)+(g<<8)+b).toString(16).slice(1)

r/codegolf • • Dec 29 '17

Is this the smallest possible Midi file?

8 Upvotes

So recently I've wondered what the absolutely smallest midi file is as long as it has to play a note. This is what I propose:

4d54 6864           # MThd header
0000 0006           # Length
0001                # Format
0001                # Number of track chunks
0001                # Ticks per Crotchet

4d54 726b           # MTrk
0000 000c           # Length

Delta | Event
00    | 90 4850     # Play C5 at velocity 80
01    |    4800     # Note Off
01    | ff 2f00     # End of track

I've already tried removing the Note Off and just using the end of track but it didn't work for whatever reason. I did make sure to edit the length of the chunk so that's not it.

Can anyone propose a smaller file?


r/codegolf • • Apr 11 '17

Can you make this Markov chain Python code shorter than 25 lines?

8 Upvotes

This was an old assignment I did a year or so back. Figured it might be neat to see how short you can get this Python code.

Here's the code:

Non-commented version with no spacing: https://pastebin.com/qc2yFpxH

Fully commented version: https://pastebin.com/0acCBW2g

Essentially it's a basic markov chain. Here are the requirements:

https://imgur.com/a/SbxqF


r/codegolf • • Jun 16 '26

Some ~100 line games

7 Upvotes

As an exercise in focus and economy I wanted to make a set of games with short but (hopefully) readable source code.

It was a fun challenge and taught me a lot. I hope the results will be of interest or amusement to others.

There are five games in total. There's also a manifesto about doing this kind of project for those who like that sort of thing.

Part of the challenge is actually releasing things and accepting feedback so I'd be grateful for any opinions you have to offer, whether critical or complimentary.

If you've written a deliberately short game too then please link to it, I'm interested to see what can be done.


r/codegolf • • Nov 13 '24

Python fizzbuzz in 63 bytes

7 Upvotes
for n in range(101):print(("fizz"*(n%3<1)+"buzz"*(n%5<1)) or n)

EDIT:

Now down to 60:

for n in range(101):print("fizz"*(n%3<1)+"buzz"*(n%5<1)or n)

r/codegolf • • Feb 21 '24

My first code golf (I then took time to explain to him how it worked)

7 Upvotes

r/codegolf • • Feb 01 '24

Any program in one line of python

7 Upvotes

Hello team. I think I can prove that any program at any level of complexity can be written in one line of python code. For example, here is advent of code day 7 problem 1:

with open("problem.txt", "r") as tf:(lambda fi, pd: (lambda m, sf2, lf, f: print(sum([int(x.split()[1]) * (i + 1) for i, x in enumerate(sorted(tf.read().split("\n"), key=lambda ct: sf2([int(x) if x.isnumeric() else m[x] for x in ct.split()[0]], f(lf(ct.split()[0])))))])))({"A": 14, "K": 13, "Q": 12, "J": 11, "T": 10}, (lambda h1, hp1: int(fi(hp1) + fi(h1))), (lambda t: [i for i in range(1, len(t) + 1) if (sorted(t) + ["z"])[i] != (sorted(t) + ["z"])[i - 1]]), (lambda tu: pd(sorted([x if i == 0 else x - tu[i - 1] for i, x in enumerate(tu)], reverse=True)))))((lambda ns: "".join([f"{n:02d}" for n in ns])),(lambda n: n + ([0] * (5 - len(n)))))

I actually wrote an article on my personal website to show how any program can be written in one line of python. I'd love for you to read it if it sounds interesting to you!

https://rebug.dev/post/TWCPgeW6ILJOa2WdR3U4

What do you think? Is my conjecture proven?


r/codegolf • • Feb 05 '21

Lovebyte: Where size matters. Demoparty celebrating sizecoding/codegolfing on March 12-14 , 2021

7 Upvotes

Join us in a celebration of the smallest with a dedicated sizecoding demoparty/event, held on the weekend of 12-14th march 2021 on Discord and Twitch We'll be online streaming with intro competitions in different size categories from the smallest to the even smaller. From 256 pixel graphics and nanogame competitions to bytebeat music competition. Or what about cool size-coded related seminars to get you started, Roundtable, DJ Sets and many other events? This is the one event where size does matter! Don't miss it!
- Lovebyte. Where size matters...

More info at: http://www.lovebyte.party

Competitions:
- Combined 32 byte intro competition
- Combined 64 byte intro competition
- Low-End 128 byte intro competition (Atari, Commodore, Spectrum,etc.)
- Hi-End 128 byte intro competition (DOS, ARM, Tic-80, Javascript)
- Low-End 256 byte intro competition Atari, Commodore, Spectrum,etc.)
- VM 256 byte intro competition (Tic-80 , Javascript)
- Hi-End 256 byte intro competition (DOS, ARM)
- Nanogame 256 byte game competition
- 256 Pixel Graphics competition
- Bytebeat music competition

Byte-Athlon For those competing in multiple of the size coding competitions, we will have a special multi-category Byte-athlon event. Where we will determine who is the most skilled across all size categories: 32byte, 64byte, 128byte and 256byte. An award ceremony will be held at Revision 2021, where the Winners will receive a special byteathlon award as well as additional prizes. Anyone can join the Byte-Athlon by submitting a prod in all categories: 32byte, 64byte, 128byte and 256 byte (lowend, highend or virtualmachine)
Events
- Compo Preshows
- 8 byte and 16 byte intro showcase (all new releases)
- Best of tiny intros playlists
- Sizecoding Roundtables
- Demoscene Skribbl.io sessions
- Sizecoding Showdown (*tbd)
- DJ Sets
- And much more...

So join us online or even better send in your entries to our partysystem!
Contact us on discord (see website for link) or via email for your vote/registration key.


r/codegolf • • May 30 '20

Microdose - A 128 byte MS-DOS demo with 8 different effects, custom color palette and sound

7 Upvotes

Straight from the demoscene, Winner of the Outline online 2020 128-byte intro competition. https://www.pouet.net/prod.php?which=85677 (sourcecode included)


r/codegolf • • Jan 20 '19

My attempt on codegolf fizzbuzz problem in Python. Do provide criticism, comments and suggestions to make the code better.

Thumbnail
youtu.be
7 Upvotes

r/codegolf • • Dec 05 '18

Dweets explained: I wrote a three-part series on what a dweet is and how it works

7 Upvotes

I wrote a three-part series on what a dweet is and how it works and thought about sharing it here. For those of you into code golfing and Javascript, I invite you check it out:

https://luciopaiva.com/dweets/pt1/

I intend to write more parts as soon as I find more time to dissect other dweets. Lots of cool techniques to learn from... amazing code artists there :-)


r/codegolf • • Feb 26 '17

Ohm - a new golfing language inspired by 05AB1E and Jelly

Thumbnail
github.com
7 Upvotes

r/codegolf • • Mar 14 '16

Beautiful music from a tiny bit of code.

7 Upvotes

This code is not my own but it needs to be shared. It's written as a Linux command.You can see the code here there's also a great video about it here


r/codegolf • • Jan 25 '16

[challange][any] print every friday in 2014

7 Upvotes

format should be D.M.YYYY
(so 03.01.2014 is okay, so is 3.1.2014)


r/codegolf • • Jan 22 '14

xkcd: Regex Golf

Thumbnail
xkcd.com
7 Upvotes

r/codegolf • • Nov 24 '13

[perl] Grok a dictionary to find the word with the largest number of i's.

7 Upvotes

I'll start. No tricks yet.

$ perl -ne '@x=/i/g;if(@x>$max){$max=@x;$w=$_};END{print"$max $w"}' /usr/share/dict/words
6 indivisibility

Counting only the command in '', that's 55.


r/codegolf • • Jan 16 '26

ShaderGolf: extremely minimal way to draw programmatically

6 Upvotes

ShaderGolf is a programming/drawing challenge where there is a canvas scanned top to bottom, uses 16 colors, there are 2 variables called c (color) and t (time), and there is a program called 'shader' that executes when each pixel is scanned, and the program is just literally a single expression. the t variables increments after each pixel is scanned.c is 0 per pixel by default. Here are some example patterns:

Line: 15 - !(t % 257) * 15

Colored stars: 15 - !(t % 46) * (15 - t % 16)

Colored circles: t * (t >> 7) >> 3

Try at: http://eymenwinneryt.42web.io/shg.htm


r/codegolf • • Dec 04 '25

Advent of Code: Day 4

6 Upvotes

Post your golfs.

Here are mine (Python):

Part 1 (183 bytes)

b=[[0]+[c>'.'for c in l]for l in open('input.txt')]
w=len(b[0])
t=[[0]*w]
print(sum(v[i+1]&(sum((t+b+t)[j+x//3][i+x%3]for x in range(9))<5)for j,v in enumerate(b)for i in range(w-2)))

Part 2 (242 bytes)

b=[[0]+[c>'.'for c in l]for l in open('input.txt')]
s=w=len(b[0])
t=[[0]*w]
o=sum(sum(b,[]))
while s!=b:s=b;b=[[0,*((sum((t+b+t)[j+x//3][i+x%3]for x in range(9))>4)*v[i+1]for i in range(w-2)),0]for j,v in enumerate(b)]
print(o-sum(sum(b,[])))

r/codegolf • • Apr 30 '25

Minecraft like landscape in less than a tweet

Thumbnail
pouet.net
6 Upvotes