7 ms·
10 PRINT CHR$(205.5+RND(1)); : GOTO 10 (2012)
- rbanffy 8y agoA nice companion to https://nostarch.com/hemingway https://nostarch.com/hemingway
- dang 8y ago2017: https://news.ycombinator.com/item?id=15680668 https://news.ycombinator.com/item?id=15680668 2012: https://news.ycombinator.com/item?id=4856207 https://news.ycombinator.com/item?id=4856207
- deleted 8y ago[deleted]
- rahimiali 8y agotl;dr: the output looks like this: https://ibb.co/Ypp9DZ3 https://ibb.co/Ypp9DZ3
- edoceo 8y agoWhy does ibb need to know my location to serve an image?
- hombre_fatal 8y agoIt's requesting permission to send notifications, not your location. And it's because it loads https://cdn.siteswithcontent.com/js/push/subscribe.js?v=1.1.0 https://cdn.siteswithcontent.com/js/push/subscribe.js?v=1.1.... whatever that's for. That domain is on various adblock lists.
- snek 8y agohttps://snek.dev/10print https://snek.dev/10print :)
- shrimpx 8y agoShould fix the line height so the lines connect to each other.
- snek 8y agowhich browser doesn't show that right? chrome and firefox have connected lines for me
- bananicorn 8y agoFirefox doesn't - but it probably falls back on system fonts for me - there the line height needs to be at around 1.15em... Not that that helps in any way, since you never know which font might be used^^
- omaranto 8y agoThe lines are not connected here, on Chrome. Maybe it depends on what fonts you have installed?
- zestyping 8y agoAlas! I was hoping the pattern would change every time I refreshed the page.
- amasad 8y agoWrote it in JS at http://10print.art http://10print.art Source: http://10print.art/__repl http://10print.art/__repl
- AndrewKemendo 8y agoFor powershell: for(){Write-Host(Random("\","/"))-N}
- caf 8y agoYou can recreate the magic in bash: while true; do printf "\u$((2571 + ($RANDOM & 1)))"; done
- timClicks 8y agoIt's a shame that our fonts don't have the same aspect ratio. But that's a neat trick.
- Nursie 8y agoDoesn't quite work on my mac :/
- mojuba 8y agoGot it! This works on macOS. It encodes the same characters in hex UTF-8: while true; do printf "\xe2\x95\xb$((1 + ($RANDOM & 1)))"; done
- Nursie 8y agoExcellent work! Thankyou, that's awesome and very fast....
- kazinator 8y agoThe obligatory pure ASCII slash-backslash version: while true; do printf $(printf "\\\\u%04x" $((47 + 45 * ($RANDOM % 2)))); done
- fooblat 8y agoAnd for an even more "authentic" old school experience in bash: while true; do printf "\u$((2571 + ($RANDOM & 1)))"; sleep 0.02; done
- kazinator 8y agoFun task: write a program which takes such output, identifies all enclosed cells, and breaks them open, so that the maze is connected: any two points in the maze are connected by at least one path. Bonus: close loops, so any two places in the maze are connected by a unique path. As a preprocessing step, reformat the data to 77-column-long lines first, removing any whitespace characters, and discarding the last line if it is shorter than 79 characters, and then close off the exterior with solid zig-zags, like this, which are strictly added to the data (no overwriting): ╱╲╱╲╱╲...╱╲╱╲╱╲╱╲ ╲╱╲╲╲╲...╲╱╱╲╱╲╱╱ ╱╲╲╲╱╱...╱╲╱╱╲╱╲╲ ╲╱╲╲╱╲...╲╱╲╲╱╱╲╱ : : . . ╱╱╲╲╱╲...╱╱╲╱╲╱╲╲ ╲╲╱╲╲╱...╱╱╱╲╲╱╲╱ ╱╱╱╲╲╱...╱╱╱╲╱╲╱╲ ╲╱╲╱╲╱...╲╱╲╱╲╱╲╱
- th0ma5 8y agoVideo here https://youtu.be/m9joBLOZVEo https://youtu.be/m9joBLOZVEo
- cryptonector 8y agoYes, I see now, you could use that as the start of a book.
- bartread 8y agoGordon Bennett! That certainly provides a stark reminder of how slow BASIC was on the Commodore 64. This rings a bell though: I remember encountering it back when I owned the machine, possibly in the BASIC manual that came with it, possibly in a magazine, or perhaps somebody at school mentioned it.
- flohofwoe 8y agoLive version here ;) https://floooh.github.io/tiny8bit/c64.html?input=${wait:200}10%20PRINT%20CHR%24(205.5%2BRND(1))%3B%20%3A%20GOTO%2010%0ARUN%0A https://floooh.github.io/tiny8bit/c64.html?input=${wait:200}...
- mycall 8y agoThis was my favorite thing to do on TSR-80s at Radio Shack, then walk away, although I would do all characters instead.
- rzzzt 8y agoThis Maze Does Not Exist: an AI-powered labyrinth generator
- jypepin 8y agoI also built something in JS inspired by 10print with some customisation https://jauny.github.io/10print/ https://jauny.github.io/10print/ :)
- rkagerer 8y agoLove it! Brings up so much nostalgia from the days of programming on my old TRS-80. But is it really a maze? Once you start, you don't seem to get much choice of path...
- Kurtz79 8y agoOf course not, there is no logic behind it, save for printing "walls" that line up with each other. It's a (neat) graphic trick.
- tromp 8y agoMy maze generator at http://tromp.github.io/pearls.html#maze http://tromp.github.io/pearls.html#maze produces arbitrarily long proper mazes on the fly. After compiling and running, enter -1 as the requested height.
- Starwatcher2001 8y agoYou might enjoy this game written in a single line of BASIC on a TRS-80: https://www.youtube.com/watch?v=lWyZO-yPnvM https://www.youtube.com/watch?v=lWyZO-yPnvM For anyone not familiar with the TRS-80, who finds the code somewhat weird.. the BASIC implementation was written by Microsoft. Only the first two letters of variable names were significant. Although interpreted, the ROM tokenized typed lines, meaning it didn't care about spaces. This led to such gems as: FORK=10 TOMATOES STEP LADDER
- fnord77 8y agothis book reads like an article on a modern art piece.
- jesuslop 8y agoLacks randomize()
- DanBC 8y agoI think Commodore BASIC had a more complex way of seeding the random timer: https://www.c64-wiki.com/wiki/RND https://www.c64-wiki.com/wiki/RND POKE 56328,0 : REM real-time clock activate with 1/10s -> clock runs ($DC08) PRINT RND(0) : REM Random number addicted by timer and real-time clock
- Voltage 8y agoYou could also do I=RND(-TI) Providing a neg number to RND would "reseed" the random number generator. TI was a "system" variable that updates every 60th of a second.
- ssdsa 8y agoIn 2013, I recreated the output as a shader in ShaderToy: https://www.shadertoy.com/view/ld23DW https://www.shadertoy.com/view/ld23DW
- neatcoder 8y agoIs there anyone here who still writes code in BASIC? If so which interpreter/compiler do you use?
- gushie 8y agoI do so professionally. Our 35+ year old application is written in what was once VAX BASIC running on OpenVMS (Now on Integrity and called HP BASIC).
- neatcoder 8y agoWow! Can you share your story more? What does your application do? Why did you choose BASIC 35 years ago? Did the question about rewriting it another language come up anytime? How did such discussions go? Do you enjoy writing BASIC code?
- gushie 8y agoI've been with the company 20 years so wasn't involved in the original decision. I believe the company started out on PDP's before moving to MicroVAX (and later Alpha and Integrity). BASIC will likely have been the best fit at the time. It is business software for the Agri industry, originally a terminal text entry system. Now we also have a web front end (running on Windows IIS, communicating to VMS/BASIC via Apache Tomcat/WSIT webservices). We did try converting to VB6 back when it was a thing, but then .NET happened so we abandoned it as conversion to VB.NET wasn't so straight forward. A rewrite in C# was briefly considered before finally going for the web front end/web services option to avoid rewriting the BASIC business/data layer. Sadly the application will go end of life in a couple of years, as we're now part of a larger corporation who have similar applications. Ours lost out due to the OpenVMS layer being a hard sell to new customers. I've never really thought about when I enjoy it! It's mostly a data entry / reporting application, so generally not very exciting :)
- gushie 8y agoI tried it in HP BASIC. (Played with a few terminal emulator settings and this is the best I got) https://imgur.com/a/N6QSkXB https://imgur.com/a/N6QSkXB
- skrebbel 8y agoIt bothers me way more than it should that this line of code has become known as "10print". Like, 95% of BASIC oneliners out there start with "10 PRINT". It's like calling a McDonald's Super Size Big Tasty Meal With Diet Coke And A Side Salad a "Mac". It should've been called 205.5+RND or something. Grmbl.
- SeanLuke 8y agoWhy the 205.5? Why wouldn't this work as 205 + RND(1)?
- scbrg 8y agoRND(1) returns a value between 0 and 1, but always lower than 1. Thus, the result of 205+RND(1) will always be 205 point something, which in turn will be truncated to 205. Thus, it will always result in the same character.
- SeanLuke 8y agoI see. RND returns a float.
- soneil 8y agoIt's more that the decimal is always rounded down. So you don't want a value between 205 and 205.9999999, as it'll always be rounded down to 205. you want a value between 205.5 and 206.49999999, so when rounded down it has a (practically) even chance of landing on either 205 or 206.
- Voltage 8y agoIn CBM BASIC RND(1) returned a floating point value between 0.0 (inclusive) and 1.0 (exclusive). 205 + RND(1) would always evaluate to 205 when truncated. 205.5 + RND(1) pseudo randomly selects between 205 and 206
- HocusLocus 8y agoFrogger, TRS-80 Model 1 https://www.youtube.com/watch?v=wh7gRoYgUpc https://www.youtube.com/watch?v=wh7gRoYgUpc
- jquinby 8y agoNice. This brings back some great memories. I used to do a similar one-liner that alternated between white and black blocks, which created crossword-puzzle-like patterns. I'd sit across the room and squint at the display, hoping to see some sort of emergent pattern.
- golergka 8y agoA bit disappointed that this page doesn't generate the maze with each visit
- pantulis 8y agoIn the same book, an old one-liner called "BURROW" from Pet Gazette: 1A$="[up][down][left][right]":PRINTMID$(A$,RND(.5)4+1,1)"[left]";:FORI=1TO30:NEXT:PRINT"[rvson][space][left]";:GOTO1
- bufferoverflow 8y agoJavascript version: for (let i=0;i<10000; i++) document.write(String.fromCharCode(9585 + Math.random()*2) + (i%100 == 99 ? '<br>':'')) const b = document.body.style; b['font-family'] = 'Courier New'; b['font-size'] = b['line-height'] = '16px'; https://jsfiddle.net/qxjdtru6/ https://jsfiddle.net/qxjdtru6/ And a fun curvy variation: https://jsfiddle.net/qxjdtru6/1/ https://jsfiddle.net/qxjdtru6/1/
- svendahlstrand 8y agoThat's a great read! The book inspired me to port that BASIC one-liner to Game Boy flavored assembly. Still having a Game Boy lying around? Now you have portable mazes: https://github.com/svendahlstrand/10-print-game-boy https://github.com/svendahlstrand/10-print-game-boy
- kazinator 8y agoThis is poorly documented; I don't see a REM statement.