| Bytes | Lang | Time | Link |
|---|---|---|---|
| nan | AWK | 241105T145725Z | xrs |
| nan | Python 3 | 230712T223601Z | Ethan C |
| 1792 | Mornington Crescent | 250408T002053Z | Andrew B |
| 019 | Nim | 250325T024950Z | janAkali |
| 008 | Bespoke | 250325T015722Z | Josiah W |
| nan | Vim | 210427T001349Z | a stone |
| 006 | Jalapeño | 250324T021926Z | ATaco |
| 022 | SAKO | 250322T062642Z | Acrimori |
| nan | AArch64 machine code + Linux syscalls | 230628T215519Z | landfill |
| 015 | /// | 240906T050443Z | autumn |
| 021 | brainfuck | 240802T235912Z | Andrew B |
| 027 | JavaScript Node.js | 240802T233913Z | Andrew B |
| 014 | Setanta | 240802T000507Z | bb94 |
| nan | JCram | 240801T183502Z | Kamila S |
| 009 | Uiua 9 bytes | 240801T153300Z | janMakos |
| 022 | ><> | 240801T145254Z | Europe20 |
| nan | YASEPL | 240312T170729Z | madeforl |
| 039 | Pascal | 240312T010001Z | Kai Burg |
| nan | Desmoslang Assembly | 230530T045915Z | Dadsdy |
| nan | Racket | 230714T232515Z | Ed The & |
| 027 | Swift | 230714T220557Z | macOSist |
| 001 | Kib | 230714T200102Z | Komali |
| 006 | ForWhile | 230712T195321Z | bsoelch |
| nan | C | 230602T151652Z | landfill |
| 002 | !@#$%^&*_+ | 230614T220457Z | Wallace |
| 004 | Python REPL | 230601T185327Z | The Empt |
| 013 | Python 3 PyPy | 230601T172440Z | Wallace |
| nan | PHP | 151006T125354Z | Martijn |
| nan | Thunno 2 | 230528T141232Z | The Thon |
| nan | Thunno d | 230315T132735Z | The Thon |
| 015 | Slashalash | 180620T154928Z | Sophie S |
| 021 | Jelly | 160330T031951Z | Dennis |
| 023 | 05AB1E | 170606T165622Z | Magic Oc |
| 008 | Turtlèd | 160921T041803Z | Destruct |
| 004 | Carrot | 170521T124347Z | user4180 |
| 002 | APL | 220711T125145Z | Vadim Tu |
| nan | Flobnar | 220711T080629Z | Bubbler |
| 001 | Risky | 220129T062757Z | Dyad Han |
| nan | Python 3 | 220128T222609Z | jeptguy |
| 009 | Crystal | 220128T215400Z | user9275 |
| 013 | JavaScript | 220128T181140Z | user9275 |
| 012 | Python 3 | 220128T183344Z | Larry Ba |
| 018 | Vyxal | 211118T035227Z | emanresu |
| nan | Braingolf | 170517T161141Z | Mayube |
| 008 | Matlab | 151002T233550Z | Luis Men |
| 003 | Hexagony | 210427T005936Z | je je |
| 118 | Subleq | 210509T123602Z | Axuary |
| nan | Excel | 210428T144717Z | Axuary |
| 007 | Factor | 210427T010517Z | chunes |
| 006 | Julia | 210426T214538Z | MarcMush |
| nan | MATLAB | 210322T151727Z | robbie c |
| nan | Pxem | 210322T113610Z | user1004 |
| 002 | BRASCA | 210322T110945Z | SjoerdPe |
| 032 | Python | 210322T103719Z | SegFault |
| 028 | Flurry | 200812T015101Z | Bubbler |
| 003 | TlanG | 200701T144236Z | Daniel H |
| 004 | JavaScript | 151004T123802Z | Unihedro |
| 002 | naz | 200111T055534Z | sporebal |
| nan | GolfScript | 200110T101258Z | user8505 |
| 022 | W | 191222T133729Z | user8505 |
| nan | GolfScript | 191209T180424Z | Pseudo N |
| 005 | APL Dyalog Classic | 191209T130745Z | user8505 |
| 007 | Triangular | 190506T144755Z | squid |
| nan | Stax | 190822T221939Z | user8965 |
| 062 | Keg | 190606T151004Z | user8505 |
| nan | MathGolf | 190814T133021Z | maxb |
| 002 | MathGolf | 190729T182147Z | Matthew |
| 010 | Underload | 190731T190456Z | Edgex42 |
| 008 | 33 | 190730T232231Z | TheOnlyM |
| nan | C gcc | 180114T102822Z | gastropn |
| 012 | Python 2 | 190729T181849Z | Matthew |
| nan | Befunge93 | 190607T191757Z | negative |
| 087 | Aheui esotope | 190607T102726Z | LegenDUS |
| 014 | Python 3 | 190606T161417Z | SJ_SJ |
| 005 | Deadfish~ | 190529T185723Z | squid |
| 122 | TinCan | 190503T161456Z | Dehodson |
| nan | Excel Formula | 190502T103938Z | i_saw_dr |
| 004 | Clam | 190501T153828Z | Mayube |
| nan | 190430T181615Z | movatica | |
| 010 | Bash | 190430T175034Z | Beefster |
| nan | Husk | 190328T093752Z | Unrelate |
| 035 | 8088 machine code | 190409T185612Z | 640KB |
| 005 | Guile | 190409T153611Z | SYZYGY-D |
| 005 | Brainfuck | 190406T180931Z | orthople |
| 021 | Boolfuck | 190405T141451Z | orthople |
| 001 | ink | 190402T075346Z | Sara J |
| 032 | INTERCAL | 190401T011809Z | Unrelate |
| 039 | Come Here | 190401T014021Z | SuperJed |
| 086 | Java | 190323T224536Z | Benjamin |
| 040 | Tamsin | 190323T205740Z | Esolangi |
| nan | Perl 6 | 190321T023300Z | Jo King |
| 008 | Perl 6 | 190321T021055Z | bb94 |
| 025 | Python 3 | 170522T131240Z | Djaouad |
| 016 | C# Visual C# Interactive Compiler | 190305T205443Z | Gymhgy |
| 058 | MIPS | 190306T045242Z | Bsoned |
| nan | SNOBOL4 CSNOBOL4 | 190305T211529Z | Giuseppe |
| nan | Runic Enchantments | 190305T210754Z | Draco18s |
| nan | Brachylog | 190305T202713Z | Unrelate |
| 003 | PowerShell | 181208T215519Z | GMills |
| nan | Z80Golf | 181209T093308Z | Maya |
| nan | Java | 181209T084002Z | Amir M |
| nan | Ahead | 181209T015630Z | snail_ |
| 004 | Ahead | 181209T013830Z | snail_ |
| nan | 181209T011444Z | AndiChin | |
| nan | Gol><> | 180823T025628Z | Jo King |
| 191 | Shakespeare Programming Language | 180527T033344Z | Jo King |
| 020 | Hummus | 180604T190405Z | Azeros |
| 001 | Charcoal | 170521T184745Z | user6318 |
| nan | Perl 5 | 180601T160326Z | fockjef |
| nan | Wolfram Language Mathematica | 180531T095614Z | Shieru A |
| 036 | C | 180531T035558Z | J. Merdi |
| 024 | Rebol | 180530T211647Z | Friendly |
| 026 | Minecraft Functions 18w15a | 180527T232945Z | Noskcaj |
| 018 | Ruby | 180527T080823Z | Windmill |
| nan | JavaScript REPL | 180522T015723Z | l4m2 |
| 036 | Whitespace | 180521T223812Z | Censored |
| 030 | BrainFlak | 180114T043221Z | Jo King |
| 011 | Attache | 180522T000605Z | Conor O& |
| nan | Befunge98 | 180114T031854Z | Jo King |
| 046 | F# | 180521T212043Z | Ciaran_M |
| nan | Japt P | 180521T065909Z | Bubbler |
| nan | JavaScript Node.js | 180420T032027Z | Yair Ran |
| 006 | Fission | 171013T135746Z | KSmarts |
| 001 | Implicit | 170912T034740Z | MD XF |
| 090 | Java | 160330T013712Z | hyperneu |
| nan | 05AB1E | 160922T122922Z | Emigna |
| 021 | LibreLogo | 171014T031952Z | Grant Mi |
| nan | SmileBASIC | 170126T125206Z | 12Me21 |
| nan | BASH + coreutils | 170927T140000Z | Andrew D |
| 035 | Scala | 170929T214142Z | cubic le |
| 001 | Japt | 170522T081418Z | Shaggy |
| nan | RProgN 2 | 170925T035914Z | ATaco |
| nan | Pyth | 151002T232139Z | lirtosia |
| nan | JavaScript ES6 | 151002T232801Z | DankMeme |
| 030 | Windows Batch | 170521T123314Z | stevefes |
| 001 | Jq 1.5 | 170919T045543Z | jq170727 |
| 001 | Mathematica REPL | 151003T032051Z | alephalp |
| 004 | dc | 170917T031952Z | cab404 |
| nan | VBA | 170606T135313Z | Taylor R |
| nan | Pyke | 170916T195542Z | Blue |
| nan | Pyke | 170916T195350Z | Blue |
| 001 | Pyke | 170916T194608Z | Blue |
| 020 | TIBASIC | 170912T214418Z | Khuldrae |
| nan | Ly | 170821T222440Z | LyricLy |
| 015 | Java 8 | 170814T152741Z | NotBaal |
| 002 | TIBasic | 170606T154335Z | Timtech |
| 028 | Python 2 | 170628T153901Z | Fedone |
| nan | QBIC | 170126T102020Z | steenber |
| 005 | Bash | 170605T144533Z | Wossname |
| nan | ><> | 170604T171929Z | Esolangi |
| nan | Check | 170604T171231Z | Esolangi |
| 011 | bash | 170603T155237Z | Wossname |
| 001 | Braingolf | 170603T115044Z | totallyh |
| nan | Forth gforth | 170524T114955Z | 2xsaiko |
| nan | Fourier | 170522T091619Z | Beta Dec |
| 002 | Pari/GP | 170521T152132Z | alephalp |
| nan | REXX 33 Bytes 25 = 8 | 170521T130748Z | theblitz |
| 004 | Powershell 4 Bytes | 170518T121202Z | Sivapras |
| nan | 05AB1E | 170518T085139Z | kalsower |
| 045 | PHP | 170413T140559Z | Jimwel A |
| nan | Fourier Noncompeting | 170413T130434Z | Beta Dec |
| 002 | k | 170413T011848Z | zgrep |
| 010 | Excel | 170413T002214Z | Jör |
| 002 | J | 170412T234212Z | Bijan |
| nan | Alice | 170412T185420Z | Martin E |
| nan | Haskell | 170226T130819Z | Sacchan |
| 013 | ForceLang | 170226T123731Z | SuperJed |
| 029 | Processing | 151007T181713Z | user4180 |
| 107 | Java 132 25 = | 170226T110158Z | user6333 |
| 016 | [NonCompeting] C | 170226T083333Z | Albert R |
| 025 | C | 151003T021235Z | Albert R |
| 002 | Pushy | 170127T191701Z | FlipTack |
| 006 | PKod | 170127T191410Z | Offtkp |
| 024 | Ruby | 160704T041037Z | anna328p |
| 035 | Kitanai | 170127T105248Z | Sygmei |
| 009 | PHP no bonus | 161218T143355Z | Titus |
| nan | PHP | 161218T144015Z | Titus |
| 008 | Juggle | 170127T041647Z | Zavada |
| 002 | TIBasic | 170126T162143Z | Julian L |
| 020 | Python 3 | 170126T160219Z | Jimmy Jo |
| 017 | Recall | 151003T055138Z | user4264 |
| 030 | slang | 161023T145743Z | Erik the |
| 082 | Java 8 | 160922T132854Z | mrco |
| nan | Scala | 160922T120340Z | corvus_1 |
| 027 | Nim | 160922T112924Z | Copper |
| 010 | Cubix | 160921T014233Z | ETHprodu |
| 019 | BASH | 160804T153253Z | CousinCo |
| nan | Python | 160804T032531Z | vikarjra |
| 128 | BrainFlak | 160804T042729Z | Wheat Wi |
| 002 | V | 160804T034650Z | DJMcMayh |
| 011 | Perl5 | 160703T233802Z | Byeonggo |
| 003 | Desmos | 160703T225242Z | weatherm |
| 204 | PD | 160622T101306Z | Simon |
| 007 | dc | 160621T222248Z | juh |
| 003 | APL | 160528T232740Z | TuxCraft |
| 085 | Java | 160528T195159Z | Hopefull |
| 010 | Tellurium | 160528T140452Z | m654 |
| 002 | JavaScript | 160505T233028Z | ericw314 |
| 017 | Batch | 160402T125357Z | MrPaulch |
| nan | PHP | 160330T144718Z | ricdesi |
| 009 | Brian & Chuck | 160331T101438Z | Sp3000 |
| 006 | Hexagony | 160331T101038Z | Martin E |
| nan | Labyrinth | 160331T095409Z | Martin E |
| nan | Lua | 151004T171227Z | Trebuche |
| 012 | Underload | 160330T222823Z | MickyT |
| 002 | Pylongolf | 160330T211657Z | user4701 |
| 211 | J | 160330T020956Z | Leaky Nu |
| 2011 | Lua | 160330T025420Z | Leaky Nu |
| 015 | Cubix | 160330T011540Z | MickyT |
| 008 | Fuzzy Octo Guacamole | 160329T215803Z | Riker |
| 011 | Python 2 | 160319T163921Z | Zach Gat |
| 016 | Z80 machine code | 160319T093107Z | Fox |
| 003 | Gogh | 160319T041605Z | Zach Gat |
| 009 | Mathematica | 151229T140748Z | LegionMa |
| nan | Perl 5 | 151002T233825Z | Codefun6 |
| nan | Mumps | 151228T214544Z | zmerch |
| 001 | PlatyPar | 151216T012627Z | Cyoce |
| nan | BinaryEncoded Golfical | 151217T174002Z | SuperJed |
| 005 | MATLAB | 151217T170529Z | Tom Carp |
| 011 | Python 2 | 151217T154745Z | ASCIIThe |
| 003 | SWIProlog | 151027T100341Z | Fatalize |
| 011 | Perl | 151216T185650Z | ASCIIThe |
| nan | Note This answer did not work when the question was asked | 151216T015655Z | izzyg |
| 030 | Sass | 151215T130515Z | Fabrizio |
| nan | Mouse2002 | 151214T141406Z | cat |
| 003 | Perl 6 | 151028T013416Z | Brad Gil |
| 015 | Python | 151027T142343Z | TheDocto |
| nan | JavaScript ES5 | 151005T012254Z | Domino |
| 017 | CJam | 151003T000509Z | Dennis |
| 009 | Common Lisp REPL | 151027T064721Z | Candles |
| nan | Minkolang 0.9 | 151027T040242Z | El'e |
| nan | Vitsy | 151026T124944Z | Addison |
| 007 | Burlesque 7 Bytes | 151020T144956Z | mroman |
| nan | Simplex v.0.5 | 151020T040448Z | Conor O& |
| 055 | Hassium | 151012T175457Z | Jacob Mi |
| nan | 151012T115128Z | Nebula | |
| 059 | Go | 151003T190421Z | Fabian S |
| 008 | APL | 151009T134522Z | marinus |
| 004 | Pyth | 151003T175341Z | Erik the |
| 001 | CJam | 151008T165445Z | Mama Fun |
| 003 | Javascript | 151006T233721Z | Mama Fun |
| nan | 151005T180930Z | Mutador | |
| 002 | JavaScript | 151008T121702Z | Unihedro |
| nan | Retina | 151006T150046Z | Martin E |
| 004 | POSIX bc | 151007T223601Z | awd123 |
| 077 | C# | 151007T203618Z | Thomas W |
| 078 | Funciton | 151007T195858Z | Timwi |
| nan | Python 2.7 | 151007T184621Z | Status |
| nan | 151007T163204Z | PenutRea | |
| nan | Python 3 | 151006T230550Z | Blckkngh |
| 011 | Python 2 | 151006T112233Z | dieter |
| 001 | Bubblegum | 151004T003045Z | Dennis |
| 001 | Bash + GNU coreutils | 151003T081331Z | user1921 |
| 001 | Bash + GNU coreutils | 151006T111300Z | Toby Spe |
| 4015 | Sed | 151005T170407Z | Toby Spe |
| 007 | DOS | 151006T101157Z | Berend |
| 010 | Seed | 151005T165248Z | Sp3000 |
| nan | ><> | 151002T235620Z | torcado |
| nan | Selfmodifying Brainfuck | 151005T193335Z | mbomb007 |
| 768 | Shakespeare | 151004T054530Z | Luke |
| 082 | C | 151005T180011Z | wefwefa3 |
| 004 | MUMPS | 151005T175546Z | senshin |
| 010 | Powershell | 151005T154406Z | tomkandy |
| 014 | Brainfuck | 151005T091514Z | anatolyg |
| 001 | Insomnia | 151005T072714Z | n̴̖̋h̷͉̃ |
| 009 | Julia | 151003T112723Z | Moritz S |
| 002 | QBasic | 151005T022036Z | DLosc |
| 003 | R | 151005T004112Z | flodel |
| 023 | C | 151004T221339Z | anatolyg |
| 025 | Brainfuck | 151004T220042Z | Hand-E-F |
| 001 | TIBASIC | 151004T174937Z | Conor O& |
| nan | GolfScript | 151004T173828Z | Ilmari K |
| nan | JavaScript ES6 | 151004T060716Z | Patrick |
| 005 | Ruby | 151004T155756Z | Rocko |
| 019 | Haskell | 151004T120845Z | nimi |
| nan | ><> | 151004T142124Z | Sp3000 |
| 001 | GolfScript | 151004T124505Z | ProgramF |
| 012 | MSM | 151004T122914Z | nimi |
| 025 | C | 151004T121949Z | Vincent |
| nan | Ruby | 151004T032827Z | Nathan M |
| 062 | C# | 151003T214630Z | Lucas Tr |
| nan | Pyth | 151003T212829Z | izzyg |
| nan | Element | 151003T045457Z | PhiNotPi |
| 009 | PHP 7 | 151003T191415Z | Fabian S |
| 003 | TIBasic | 151003T050424Z | Deusovi |
| 006 | Pyth | 151003T173032Z | clapp |
| nan | dc | 151003T004905Z | Digital |
| 013 | Stuck | 151003T161115Z | Kade |
| 009 | CJam | 151002T232835Z | The_Bass |
| 013 | Python 3.4 | 151003T025851Z | user4551 |
| nan | JavaScript ES6 | 151003T004838Z | SuperJed |
| 018 | gs2 | 151003T110816Z | lynn |
| nan | JavaScript ES6 | 151003T000206Z | George R |
| 009 | Perl | 151003T083257Z | steve |
| nan | Perl | 151003T083211Z | primo |
| nan | Befunge98 | 151002T234755Z | El'e |
| nan | awk | 151003T074145Z | Cabbie40 |
| nan | C# | 151003T070805Z | dev-masi |
| 003 | q | 151003T053851Z | Alexande |
| 027 | q bonus | 151003T063857Z | Alexande |
| 002 | HQ9+ | 151003T062256Z | randomra |
| 080 | C++ | 151003T060318Z | Liam |
| 023 | Macaroni 0.0.2 | 151003T023435Z | Doorknob |
| 001 | Microscript | 151003T002901Z | SuperJed |
| 010 | Python 2.6 | 151002T233522Z | xnor |
| 011 | Python 2 | 151002T232313Z | xnor |
| nan | dc | 151003T002322Z | daniero |
| nan | Ruby | 151003T004902Z | histocra |
| nan | ><> | 151002T234327Z | cole |
| 021 | Mouse | 151002T234559Z | Alex A. |
| nan | Julia | 151002T232617Z | Alex A. |
| 006 | Ruby | 151002T234111Z | daniero |
AWK, 34 bytes - 25 bonus = 9
{for($1||$1=2;x++<$1*34;)printf 1}
Prints ones multiplied by the input.
{for(;x++ # more ones
<$1 # while less than input -
*26;) # times length of program
printf 1} # print you a one
Python 3, 28 27 bytes - 25 bonus = 2 bytes
-1 byte by l4m2
lambda n=2:print(*[99]*9*n)
Takes in an int as input and outputs [99] (99 is an arbitrary two-char number) times 9, which is the length of the code (27) divided by 3. The star expansion operator * makes print print the contents of [99]*9*n as a space-separated string. There are 9*2n characters from the 99's, and 9*n-1 characters from the spaces, for a total of 18n+9n-1=27n-1 characters. With the newline (+1 byte) that becomes 27n characters printed.
Mornington Crescent, 1792 bytes
Take Northern Line to Chalk Farm
Take Northern Line to Chalk Farm
Take Northern Line to Edgware
Take Northern Line to Chalk Farm
Take Northern Line to Chalk Farm
Take Northern Line to Edgware
Take Northern Line to Chalk Farm
Take Northern Line to Chalk Farm
Take Northern Line to Edgware
Take Northern Line to Bank
Take Northern Line to Bank
Take District Line to Hammersmith
Take District Line to Paddington
Take District Line to Bank
Take District Line to Hammersmith
Take District Line to Paddington
Take District Line to Hammersmith
Take District Line to Paddington
Take District Line to Bank
Take District Line to Hammersmith
Take District Line to Paddington
Take District Line to Hammersmith
Take District Line to Paddington
Take District Line to Bank
Take District Line to Hammersmith
Take District Line to Paddington
Take District Line to Hammersmith
Take District Line to Paddington
Take District Line to Bank
Take District Line to Hammersmith
Take District Line to Paddington
Take District Line to Hammersmith
Take District Line to Paddington
Take District Line to Bank
Take District Line to Hammersmith
Take District Line to Paddington
Take District Line to Hammersmith
Take District Line to Paddington
Take District Line to Bank
Take District Line to Hammersmith
Take District Line to Paddington
Take District Line to Hammersmith
Take District Line to Paddington
Take District Line to Bank
Take District Line to Hammersmith
Take District Line to Paddington
Take District Line to Hammersmith
Take District Line to Paddington
Take District Line to Bank
Take District Line to Hammersmith
Take District Line to Paddington
Take District Line to Hammersmith
Take District Line to Paddington
Take District Line to Bank
Take District Line to Bank
Take Northern Line to Mornington Crescent
Nim, 19 bytes
echo newseq[00](12)
Produces output with a newline:
@[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
Bespoke, 8 bytes
no stack
Prints Stack underflow. to STDERR.
Alternate version, 44 bytes
for my entry:N to some exponent,and output N
Prints 51^51, which is 88 digits long.
Vim, 26 25 - 25 = 0 bytes
-1 thanks to Aaron Miller
:s/^$/2
C<c-r>=<c-r>"*25
<esc>|D@"ix<esc>
Explained:
:s/^$/2<cr> Substitute blank line with 2. This is the case when no input is given.
C Cut the input line and enter insert mode
<c-r>= Enter expression mode
<c-r>" Paste input
*25 Multiply by code length
<cr> Evaluate
<esc> Return to normal mode (from insert mode)
| Move to the beginning
D Delete the line (which is the number of characters to output)
@" Paste the deleted line as the count argument to `i'
ix Insert `x'
<esc> Exit insert mode and repeat that many times
Jalapeño, 6 bytes, -19 score
|2*6*
With a trailing space.
Hex-Dump of Bytecode
0 1 2 3 4 5 6 7 8 9 A B C D E F
0000: 57 32 52 36 52 25
Kind of boring answer, |2 gives either the Input, or 2 otherwise, *6 multiplies by 6, the source code length, and * then repeats space characters that many times.
As of Version 12 of Jalapeño, space is the only one byte string that takes one byte to represent, so it's optimal.
SAKO, 22 bytes
1)LINII44
STOP1
KONIEC
This is just a port of my answer here.
Almost qualifies for a bonus, but doesn't default to 2, 38 bytes
1)CZYTAJ:N
LINIIENT(38×N)
STOP1
KONIEC
Unforunately do get an empty input we would need to read a string instead of a number and parse it, which is just not really worth it even with the bonus.
I did it anyway, 143 - 25 = 118 bytes
CALKOWITE:*N,W,I
BLOK(9):N
CZYTAJWIERSZ:N
W=0
*)GDYN(I)=58:2,INACZEJ1
1)W=W×10+N(I)-48
POWTORZ:I=0(1)9
2)LINII145×(W*SGN(1,I)+0*I)
STOP2
KONIEC
Maybe there is a way to shorten the loop, or the operation at label 2.
AArch64 machine code + Linux syscalls, 56 - 25 = 31 bytes
00: 4f03e7c0 movi v0.16b, #126 // v0 / q0 = '~' * 16
04: ad0003e0 stp q0, q0, [sp] // stack = '~' * 32
08: ad0103e0 stp q0, q0, [sp, #32] // stack = '~' * 64
0c: 52800048 mov w8, #2 // default to 2
10: 71000409 subs w9, w0, #1 // argc - 1
14: 1a890109 csel w9, w8, w9, eq // argc - 1 ?: 2
18: 910003e1 mov x1, sp // pointer to '~' * 64
1c: d2800702 mov x2, #56 // 56 bytes
20: d2800808 mov x8, #64 // 64 = write()
24: d2800020 mov x0, #1 // 1 = stdout (loop starts here)
28: d4000001 svc #0 // syscall, write(stdout, '~' * 64, 56)
2c: 51000529 sub w9, w9, #1 // loop countdown
30: 35ffffa9 cbnz w9, 0x24 // loop
34: d65f03c0 ret // return result of last syscall
Should be linked as main.
The input is the number of command line arguments.
If it needs to be linked as _start and isn't allowed to segfault out:
AArch64 machine code + Linux syscalls, 60 - 25 = 35 bytes
00: 4f03e7c0 movi v0.16b, #126 // v0 / q0 = '~' * 16
04: ad0003e0 stp q0, q0, [sp] // stack = '~' * 32
08: ad0103e0 stp q0, q0, [sp, #32] // stack = '~' * 64
0c: 52800048 mov w8, #2 // default to 2
10: 71000409 subs w9, w0, #1 // argc - 1
14: 1a890109 csel w9, w8, w9, eq // argc - 1 ?: 2
18: 910003e1 mov x1, sp // pointer to '~' * 64
1c: d2800782 mov x2, #60 // 60 bytes
20: d2800808 mov x8, #64 // 64 = write()
24: d2800020 mov x0, #1 // 1 = stdout (loop starts here)
28: d4000001 svc #0 // syscall, write(stdout, '~' * 64, 60)
2c: 51000529 sub w9, w9, #1 // loop countdown
30: 35ffffa9 cbnz w9, 0x24 // loop
34: d2800ba8 mov x8, #93 // 93 = exit()
38: d4000001 svc #0 // syscall, exit(result of last syscall)
If the input number being the number of command-line arguments doesn't count, here's one with no bonus:
AArch64 machine code + Linux syscalls, 40 bytes
00: 4f03e7c0 movi v0.16b, #126 // v0 / q0 = '~' * 16
04: ad0003e0 stp q0, q0, [sp] // stack = '~' * 32
08: ad0103e0 stp q0, q0, [sp, #32] // stack = '~' * 64
0c: 3d8013e0 str q0, [sp, #64] // stack = '~' * 80
10: 910003e1 mov x1, sp // pointer to '~' * 80
14: d2800a02 mov x2, #80 // 80 bytes
18: d2800808 mov x8, #64 // 64 = write()
1c: d2800020 mov x0, #1 // 1 = stdout
20: d4000001 svc #0 // syscall, write(stdout, '~' * 80, 80)
24: d65f03c0 ret // return result of last syscall
And for both of the above conditions:
AArch64 machine code + Linux syscalls, 44 bytes
00: 4f03e7c0 movi v0.16b, #126 // v0 / q0 = '~' * 16
04: ad0003e0 stp q0, q0, [sp] // stack = '~' * 32
08: ad0103e0 stp q0, q0, [sp, #32] // stack = '~' * 64
0c: ad0203e0 stp q0, q0, [sp, #64] // stack = '~' * 96
10: 910003e1 mov x1, sp // pointer to '~' * 96
14: d2800b02 mov x2, #88 // 88 bytes
18: d2800808 mov x8, #64 // 64 = write()
1c: d2800020 mov x0, #1 // 1 = stdout
20: d4000001 svc #0 // syscall, write(stdout, '~' * 96, 88)
34: d2800ba8 mov x8, #93 // 93 = exit()
38: d4000001 svc #0 // syscall, exit(result of last syscall)
brainfuck, 21 bytes
-->++++++[<.......>-]
Note: I decided to code this such that it prints printable ascii characters.
JCram, 9 - 25 = -16
2RⒶ¯⍓↑⍆Ⓩ⏚
Equivalent to ES6 (n=2)=>console.log(''.padEnd(n*9)).
Uiua -9 bytes
&pf▽16+@0⇡⍣⋕2&sc
Will print 16 copies of each ascii character up to the input length, starting with 0. i.e. Input of 3 gives
000000000000000011111111111111112222222222222222 (defaults to 2 if no input given)
><>, 22 bytes
095*>1-:?v;
^o*86<
Pushes 0 and 45 (which is subtracted by 1 right after), then outputs a zero that many times.
YASEPL, 22 - 25 = -3 bytes
=a'}7,""$2`1*22;"a",a~
YASEPL, 10 bytes (no input)
=a;"a",20~
Pascal, 39 Bytes
This complete program in accordance to ISO standard 7185 “Standard Pascal”
program p(output);begin write(6:78)end. { No trailing end‑of‑line character. }
prints
6
without a trailing end‑of‑line character (tested with the GNU Pascal Compiler and FreePascal Compiler).
Pascal, 90 − 25 = 65
The overhead for the bonus does not pay off since you must add input to the program parameters list and test for EOF, because reading from input is illegal if the end of file has been reached.
program p(input,output);var n:integer;begin n:=2;if not EOF then read(n);write(1:90*n)end.
Racket, 72 - 25 = 47 bytes
#!racket
((λ(n)(display(make-string(*(if(eq? eof n)2 n)72)#\a)))(read))
Explanation
The language expression for Racket is #!racket. This just tells Racket's system what language to run the program with.
On line two, we create an immediately invoked lambda that receives one optional input from the user. User input can be either #<eof> (no input) or a number n. If there is no input, we set n to be 2.
We multiply n with the length of the program which is 72 bytes (λ counts as two bytes) and use the result to make a string of as. I could have saved 3 bytes by not specifying any character to be printed, but that would print an empty string with 72 null characters. Once the string is made, we print it to standard output.
#lang racket
((lambda (n)
(display (make-string (* (if (eq? eof n) 2 n) 72) #\a)))
(read))
Links to relevant documentation
Have a wonderful weekend!
Swift, 27 bytes
for i in 87...103{print(i)}
Prints the numbers 87 through 103 inclusive, each number followed by a newline, for a total of 54 bytes.
Kib, 1 byte (noncompeting)
0
Any numeral works because of implicit output.
More interesting 4 byte solution
\A7*
\A # Push char 'A'
7 # Push 7
* # Multiply
(for reference this language is largely unfinished; I made it a couple months ago as a side project)
ForWhile 6 bytes
6(9##)
prints 12 tabs
Explanation
6( \ start for-loop with 6 iterations
9## \ print tab twice
) \ end for-loop
C, 47 - 25 = 22 46 - 25 = 21 bytes
x=2;main(){scanf("%d",&x);printf("%*x",x*46);}
Works by printing an uninitialised int, padded to the specified size. Credit to anatolyg's answer.
Python REPL, 4 Bytes
9**8
\$9^8=43046721\$
PHP, 56-25 = 31 bytes
I wanted one where size of the code doesn't matter:
<?=str_repeat(file_get_contents(__FILE__),$n!=''?$n:2)?>
Or a more modern version:
<?=str_repeat(file_get_contents(__FILE__),$argv[1]?:2)?>
Thunno 2, 8 - 25 = -17 bytes
2|8×⁻'x×
Explanation
2|8×⁻'x× # Implicit input (or not)
2| # Logical OR with 2
# (if there was no input, push 2)
8× # Multiply it by 8
⁻ # Decrement to account for
# the trailing newline
'x× # Repeat the character "x"
# that many times
# Implicit output with newline
Thunno d, 7 - 25 = -18 bytes
2~zd*ZL
Explanation
2~ # Logical OR with 2
zd # Read the source code
* # Repeat it that many times
ZL # Print without a trailing newline
# Implicit output
Thunno, 1 byte
1
Prints 1 with a trailing newline. Any digit will work here.
Jelly, -21 bytes
o2⁴x
The source code is 4 bytes long and qualifies for the -25 bytes bonus. Output is a list of 16's.
Try it online! without input or with input.
How it works
o2⁴x Main link.
If there's input, the left argument is set to that input.
Otherwise, it defaults to 0.
o2 Logical OR of the left argument and 2.
The return value is now either the input or 2.
⁴x Repeat 16 that many times, creating an array.
16 is two bytes long, and n copies are separated by n - 1 instances of , . That, plus the two bytes of [ and ] gives 2n + 2(n - 1) + 2 = 4n bytes of output.
Turtlèd, 8 bytes
15:[*,l]
explanation:
[implicit] initial cell is *, initial char var is *
15 put 15 in register
: move right by as many cells as the amount in register
[* ] while cell not *
,l write char var, move left 1 cell
Carrot, 4 bytes
.^*7
Prints ........ (8 .s).
Explanation
.^ Sets the stack-string to "."
*7 Append seven duplicates of the stack-string to itself
Implicit output
APL, 2 bytes
!7
The program prints the number 5040 (factorial of 7).
APL, 8 bytes (Bonus)
'*'⍴⍨8×⎕
The program prints asterisks (8 times more than n).
Flobnar, 27 - 25 = 2 bytes
*< _.v\@
*:|\<>
9&- <
3210
The decimal input command & defaults to its south (2) if it fails to read a number. Prints 27 times input copies of 0.
Flobnar, 8 bytes
0.!____@
Prints 16 copies of 0.
Python 3, (30-25)=5
def f(n=2):print((n*30-1)*"A")
The output includes a newline at the end which is accounted by subtracting 1 from the product of n and 30, the code length.
JavaScript, 21 16 13 bytes
alert("A"*26)
Vyxal, -18 bytes
2∨6*¤꘍₴
2∨ # n || 2
6* # times 6
¤꘍ # spaces
₴ # Without a trailing newline
Polyglot, 1 byte
0
In Vyxal, 05AB1E, K, (edit in more), prints 0 with a trailing newline.
Braingolf, (9 - 25) = -16 bytes
91+<9*1-^
Takes n input and outputs a 1 followed by x zeroes where x = (n * 9) - 1
Braingolf, 5 bytes
91+9^
Outputs 1000000000 (10**9)
Matlab, 8 bytes
1234;'5'
Output:
The output contains newline, ans =, newline twice, space four times, '5', newline, so 16 bytes.
Hexagony, 3 bytes
?"&}>'!_!!}(\\2"^$\<_!\@
Try it online!
Note: For some reason, the special Unicode character my code uses (, 0x10f447) seems to break TIO's link generator. So to make a linkable version, I replaced the character with X. Unfortunately, to run the code properly you'll have to copy and paste the character into the code in place of the X. Sorry about that.
Expanded:
? " & }
> ' ! _
! ! } ( \ \
2 " ^ $ \ < _
! \ @ . . .
. . . . .
. . . .
Whoops, thought I had a -3 but looked back over the problem and realized I missed that n defaults to 2 for an empty input. So here's 28 bytes, qualifies for 25 byte bonus. Works for values of n > 0, and defaults to n = 2 for empty input.
Explanation:
The first bit of code thats run is ?"&}2"^. ? reads n from input. Then "&}2" populates the cell to the right of n with a copy of itself, and the cell to the left with 2. This sets up for ^, which copies the value to the left of the current cell if the current cell is non-positive or empty, or the value to the right if it is positive. So if n does not exist or is non positive it is replaced with 2, otherwise it keeps its current value. After that, its just a matter of running through a simple for loop which decrements n until it reaches 0, each time printing the Unicode character 0x10f447 4 times using !. ! prints the decimal representation of a character, and 0x10f447 is 7 digits long, so in total 28 bytes are printed for each decrement it takes n to reach 0. The Unicode character is arbitrary, any with 7 digits in decimal would work (there are no 8 decimal digit characters.)
Edit: 5 byte bonus answer (doesn't qualify for answer bonus):
!<gg@
4 byte bonus answer, but it doesn't terminate:
!<)0
Subleq, 12 11 bytes (Assuming an 8 bit word)
2 -1 88 10 11 -1 8 8 0 1 22
Explanation
0: 2 -1 88 ' Output 2: "X"
3: 9 10 -1 ' 10: = 10: - 9:, if 10: <=0 exit
6: 8 8 0 ' 8: = 0, goto 0
9: 1 22 ' data
64 bit word, 96 88 bytes
2 -1 88 9 10 -1 8 8 0 1 176
Excel, 23 - 25 = -2 bytes
=REPT(0,IF(A1,A1,2)*23)
Saves 2 bytes by repeating a number instead of a character.
Excel, 4 bytes
=8^8
8^8 is an 8 digit number
Julia, 6 bytes
@info%
outputs in stderr (12 bytes including the trailing newline)
[ Info: rem
Explanation: % is the rem function (remainder)
MATLAB, 40 - 25 = 15 Bytes
I like using matlab, and I am slightly disappointed that what is probably the optimal answer for it has already been written. But here's a shot at achieving the bonus, which doesn't help ultimately but was fun regardless.
f=@(n)disp(char(linspace(1,2,2*2*10*n)))
Define an anonymous function that is 40 characters long. User calls the function as f(n) and it will output 40*n characters. (I think this complies with code golf rules but feel free to call me out if it doesn't)
with no output, the error message returned is
Not enough input arguments.
Error in @(n)disp(char(linspace(1,2,2*2*10*n)))
K
which comes out to 80 bytes, or 2x the length of my function. It's hacky but any other way would take more I'm fairly certain.
Pxem, 30 bytes (Filename) + 0 bytes (Content) - 25 bytes (bonus) = 5 bytes, requires nonprintable character, does not deal with default.
- Filename (nonprintable is escaped):
._.c.w.tXXX.eX.eX.e.p.m\001.-.c.a - Content is empty.
Try it online! (with pxem.posixism)
With comments
XX.z
# read integer and push it (pxem.posixism errors when not given)
.a._XX.z
# dup; while pop!=0; do
.a.c.wXX.z
# heap=pop
.a.tXX.z
# .e command actually stands for calling content as
# subroutine BUT content is empty so it stands for
# duplicating entire stack
# also non-command substrings stand for literals
# so stack would have (3*2+1)*2+1*2=30 X's
.aXXX.eX.eX.eXX.z
# pop all to output each of them
.a.pXX.z
# push heap; push 1; push abs(pop-pop); dup
.a.m\001.-.cXX.z
# done
.a.a
Pxem, 12 bytes (Filename) + 0 bytes (Content) = 12 bytes.
- Filename:
XX.eXX.e.e.p - Content is empty.
It outputs 24 X's without trailing LF.
How it works
XX.z
# push two X's
.aXXXX.z
# call content (as subroutine), pushing final result
## NOTE if original stack was 1,2,3 from top,
## the subroutine stack is also intialized with 1,2,3
## Then when returning from subroutine with final result of stack 4,5,6
## then original stack would be 4,5,6,1,2,3
## Since content is empty, it stands for duplicatinf entire stack
.a.eXX.z
## now X,X,X,X
# push two X's
.aXXXX.z
## now four X's
# duplicate entire stack twice
.a.e.eXX.z
# finally pop all to output each of them
.a.p
Python - (32 bytes - 25) = 7
k="1"*32
n=int(input())
print(k*n)
So close :(. This code takes a string k (which is 32 chars long, same as this code), takes n as an input, and prints k repeated n times.
Python - 16 bytes (no bonus)
k="1"*32
print(k)
Same as above, but without taking input, and thus, the code is only 16 bytes long.
Flurry, 28 bytes, no bonus
({<(({})){}{}>})({}){({})}{}
Verification
$ echo -n "({<(({})){}{}>})({}){({})}{}" | wc -c
28
$ ./flurry -iin -c "({<(({})){}{}>})({}){({})}{}"
3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3
3
$ ./flurry -iin -c "({<(({})){}{}>})({}){({})}{}" | wc -c
56
Uses 3 ** 3 = 27, and enables both stack output and return value output so that 3 is printed 27 + 1 times.
(
{<(({})){}{}>} Literal 3
) Push and return 3
({}) Pop, push and return 3; 3 3 -> 27
{({})} Push&return function
{} Pop 3; 27 push&return 3 -> push 27 copies of 3 and return 3
Flurry, 32 bytes, no bonus
<(({<({}){}>})({})){}{}>{({})}{}
Verification
$ echo -n "<(({<({}){}>})({})){}{}>{({})}{}" | wc -c
32
$ ./flurry -inn -c "<(({<({}){}>})({})){}{}>{({})}{}"
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
$ ./flurry -inn -c "<(({<({}){}>})({})){}{}>{({})}{}" | wc -c
64
How it works
In order to increase the output size, it is easiest to push numbers to stack and print them in integer mode. Basically the program follows the structure of n push&return m, where n is the repeat count, push&return is a function that, given an argument, pushes it and returns it unchanged, and m is the number to push. Then the stack contains n copies of m at the end, giving the output size of (length of m + 1) * n.
The second part of the challenge is to generate high enough numbers. Flurry uses Church numerals to represent natural numbers, so multiplication (<abc...> evaluates to a * b * c * ...) and exponentiation (ab evaluates to b**a) is much golfier than number literals (except 1), successor <><<>()>, and addition (which is defined via successor). So I tried various powers and products until I got the solution, where 32 is 4 * 4 * 2.
<
(
({<({}){}>}) Push and return 2
({}) Pop 2, push back and return 2
) Push and return 2 ** 2 = 4
{}{} Pop 4 and Pop 2
> Product; return 4 * 4 * 2 = 32
{({})} Function: push&return
{} Pop from empty stack, which gives I = 1
32 push&return 1 -> Push 1 to stack 32 times and return 1
JavaScript, 4 bytes
+1/0
Prints Infinity
I think this is the shortest possible JS solution without ES6 :P
naz, 2 bytes
4o
Outputs 0000.
Explanation
The default value of the register is 0; if the register's value is between 0 and 9 inclusive, use of the o instruction will output that number as an ASCII character.
GolfScript, 13-25 = -12 bytes
.~13*(25if n*
Explanation
if # If
. # Input is not a null string:
~ # Evaluate the input
13*(25
n*
W, -22 bytes
The program is 3 bytes long and qualifies for the -25 byte bonus. (Okay. One-digit problem fixed!)
0M
Explanation
% Filler space
M % Map: (implicitly) generate a list from 1 to the input
% There is an implicit 0, so the 0-input
% will produce the output [0, 1], which is
% 6 bytes by default.
M % Map every item in that list ...
0 % .. with the numeric constant 0
GolfScript, 18 - 25 = -7
.!35 n*{~18*(n*}if
Prints \$input * 6 - 1\$ newlines if there is an input else 35 newlines, plus one trailing newline.
if If
.! input is empty:
35 n* 35 newlines
{ } Else:
~18*(n* 18 * input - 1 newlines
Trailing newline
APL (Dyalog Classic), 5 bytes
⎕←1e9
Explanation
Not very interesting... but I hope this hasn't been posted before.
1e9 ⍝ This returns the constant 1000000000
⎕← ⍝ Move this to the output buffer
Triangular, 10 8 7 bytes
tdC%.`y
Prints odd numbers from 11 to 1 descending, twice each.
Triangular executes as if written in the shape of a triangle. For example, if your program was 123456, the triangle representing your program would be drawn like this:
1
2 3
4 5 6
The program executes starting from 1, and has a Southeast direction (I.e., the above would run as 1, 3, 6). This explanation is for its actual execution order, which is why it doesn't visually look the same as the submission.
Ungolfed/Directional
t
d C
% . `
y
-------------------------------------------------------------------
t - If ToS != 0, set direction to SouthEast
C - Push 12
` - Set direction to NorthWest (This means we hit "t" with ToS > 0)
d - Decrement the top value of the stack
%y - Print the top value of the stack, then change direction to NorthEast if ToS != 0
Previous Version (8 bytes):
Dn,%d./<
Stax, 16 bytes - 25 = -9
|?xx{{dqF}{dqq}?
Uses Stax's sneaky |? command, which means that the output is also 2 quines (or any other input number)
However, one downside is the fact that I can't use packed stax, as the |? operation prints out unpacked source code, even if the source is packed
Keg, 6 2 bytes
(|A,)
It loops 12 times printing 12 A's to the console, which is double the size of the program. There is a control character (0x0C) between the ( and |, which makes this 6 bytes.
Another shorter version:
A
This prints A plus a newline, which contains 2 characters.
Worth a mention(3 bytes):
5/
MathGolf, 5 - 25 = -20 bytes
╜2╩[*
Explanation
╜2 If not implicit input, push 2
╩[ Push dictionary word "great"
* Repeat string
To make it work, I just had to find a word within the top 256 lines of the dictionary which had the same length as the code.
Almost working 3-byter with 25 byte bonus
╜2r
Basically the same as Stan Strum's Pyth answer. If (implicit) input is equal to 0, push 2. Then create a range using either the 2, or the implicit input. The length of the output is the length of the string representation of the array, which is 3 times the length of the array. This only works for input \$\leq 10\$.
Underload, 10 bytes
()aaaaa:*S
I'm pretty sure this is unimprovable, since I made a python script to test all possible combinations of instructions. However, I did only include the instructions a:*S in it, and made it so it always starts with (), so there could be a crazy solution involving ^ or ~. Also, for those curious, there are actually 5 other valid 10 byte solutions:
()aaaaa:SS
()aa:a*:*S
()aa:a*:SS
()aa:*a:*S
()aa:*a:SS
C (gcc), 35 - 25 = 10 34 - 25 = 9 bytes
-1 byte thanks to PrincePolka
Input is in the form of number of command-line arguments. No arguments counts as no input.
main(i){printf("%*d",34*--i?:68);}
Python 2, 12 Bytes
print 18**19
Outputs 708235345355337676357632 which is 24 characters.
Befunge-93, 25 - 25 = 0 bytes
&+:0\`3*+::%+"CG"*:*:.:*.
Uses no control flow instructions! This code is implicitly looped n amount of times.
To get the n as input once and not have it interfere with subsequent iterations, we use Befunge-93's feature of returning -1 for input if the input stream is empty. At the start of each iteration, the top of the stack is the loop counter. It starts off at 0 (the default value on the stack). &+ gets a value from input and adds it to the counter. Conveniently, this sets the counter to the received input on the first iteration, and subtracts 1 on every subsequent iteration, creating a for (i = input();; i--) loop. :0\`3*+ computes (counter < 0) * 3 and adds it to the counter. This has the effect of adding 3 if the counter is negative (which happens if there was no input and we want to set n to -1+3=2), and otherwise adding 0 (if the input was positive or this is not the first iteration).
::%+ simply calculates counter % counter and discards the result, so as to halt when the counter reaches 0.
At the end, we output two large numbers by repeatedly squaring the product of two ASCII characters. Note that after each outputted number there is a trailing space.
Aheui (esotope), 87 bytes
삭밦밢따밥다사바바바바바바우a
샥ㅇ뱟ㅇ탸ㅇ뺘소처희ㅇㅇ아멍a
output is 174 bytes of 0. Aheui program is written in Korean, so one character is 3 bytes, and question said measured in byte, so 174. Trailing a is for making program to proper bytes.
How does this work?
삭밦밢따밥다 : to stack ㄱ, then put 58. (28 Korean characters. Aheui cannot put 1 to stack, so I'll subtract 2 instead of 1 when counting loop.)
사바바바바바바우 : to stack (Nothing), put 6 zeros, than move downside.
아멍 : print from current stack till nothing left. if nothing left, move to start of the line.
샥ㅇ뱟ㅇ탸ㅇ뺘소처희 : to stack ㄱ, subtract 2, check if zero, halt if zero, to stack (Nothing) and move to 사바바바바바바우 again.
a : At first, I thought this code would work just fine, but something went wrong. I used online character counter, and I got 29, so I made code with that. But code was 85 bytes and output was 174 bytes. I found the reason of this error : newline character. So I added 2 bytes to my code, than everything works fine. Aheui don't evaluate non-Korean characters, so a is just blank.
Python 3, 37 14 bytes
print('a'*27)
Deadfish~, 5 bytes
You expected a worthwhile submission, but it was ME:
{dio}
Prints the number "1" ten times.
TinCan, 122 bytes
# 62367, A, & #
# -256, A, -1 #
# 0, A, 1 #
Outputs 244 'a's.
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
Explanation:
Lines have a minimum length of 40 characters in TinCan, and there is only one instruction, so 40 bytes would be the shortest feasible TinCan program other than an empty file.
TinCan's interpreter is written in PHP and uses the PHP chr function to output the character value of each number on the stack when the program ends. This also works for values outside the range of 0 to 255, using bitwise and with 255 to get the result.
For this program, I multiplied the length of the program (122 bytes) times two, minus one for the positive case, times 256 and added (256 - 97), 97 being the ASCII value of 'a'. This gives 62367.
The loop then generates a sequence of values starting at -62367 and counting upwards by 256 each iteration. Each value in sequence when processed by chr produces another 'a'. When the variable A becomes positive, the program exits and prints 244 'a's.
With the fixed line length, golfing this down would require removing one whole instruction, which I don't believe is possible. But I'd be happy to be proven wrong!
Excel Formula, 23 - 25 = -2 bytes
=REPT("A",MAX(A1,2)*23)
However, this doesn't work for A1 (n) = 1(!)
Version supporting N=1, 28 - 25 = 3 bytes
=REPT("A",(A1=0)*56+(A1*28))
Clam, 4 bytes
p^97
Not very interesting.
Outputs 4782969 followed by a newline
Explanation:
p - Print next token's value
^ - Exponent operator on next 2 tokens
9 - Literal 9
7 - Literal 7
9^7 = 4782969
C++ (gcc)
without bonus: 57 bytes
#include<cstdio>
int main(){for(int i=57;i--;)puts("x");}
with bonus: 77 bytes (= Score 52)
#include<cstdio>
int main(){int i;scanf("%i",&i);for(i*=77;i--;)putchar(46);}
Bash, 10 bytes
yes|head -
outputs 10 lines of ys for 20 total bytes output.
Husk, 13 bytes - 25 = -12
R'A*13→←`↓ΘN←
Try it online! (Try it with no arguments!)
(Both TIO links use capital xi instead of A because it looks cooler, but since I just realized that output has to be ASCII and xi isn't exactly ASCII although it is one byte in Husk's code page, the "canonical" program here uses A instead.)
I tried to come up with a well-thought-out and enlightening explanation of why Husk's overload resolution for built-ins doesn't support distinguishing type signatures by number of arguments alone, but I couldn't quite get it right and it took long enough just to write the solution. Suffice it to say, it doesn't, so I had to get a bit creative.
The first part functions the same with and without an input:
R Repeat
'A capital A (could be any character)
13 (thirteen
* times
→ (one plus
← the first element of
whatever expression we get to the right of this))
R times.
The rest of the program handles the defaulting behavior, by exploiting ↓'s possession of overloads for using either a function or a number to drop a prefix from a list.
Explained with an input:
N The infinite list of the natural numbers
Θ with a zero tacked on to the beginning
`↓ with the first
(input
← minus one)
`↓ elements removed.
Without an input:
N The infinite list of all natural numbers
Θ with a zero tacked on to the beginning
`↓ without the largest prefix every element of which
← is not equal to 1.
A version which elects to not take the bonus:
Husk, 2 bytes
←.
Husk assumes that, in the absence of any digits on the left of the radix point, a single 0 is meant, and in the absence of any on the right, a single 5 is meant. So, it is possible to write 0.5 as just .. 0.5, as a string, is three bytes long (and so is 1/2, which is what actually gets printed), so to add a byte, subtract 1 for -0.5 (although what we actually print is -1/2).
← Subtract 1 from
. 0.5.
A longer and sillier no-input version:
Husk, 3 bytes
ss"
Prints "\"\"".
s The string representation of
s the string representation of
" the empty string.
A version which must take input, having no valid type if it doesn't take an input, and thus neither does nor doesn't take the bonus, failing to comply with the challenge at all:
Husk, 4 bytes (invalid but here anyways, would be -21 with bonus)
*s"¨
Prints n copies of "\"".
s The string representation of
" the string containing
¨ a single "
* repeated n times.
8088 machine code, IBM PC DOS, 35 bytes
Unassembled listing:
_LOOP:
AC LODSB ; load byte [SI] into AL, increment SI
8A F0 MOV DH, AL ; save original byte in DH
B9 0204 MOV CX, 0204H ; set up nibble counter and shift count
D2 C0 ROL AL, CL ; reverse nibbles (display high order first)
_NIB:
24 0F AND AL, 0FH ; mask low nibble
3C 0A CMP AL, 0AH ; is < 10?
72 02 JC _ASC ; if so, is a numeric digit
04 07 ADD AL, 07H ; otherwise adjust for A-F hex ASCII
_ASC:
04 30 ADD AL, '0' ; ASCII convert
B4 0E MOV AH, 0EH ; BIOS output char function
CD 10 INT 10H ; display char
8A C6 MOV AL, DH ; restore original nibble to AL
FE CD DEC CH ; decrement nibble counter
75 EC JNZ _NIB ; if > 0, repeat
81 FE 0123 CMP SI, OFFSET _EF ; is SI < last byte?
7C DE JL _LOOP ; if so, keep looping
C3 RET ; return to DOS
_EF EQU $ ; get program size
This is a complete IBM PC DOS executable that displays itself as ASCII hex, so will always output as twice the program size.
Output
Download and test SELF.COM!
Guile (5)
"oof" outputs $1 = "oof"
Brainfuck, -5 bytes
,[>++++<-]>[.....-]>
Input is provided in binary.
Similar to anatolyg's solution, this program corresponds to the minimal solution of a*b=10+a+b+c.
Boolfuck, 21 bytes
+[[>+>+[<;;;]<]>+>>]>
This program outputs 330 bits (41.25 bytes) which get buffered to 42 bytes. I found it by systematically (but not quite exhaustively) searching through several million possible candidates.
Here is a hexdump of the output:
00000000: fc0f ffe3 ffc7 ffff ff1f fe3f ffff f8ff ...........?....
00000010: ffff ffff c0ff fe3f ffff ff1f ffff ffff .......?........
00000020: ff1f ffff ffff ffff fe00 ..........
I also recommend taking a look at this in fatiherikli's Brainfuck visulizer (optimized and with minimal delay of course).
INTERCAL, 32 bytes
PLEASE,1<-#64DOREADOUT,1DOGIVEUP
Prints 64 null bytes and takes no input. If you like your output printable, the next version is for you:
INTERCAL, 45 bytes
PLEASE,1<-#90DO,1SUB#1<-#4DOREADOUT,1DOGIVEUP
This is one of those rare cases where C-INTERCAL’s “Turing Tape” I/O is actually helpful. Essentially, what it does is for each value in an array, rather than directly print the corresponding character, is subtract the value from the previous value (starting at 0) mod 256, reverse the bits, and then print that, for every value up to the end of the array. So to print a string of a certain length, you just need to READ OUT an array of that size, and to make it more than just a bunch of null bytes, you only need to set the first element of the array and it’ll print a bunch of something else instead: here, setting the first value to 4 prints 90 question marks, since 0 - 4 mod 256 ≡ 252 = 0b11111100 which is 0b00111111 = 63 backwards, and since every cell in the array after the first has a 0 in it the byte which gets printed never changes on account of that 252 - 0 is still 252.
A version with the bonus which prints null bytes:
INTERCAL, 67 bytes - 25 = 42 (except it can't default to 2)
DOWRITEIN.1DO.2<-#67DO(1530)NEXTPLEASE,1<-:1DOREADOUT,1PLEASEGIVEUP
A version which prints question marks instead:
INTERCAL, 80 bytes - 25 = 55 (except it can't default to 2)
DOWRITEIN.1DO.2<-#80DO(1530)NEXTPLEASE,1<-:1DO,1SUB#1<-#4DOREADOUT,1PLEASEGIVEUP
Uses a call to syslib for multiplication of the input with 80 into :1. (Also note that INTERCAL’s native number input format is the digits of a number spelled out with a trailing newline.)
Come Here, 39 bytes
CALL"9999999999999"iTELLi i i i i iNEXT
Java, 86 bytes
Prints 172 (86*2 = 172) null bytes to STDOUT
interface A{static void main(String[]a){System.out.print(new String(new char[172]));}}
Perl 6, 17 - 25 = -8 points
print e x(get||2)
Prints the builtin constant e (\$2.718281828459045\$) either input or 2 times. Luckily, the precision of the constant is 17 bytes long, exactly the same as my code length.
Explanation:
print # Print without newline
e # The constant e (2.718281828459045)
x( ) # String multiplied by
get # The input
||2 # Or two if the input does not exist
Perl 6 (8 bytes)
say 1e14
Perl 6 (with challenge, 27 bytes - 25 = 2)
print "a"x(@*ARGS[0]//2)*27
Python 3, 26 25 Bytes
lambda n=2:print(n*26*'-')
Improved thanks to @JoKing
C# (Visual C# Interactive Compiler), 17 16 bytes
Write($"{0,32}")
Thanks to Jo King for saving one byte!
MIPS, 58 bytes
main:li $v0,1
li $a0,63
l:sub $a0,$a0,1
syscall
bnez $a0,l
A counter loop that prints the count on each pass without spaces or a trailing newline.
SNOBOL4 (CSNOBOL4), 58 bytes - 25 = 33
N =INPUT
O OUTPUT =1
X =LT(X,N * 29 - 1) X + 1 :S(O)
END
Runic Enchantments, 10 bytes -25 = Score: -15
"9q2i{S*$;
Program reads a string literal (effectively its own source), concats a 9, pushes a literal 2, and attempts to read input.
Reading input and there being no input to read causes the next two commands, {S, to be NOP. This leaves the literal 2 on top of the stack. If there was input, the input ends up on top and the literal 2 on the bottom. Non-numerical input has undefined behavior.
Then multiplication between the integer on the top of the stack with the next item (the string) duplicates it n times (Python style). String is exactly the length of the program, being almost a quine, with 9q putting a 9 on the end substituting for the missing " from the beginning. $; prints only the resulting string and terminates (discarding any remaining literal 2 if input was taken).
Brachylog, 10 bytes - 25 = -15
{2|};Ṿj₍jw
w Print
Ṿ "aeiou"
j concatenated with itself
2 two
{ |} or whatever else the input is
; ₍ times
j concatenated with itself again.
A version without the bonus:
Brachylog, 3 bytes
ẈẈw
Bypasses the ban on unnecessary whitespace by using unnecessary variable unification instead.
w Print
Ẉ the built-in constant "aeiouy" which is
Ẉ the built-in constant "aeiouy".
A version without any silly redundancy:
Brachylog, 4 bytes
1j₈w
w Print
1 the digit 1 (could be any digit other than 0)
j repeated
₈ eight times.
PowerShell, 3 bytes
1e4
PowerShell, 1 byte
Thanks to @mazzy for pointing this one out!
1
Both programs' outputs includes a trailing newline!
Z80Golf, 14 bytes - 25 bytes of bonus = 11 anti-matter bytes (-11 classic bytes)
00000000: 3e02 cd03 8006 0eff 10fd 3d20 f876 >.........= .v
Takes input as a byte value.
ld a, 2
call $8003
outer:
ld b, 14
inner:
rst $38
djnz inner
dec a
jr nz, outer
halt
Java, 234 - 25 = 209 bytes
import java.io.*;interface A{static void main(String a[])throws Exception{InputStream i=new FileInputStream("A.java");byte[]b=new byte[1];for(int l;(l=i.read(b))!=-1;)for(int n=0;n<Integer.parseInt(a[0]);n++)System.out.write(b,0,l);}}
Formatted :
import java.io.*;
interface A {
static void main(String a[]) throws Exception {
InputStream i = new FileInputStream("A.java");
byte[] b = new byte[1];
for (int l; (l = i.read(b)) != -1; )
for (int n = 0; n < Integer.parseInt(a[0]); n++)
System.out.write(b, 0, l);
}
}
Ahead, 6 - 25 = -19 bytes
Here it is with the bonus.
I6*kO@
I Read number from stdin
6* multiply by 6
k I*6 times...
O ...pop and print number
@ end
Python3 Shell version
'2'*10
outputs:'2222222222'
Gol><>, 8 - 25 = -17 bytes
IE28*Rn;
Outputs all 0s.
Explanation:
I Get inputted number
E2 Push 2 if no input
8* Multiply by 8 (length of code)
Rn Print 0 that many times
; Halt
Without bonus, 4 bytes
"D;
Outputs [68 59]. Note that both input and output have a trailing newline.
Shakespeare Programming Language, 216 192 191 bytes
Twice the source.Ajax,.Puck,.Act I:.Scene I:.[Exeunt][Enter Ajax and Puck]Ajax:Open heart!You big big big big big big big cat!Puck:You is the sum ofyou a cat!Be you worse I?If solet us Act I!
Prints a 0 followed by 128 128s.
Hummus, 20 bytes (non-competitive)
().(rep('xx',20)).()
Explanation:
().(rep('xx',20)).() //Empty anonymous function
(). //Empty parameter declaration
(rep('xx',20)) //Repeat 'xx' 20 times
.() //Empty value declaration
In contrast, a non-empty, anonymous function would look like this:
(x).(x*x).(2)
(x). //Defines x as parameter
(x*x) //Defines the output to be x*x or x²
.(2) //Defines the input of the anonymous function to be 2 (hence the output is 4)
Alternative, 2 bytes:
!0
This works as well and outputs true but since this was posted multiple times already, I found it to be quite a boring solution.
Wolfram Language (Mathematica), 17 bytes - 25 = -8
Echo[10^(17#-5)]&
Assuming giving a function is OK. Prints >> 1, then (17 * input - 5) 0s, then a trailing new line, thus making the output 17 * input bytes long.
C, 36 bytes
main(a){for(a=4;a--;)puts(puts);}//!
Really hacky stuff here. The implementation of puts on my machine (gcc 6.3) has 16 bytes before it hits a null, and adds a newline and SOH (18 bytes total). Run four times, and it's 72 (or 0x48) chars. I padded mine with a 3-char comment to fit that. Most of the chars are unreadable, so here's a hexdump of the output.
0000000 5541 5441 8949 55fc 4853 ec83 e808 76ae
0000010 0a01 5541 5441 8949 55fc 4853 ec83 e808
0000020 76ae 0a01 5541 5441 8949 55fc 4853 ec83
0000030 e808 76ae 0a01 5541 5441 8949 55fc 4853
0000040 ec83 e808 76ae 0a01
0000048
Rebol, 24 bytes
copy/part mold system 48
Prints the first 48 characters of the system object.
Also works with the Red language
Minecraft Functions (18w15a, 1.13 snapshots), 26 bytes
Uses one function named ab
ab
function ab
tp @e ~0 ~0 ~0
It just recurses until it hits the default limit of 65536, at which point it outputs Executed 65536 commands from function 'minecraft:ab'
Ruby, 18 Bytes
I am lazy to make the input thing. So take the *2.
36.times{print"a"}
JavaScript REPL, 24-25 = -1 bytes
Array(24*prompt()||48)+0
JavaScript function, 20-25 = -5 bytes
(n=2)=>Array(20*n)+0
n=>Array(20*n||40)+0
Just how no one post this?
Whitespace, 38 36 bytes
SSTTTSTTNNSSNSNSTNSTSSSTNTSSSSNSNTTN
Prints "-27-26-25-24-23-22-21-20-19-18-17-16-15-14-13-12-11-10-9-8-7-6-5-4-3-2-1". Whitespace doesn't have optional input so I can't go for the bonus.
Brain-Flak, 30 bytes
([()()()()()]){((((({}))())))}
Prints three 0s, four each of -1 through to -4 and two -5s, each separated by spaces.
With bonus: 62 - 25 = 38 bytes
({{}[()()]}()()){({}<((()()()()()){}){({}(([()])))}>[()])}{}
Outputs n*(20*"-1 "+"0 "). There are two extra spaces to pad it out to 62 bytes.
How It Works:
({{}[()()]}()()) Add a 2 to the stack if there is no input
{ Outer loop
({} Pop the outer loop counter
<
((()()()()()){}) Add a 10 to the stack
{ Inner loop
({}(([()]))) Decrement the inner loop and add two "-1"s to the stack
}
> Discard the inner value
[()]) Decrement the outer loop counter
}
{} Pop the excess 0
Attache, 11 bytes
10^20|Print
Attache (bonus), 36 - 25 = 11 bytes
(Safely[ReadInt][]or 2)*36*$x|Output
Uh. Both come out to be the same byte count. So there's that.
Befunge-98, 12 - 25 = -13 bytes
j& 6*1-k.@>2
Prints the correct amount of 0s, each with a trailing space.
How It Works:
j No effect
& Gets input. If no input, reflect
>2 If it reflected put two 2s on the stack
j Use one of the 2s to jump past the &
6*1- Multiply by 6 (length/2) and subtract 1 because it prints an extra 0 later
k.@ Print that many 0s and end the program
F#, 46 bytes
let[<EntryPoint>]m a=
printf"%A"[|10..31|]
0
Prints out:
[|10; 11; 12; 13; 14; 15; 16; 17; 18; 19; 20; 21; 22; 23; 24; 25; 26; 27; 28; 29; 30; 31|]
which is 92 bytes long.
Japt -P, 3 - 25 = -22 bytes
õ@L
How it works
Uõ@L
Uõ Create range of [1..input] inclusive, and map...
@L the function that returns the constant 100.
The õ generates [1,0] for no input (implicit zero) and [1,...,n] for positive integer input, which perfectly fits with the default=2 requirement.
The -P flag prints the resulting array with no separator, so the output length is exactly 3 times the length of the array.
JavaScript (Node.js), 22 - 25 = -3 bytes
(x=2)=>''.padEnd(22*x)
If we require an alert-type output, this can be managed in 29 bytes - 25 = 4 points:
(x=2)=>alert(''.padEnd(29*x))
Versions without bonus (7 bytes):
x=>1e13
And with output as alert (12 bytes):
alert({}+$4)
Or without special console variables (14 bytes):
alert({}+1e12)
Fission, 7 6 bytes
'#ORR"
This is a variation on a standard Fission quine. With two R's it creates two atoms and reads through the program twice.
Outputs ''##OORRRR##
-1 byte thanks to Jo King
Java, 90 bytes
class T{public static void main(String[]a){for(int i:new int[90])System.out.print("##");}}
05AB1E, 7 - 25 = -18 bytes
Saved a byte thanks to Okx.
YI7*ð×?
Explanation
Y # push 2
I # push input
7* # multiply top of stack with 6 (program length)
ð× # repeat <space> that many times
? # print top of stack
SmileBASIC, 24 18-25= -7 bytes
N=2INPUT N?@A*N*9;
In SmileBASIC, labels (@LABEL) are treated as string literals in expressions, so you can make a 2 or more character long string without any quotes. Then it just has to print @A N*9 times to get the correct length.
Without bonus, 6 4 bytes
?1E7
There is a line break after the output, but technically no character is printed to the screen (it is different than if you just printed CHR$(10))
BASH + coreutils, 22 (-25) = -3 bytes
printf %$[${1:-2}*22]d
Pass repeat count as 1st argument. Omit argument to default to 2 repeats.
Japt, 1byte
My previous solution-with-bonus was invalid as I missed the requirement that input should default to 2. This is a stop-gap until I have a few minutes to come up with something better.
A
Output: 10
B-G would also work, outputting 11-16 respectively, as would H (32), I (64) & J (-1).
Slightly less trivial solutions include A³ (1000) and 8³² (262144), among many others.
RProgN 2, 8 - 25 = -17
2)i‘8*x*
Explained
2)i‘8*x* #
2 # Push two to the stack.
)i‘ # Create a stack from the registry stack, inverse it, and pop the top value. If an argument is provided, it will use that, otherwise, it will use 2.
8* # Multiply it by 8 (The length of the code)
x* # Multiplied by the string "x".
Pyth, 10 9 - 25 = -16
-1 by Dennis
**N9?zvz2
Prints [input]*9 quote characters, or 2*9 if the input is empty.
isaacg has a shorter answer here
Pyth, 1 byte
T
Prints 10. It's a built in variable that initializes to 10.
Windows Batch, 148 144 73 30 bytes
@echo %OS%%OS%%OS%%OS%%OS%%OS%
The %OS% system variable should be Windows_NT on most Windows NT systems.
6 of this %OS%(i.e. Windows_NT) is exactly 60 character, which is codeLength * 2.
Jq 1.5, 1 -9 -10 -1 bytes
range(inputs?//2)|23*"a"
Source is 24 bytes (-1 with bonus). Sample runs
Sample run with no input (defaults N=2)
$ jq -Mrn 'range(inputs?//2)|23*"a"' </dev/null
aaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaa
Confirm character count with no input (defaults N=2)
$ jq -Mrn 'range(inputs?//2)|23*"a"' </dev/null | wc -c
48
Sample run with N=4
$ jq -Mrn 'range(inputs?//2)|23*"a"' <<< "4" | wc -c
96
Verify length of program
$ echo -n 'range(inputs?//2)|23*"a"' </dev/null | wc -c
24
Jq 1.5, 1 byte
1
Sample Run
$ jq -Mnr 1
1
$ jq -Mnr 1 | wc -c
2
$ echo -n 1 | wc -c
1
Mathematica REPL, 1 byte
#
Prints #1.
VBA, 2 1 -3 20 - 25 = -5 Bytes
?Spc([Max(A1,2)*20])
Which outputs [A1] (analagous to n) else 1 times 22 (length of the code) spaces
Previous Version 1 Byte
?
Output
TI-BASIC, -20 bytes
10^(5Ans-1
As Julian Lachniet mentioned in a comment on his answer, TI-BASIC does not accept empty input, so I guess this is TECHNICALLY 5 bytes.
Note that 10^( is only one byte, as is Ans.
All this does is print a power of ten with 5Ans digits.
Ly, 17 - 25 = -8 bytes
"9>n[<&s&ol>1-]<;
A simple quine variant. Outputs 9>n[<&s&ol>1-]<; input times. (there's a tab at the end)
3 bytes, no bonus
"&|
Outputs:
38 124
Java 8, 16 15 bytes
Golfed a byte by using a for loop instead of a while loop. (back to where I was before :P)
u->{for(int x=0;++x<40*u;)out.print(1);}
Using a static import to reduce the code by 7 bytes, this prints out 1 40u times, where u is the integer taken from input. Since the program code is 40 bytes long and I incorporated the bonus, that leads me with 40 - 25 = 15 bytes.
TI-Basic, 2 bytes
::
(Ab)uses the fact that programs output Done when nothing is evaluated on the last line.
Python 2, 28 bytes
Quick and simple, also unimaginative.
This prints 1 14 times, separated by spaces, and a newline at the end.
for i in range(14):print 1,
Note: the newline in the code is required, otherwise it won't run.
QBIC, 16 - 25 = -9 36 - 25 = 11 32 - 25 = 7 bytes
:~a|q=a][q*4|?@ABCDEFGHIJKLMNOP
Explanation:
: Get a cmd line paramenter 'a'
~a| IF a <> 0 THEN
q=a] set q to the value of a
If we don't hit that IF-branch, q will be 1 by default in QBIC
[q*4| And execute the following 4 times for each 'a/q'
?@QBICFTW!IJKLMNOP Print this 16-byte string literal
The code is 16 bytes boilerplate and 16 bytes repeated output. Printing that output four times = 16x4 = 2x32 = double my source code length. And it accepts an input that does this N times.
Bash, 5 bytes
seq 5
Output (with a newline char on the end of each gives 10 bytes)...
1
2
3
4
5
><>, 15 + 2 (-v flag) - 25 = -8 bytes
2{f*:?!;0n1-30.
Explanation:
2{ puts 2 at the bottom of the stack. If no input was provided, this means it is at the top. Otherwise, the provided input will be at the top.
f* multiplies the input by 15 (the length of the program)
We then go into a loop: :?!;0n1-30.
:?!; ends the program if the counter is 0.
Otherwise, 0n prints 0, 1- decrements the counter, and then 30. goes back to the start of the loop.
Check, 14 - 25 = -11 bytes (non-competing)
.>2\&"?"*>14*o
Explanation:
.>2\& puts 2 at the back of the stack. If there were no arguments passed, this means 2 is at the top of the stack. Otherwise, the passed input is on top of the stack. We then repeat the character ? as many times as the stack number, and then repeat the result 14 times, and then output it.
bash, 11 bytes
Here's a pleasingly ironic usage of a data compression tool :) ...
gzip -f<<<2
Here's a hex dump of the output (22 bytes)...
0000000: 1f 8b 08 00 e3 ce 32 59 00 03 33 e2 02 00 90 af ......2Y..3.....
0000010: 7c 4c 02 00 00 00 |L....
Braingolf, 1 byte
Prints 0 and a newline.
l
Explanation
l
l push length of the stack to the stack
implicit output
implicit newline printed at end of program
Forth (gforth), 36 - 25 = 11 bytes
: x depth 0= if 2 then 36 * spaces ;
How it works:
Checks if no value is on the stack (depth 0=). If that is the case, push 2. Then just print n * 36 spaces.
Forth (gforth), 2 bytes
.S
Only works if the stack is empty. Prints <0> (<, 0, > and space)
Fourier, 12 - 25 = -13 bytes
Non competing: Fourier is newer than the challenge
I*12(1oi^~i)
Explanation pseudocode:
For i = 0 to (Input * 12)
Print 1
Pari/GP, 2 bytes
7!
Prints 5040 in the REPL.
REXX 33 Bytes -25 = 8
say copies("x",max(2,"0"arg(1))*33)
Powershell 4 Bytes
,1*8
This prints '1' 8 times in the console window.
05AB1E, 6 - 25 = -19 bytes (noncompeting)
VžOY×?
VžMY×? Argument n
V Assign n to Y, if n is empty Y defaults to 2
žO Push 'aeiouy' to stack (has same length as program)
Y× Repeat the string Y times
? Print top of stack without newline
PHP, 45 bytes
<?php print number_format(pow(10,66))."a"; ?>
output:
1,000,000,000,000,000,132,394,543,446,603,018,655,781,305,157,705,474,440,625,207,115,776a
<?php //PHP start tag
print //Prints what's ahead
number_format(arg) //format what's inside the parentheses as a number, with separators. (Used as escape function for having scientific notation result
pow(base,exp) //Gets the value of the `base` raised to the power of `exp`
. //Concatenation operator
"a" //String of "a"
?> //End tag for PHP
Fourier - Non-competing, 12 - 25 = -13 bytes
Fourier is newer than this challenge.
I*12(1ox^~x)
Works by multiplying the input by 12 (the length of the program) and outputting the number 1 that many times.
k, 2 bytes
This is one byte, but I don't like the answer because it doesn't feel "proper".
1
When run in oK as a file (as opposed to interactively) it prints out a newline after printing the 1.
Another sort-of cheating answer:
11
If run in the closed-source k interpreter, it would output 11 followed by a newline and a space (and it would expect the next command).
$1
This would result in ,"1" if trailing whitespace was not counted.
Excel,10 Bytes
=pi()&1234
prints 3.141592653589791234
J, 2 bytes
!7
Prints 7 fatorial, or 5040.
If you include the trailing newline then use:
!6
Which would print 720.
Alice, 10 bytes - 25 = -15
2/
&oi@/a*
Prints a 0x02 byte and 10n-1 null bytes when given an argument n, and simply 20 null bytes when no argument is given.
Explanation
2 Push 2 as the default input.
/ Reflect to SE. Switch to Ordinal.
i Read all input as a string. Pushes "" if no input is given.
Reflect off bottom boundary, move NE.
Reflect off top boundary, move SE.
/ Reflect to E. Switch to Cardinal
a Push 10, the length of the source code.
* Multiply. The first argument this pops is 10. But two pop another integer
argument, some implicit conversion needs to happen. If an input was given,
that string is popped and converted to an integer, which will be used as
the second argument. But if no input was given, the value "" contains no
integers, so it's discarded and Alice pops the next value instead (the
default value 2 we pushed earlier).
IP wraps around to the first column.
& Repeat the next command that many times.
o Pop that many values and print them as bytes.
i Try to read more input, irrelevant.
@ Terminate the program.
Some alternatives
Without the bonus, we can do this in 4 bytes, printing 8 null bytes:
8&o@
Simple enough. There's a really fun and 6 byte solution with readable output though:
/
O@n
This prints Jabberwocky with a trailing linefeed. The reason is that n is logical not, and the "canonical" truthy (non-empty) string used by Alice when applying this command to a falsy (empty) string is "Jabberwocky". So...
/ Reflect to SE. Switch to Ordinal.
n Logical NOT. Pops an implicit empty string from the stack and turns it into
"Jabberwocky".
Reflect off bottom right corner, move back NW.
/ Reflect to W. Switch to Cardinal.
IP wraps around to the last column.
/ Reflect to NW. Switch to Ordinal.
Reflect immediately off top boundary, move SW.
O Print "Jabberwocky" with a trailing linefeed.
Reflect off bottom left corner, move back NE.
/ Reflect to S. Switch to Cardinal.
@ Terminate the program.
Haskell, 25-25 = 0 bytes
f n=putStr$[1..25*n]>>"*"
prints n*25 Asterisks
ForceLang, 13 bytes
io.write 1e25
Processing, 31 29 bytes
for(int i=1;i++<34;)print(i);
I stumbled upon this submission from long ago and decided that it can be golfed more.
Outputs all the integers from 2 to 34 in a single line (58 bytes).
2345678910111213141516171819202122232425262728293031323334
Java - 132 - 25 = 107 bytes
interface o{static void main(String[]a){int i=2,k=0;if(a.length>0)i=Integer.parseInt(a[0]);for(;k<132*i;k++)System.out.print('X');}}
Takes one number(Supposed to be a number, NumberFormatException otherwise) and converts it to an integer, if no input is present, it defaults to 2.
Prints X characters.
Ungolfed version:
interface o {
static void main(String[] a) {
int i=2, k=0;
if (a.length > 0)
i = Integer.parseInt(a[0]);
for (; k < 132 * i; k++)
System.out.print('X');
}
}
[Non-Competing] C, 16
Code:
//score=16 bytes
Outputs: error: ld returned 1 exit status (32 bytes)
C, 27 25
main(){printf("%50f",0);}
•Thanks @Titus for knocking off 2 bytes
And for my non-competing 16 byte solution in C, go here: https://codegolf.stackexchange.com/a/111330/16513
^I say non-competing because the error code could possibly depend on your compiler, Also note I'm using GCC in that solution. Also I'm not certain if it breaks rule 1 or not, I think it probably does so I went ahead and labeled it non-competing
Pushy, 2 bytes
H#
Try it online! - this prints 100 followed by a trailing newline, 4 bytes of output.
H \ Push 100 to the stack
# \ Print with a trailing newline
PKod - 6 bytes
Code:
=0+ni6
Explanation:
=0 - Set variable as 0 (ascii code of 0 is 48, thus 48 is stored in the variable)
+n - Add 1 to variable (making it 49 on first iteration) and print ascii char code
i6 - 'i' kicks you back 2 blocks in code (to the '+' sign) until variable equals next char
which is '6'
Output:
495051525354
(note how it prints ascii char code from 1 to 6 (49 50 51 52 53 54) but without spaces.)
Ruby, 24 bytes (with bonus)
->m{m.to_i.times {49.times {print "a"}}}[gets||2]
Kitanai, 35 bytes
$0[70]#?(neq@0)([sub@1]print"!"&1)%
Just a simple loop to print 70 times the character "!".
PHP no bonus, 19 17 16 14 9 bytes
<?=99**9;
prints 913517247483640899
longer versions:
echo date(Mc);14 bytes print the first three letters of the month name followed by
an ISO-8601 formatted date (like2017-01-26T21:57:38-08:00- length=25)var_dump([01]);15 bytes printarray(1) {\n [0]=>\n int(1)\n}\necho decbin(~0);16 bytes print 32 ones (on a 32 bit machine)echo md5(12345);16 bytes print827ccb0eea8a706c4c34a16891f84e7b<?=str_pad(_,34);17 bytes print one underscore and 33 spaces.<?=decbin(2**33);17 bytes print a1and 33 zeroesprintf("%34d",0);17 bytes print 33 spaces and a0echo date(uuuuuu);18 bytes print 6*6 zeroes<?=date(uuuuYY);16 bytes print 6 zeroes four times and the current year twice
close but no cigar:
<?=pi();8 bytes print3.1415926535898(15 characters; 64 bit machine)<?=log(2);10 bytes print0.69314718055995(16 chars; 64 bit)<?=date(wc);12 bytes print 26 charsvar_dump(_.pi());17 bytes print 30 chars (64 bit)
PHP, 32 30 bytes -25 = 5
<?=str_pad(_,30*$argv[1]?:60);
prints an underscore, fills up with spaces
fancier, but longer (38 bytes):
<?=date(str_pad(r,3*$argv[1]?:6,MYr));
gives ("rMY" repeated N times) as argument to date(), which returns an RFC 2822 formatted date (e.g. Thu, 26 Jan 2017 23:32:31 -0800, length=31) followed by 3 letters of the month name and the 4 digit year - repeated N times. <?= prints the result.
Juggle, Non-competing, 8 bytes
Golfed: 1<4=a[p]
Ungolfed
1<4 <--- literal for 1 bit-shifted left 4 indices, equal to 16
=a <--- Set a equal to 16
[ <--- Iterate until a == 0
p <--- Print a new line
] <--- Decrement a by 1
This code effectively just outputs 16 \n characters, so there's not much to it.
TI-Basic, -2 bytes
:Input N
:".
:While N23>length(Ans
:Ans+".
:End
:Ans
Python 3, 20 bytes
print('#'*40,end='')
The optional argument end removes the newline. This is necessary due to universal newline support in Python which generates a \n on Linux and \r\n on Windows.
Recall, 17 bytes
................!
16 NOOPs. Then the debugger ! is invoked and dumps the memory to the console. The memory is empty, but the header is 34 bytes long:
-- STATE DUMP --
----------------
Try it here.
Java 8, 82 Bytes
interface A{static void main(String[]s){for(A a:new A[164])System.out.println();}}
Prints out 164 empty lines.
Scala, 52 - 25 = 27 bytes
object A extends App{println("#"*(args(0).toInt*52)}
Simply prints the string # repeated (arg * lengthOfCode) times.
Nim, 27 bytes
echo getStackTrace()[0..51]
Prints the first 53 bytes of the following, plus a trailing newline:
Traceback (most recent call last)
<filename>.nim(1) <filename>
Note that despite having the filename in the output, this answer's validity is not dependant on the length of the filename. For example, saved in x.nim, this is output:
Traceback (most recent call last)
x.nim(1)
There are nine trailing spaces there. Conversely, when saved in areallylongfilename.nim, this is output:
Traceback (most recent call last)
areallylongfilena
Newlines are also output in each example. Example usage:
$ nim c length.nim
$ ./length | wc -c
54
Cubix, 10 bytes
Cubix is a 2D esolang with a twist: the source code is wrapped around the outside of a cube.
>..(NU@?O/
Test it online! This maps to the following cube:
> .
. (
N U @ ? O / . .
. . . . . . . .
. .
. .
The output is
10998877665544332211
Don't even ask how it works... though if you'd like to watch it in action, run it here.
BASH, 19 bytes
54 bytes -25 bonus. Using the variable input for x repeats:
#!/bin/sh
a=$1;for i in `seq 1 ${a:=2}`;do cat $0;done
similar but more readable:
#!/bin/sh
a=$1
for i in `seq 1 ${a:=2}`; do
cat $0
done
19 bytes for a simple sh script.
#!/bin/sh
cat $0 $0
Python, 24-25= 0 -1 bytes
print'a'*int(input())*24
It takes input, converts it to an integer, multiplies it by 24 (the length of my code) and multiplies the character a by it
Thanks to @EamonOlive for reducing 1 byte
Brain-Flak, 128 bytes
Try it online!(You probably wont be able to finish it before the universe ends)
(((((((((((((()()()){}){}){}){}()){}){({}[()])}{}){({}[()])}{}){({}[()])}{}){({}[()])}{}){({}[()])}{}){({}[()])}{}){({}[()])}{})
How it works
It starts simply by pushing ninety-eight to the stack:
((((((()()()){}){}){}){}()){})
It then implements my Triangulation algorithm:
(*push n*{({}[()])}{})
seven times.
This results in
1447283887869053957595051227533274962011504066726596247765427442496031260270109555118382532157345193860142997726793245725173763195275989332247013823819162395404940274645651775376645319691872778284304403703355308050412897911161964450479105938633399903762942
The program then terminates and spits the contents of the stack to the terminal. Since insert atrociously huge number here is 256 characters long in base 10, the output is exactly twice the source code's length.
As one might tell I used a computer aided search to find this solution. This is almost certainly the shortest solution using the triangulation method I outlined.
V, 2 Bytes
4é
This outputs
ÿÿÿÿ
Explanation
This is a really hacky answer, and it works by abusing the internals of V. Essentially how it works is that ÿ is a command in V that signals the program is over, and any pending commands must complete. Otherwise, some implicit endings would not work, and the interpret would hang more often. This command is automatically sent several times at the end of the program, and most of the time has no effect on the output.
é is a command that inserts a single character. However, it does it by grabbing a raw byte, so it doesn't interpret ÿ as "end", it interprets it as "this is the character you need to insert." 4é makes it insert this character 4 times instead of one.
Perl5, 11 bytes
x is string repetition operator
print 1x22
Desmos, 3 bytes
9^6
Equals 531441
PD, 204 bytes
#N canvas 1 7 1 1 1;
#X obj 1 6 loadbang;
#X msg 1 1 \; pd quit;
#X obj 2 5 print;
#X obj 2 2 metro 10;
#X obj 1 7 del 340;
#X connect 0 0 3 0;
#X connect 0 0 4 0;
#X connect 3 0 2 0;
#X connect 4 0 1 0;
run with pd -nogui patchname.pd 2>&1. The program will print the String print: bang (12 bytes including the newline) every 10ms. Then the program terminates after 340ms which will result in the string being printed 34 times (34 * 12 = 408 Bytes output).
dc, 7 bytes
2oFddnf
2o Set the output radix to 2: write to stdout using the binary digits [01]
F Push 0xF on the stack, equivalent to 1111b
dd Duplicate the top-of-stack, then duplicate the top-of-stack: 1111b, 1111b, 1111b
n Pop the topmost item from the stack (1111b) and write it (using binary, per
the above) to stdout. Do not follow with a newline.
f Dump the contents of the stack (1111b, 1111b), following each item with a
newline.
Visible characters comprise 12 bytes; add two (2) newlines for a total of 14.
Edit: Since I'm the only dc answer with a natural number for a score, why not post the following?
dc, 8 bytes
cccccccP
Clears the stack seven times, then attempts to pop the top (non-existent) value and print it as text (i.e., a number with output-radix UCHAR_MAX+1). Since the stack is empty, this results in a fifteen-byte error message followed by a single newline. (Works for GNU dc 1.2)
APL, 3 bytes
1e5
Print 100000...
Java, 85
class A{public static void main(String[]s){for(A a:new A[170])System.out.println();}}
Tellurium, 10 bytes
µa~Åm16.
Outputs a 16 times. Simple enough.
More detailed explanation:
µ Begins reading a string
a
~ Stops reading a string and stores it in the selected cell
Å Command set 2
m Print the cell's value n times
16
.
There might be a shorter version using Åw but I'm too tired to do that :P
JavaScript, 2 bytes
f=(n=2)=>("f="+f).repeat(n)
- +27 bytes source code
- -25 bytes bonus
Batch, 17 bytes
@type %0 %0 2>nul
This one does not require a special locale (as the date solution does)
And it does not require %PATH% to be set. (No environment at all, for that matter)
2>nul is required to supress type to output the filenames on stderr (which it does when more than 1 file is printed)
Currently I couldn't conjure up a f(x)=x*N solution that is shorter than 17+25 bytes
This is the best I could come up with:
@if !%1 == ! (call %0 2) else (for /l %%x in (1,1,%1) do @type %0 2>nul)
Which has a score of (72-25) 45 bytes
PHP, 34 bytes - 25 = 9
$i=34*$argv[1];while($i--)echo"x";
34 bytes generating 34 * $argv[1] characters
2x version, 25 bytes
$i=50;while($i--)echo"x";
25 bytes generating 50 characters
Brian & Chuck, 9 bytes
{?
#.{-?
Try it online! There's a single unprintable \x12 (code point 18) before the first { which gets decremented each iteration, giving an output of 18 ?s.
Hexagony, 6 bytes
o!!!!@
Prints
111111111111
Explanation
Probably one of the simplest Hexagony programs I've written. The unfolded code is
o !
! ! !
@ .
and is simply executed in reading order. o sets the current memory edge to 111 (any letter from d to z would do). Then the ! print that four times and @ terminates the program.
I might try for the bonus later, but I have some doubts that it will fit in side-length 4 (and side-length 5 might end up costing more than the bonus gives).
Labyrinth, 10 bytes - 25 = -15
Another Labyrinth collaboration with Sp3000.
?02
`\
~"@
This prints 10n linefeeds to STDOUT.
Explanation
The most interesting part is probably how the default value of 2 is handled.
If an input number is given, the following code is executed:
? Read integer from STDIN.
0 Multiply by 10. This is because digits in Labyrinth work by multiplying the top of
the stack by 10 and then adding themselves, such that multi-digit numbers can be
written into the code more easily.
The top of the stack is now positive (and contains the number of characters to be
printed) so the instruction pointer (IP) turns right/south towards the \.
If no input number is given, ? pushes a 0 instead, and this happens:
? Push 0.
0 Multiply by 10, which is still 0. Since the top of the stack is now 0, the IP
keeps moving forward/east instead.
2 Multiply by 10, add 2, which sets the top of the stack to 2. The IP hits a
dead end so it turns around.
0 Multiply by 10 to give 20. Now the top of the stack is positive and IP
turns left/south towards the \. Again, the top of the stack is the number
of characters to be printed.
Now all we need to do is print one character each while decrementing the top of the stack to zero. The cheapest character to be printed in Labyrinth is a linefeed, because \ prints one without affecting the stack at all. As an additional trick, we decrement via multiply by -1, bitwise NOT, to ensure that the top of the stack is negative in the top left corner of the loop (otherwise the IP would move towards the ? again).
The loop is then simply:
\ Print linefeed.
` Multiply by -1.
~ Bitwise NOT.
" No-op. This cell acts a junction. While the top of the stack is positive
the IP will turn left/north, otherwise it will move forward/east.
When the IP leaves the loop it hits the @ which terminates the program.
For completeness, here are also two 7-byte versions without the bonus:
7:(
@`!
prints
-7-6-5-4-3-2-1
And
>11!:
@
prints
11001011111011
The former is a very simply (but compact) loop which prints -n while decrementing n from 7 down to 0.
The latter is a simple modification of Sp3000's solution to this challenge (which makes the execution a little bit crazier though).
Lua, 35 - 25 = 10 bytes
Takes input from the command line, which is in the varargs.
print(("n"):rep(35*(...or 2)-1))
Underload, 12 bytes
(\/)a:*::**S
Outputs
(\/)(\/)(\/)(\/)(\/)(\/)
Explanation
(\/) # push \/ to the stack : \/
a # add brackets to TOS : (\/)
:* # duplicate the TOS and join. : (\/)(\/)
:: # duplicate a couple of times : (\/)(\/)<>(\/)(\/)<>(\/)(\/)
** # join stack items : (\/)(\/)(\/)(\/)(\/)(\/)
S # output TOS
Pylongolf, 2 bytes
.;
. - Reset the stack
; - Debugally print both the stack and the variables.
The interpreter I use prints debugally by converting an 2 arrays into a string which has that string begin with [ and end with ] which prints:
[][]
J, 6 5 3 2 bytes (bonus: -11 bytes) (try it online)
Program:
%4
Output:
0.25
Explanation: The reciprocal of 4.
Bonus:
10,1$~_1+7*]/2
Testcases:
10,1$~_1+7*]/2 :10 1 1 1 1 1 1 1 1 1 1 1 1 1
10,1$~_1+7*]/2 2 :10 1 1 1 1 1 1 1 1 1 1 1 1 1
10,1$~_1+7*]/2 3 :10 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Explanation:
10, NB. prepend 10 to
1$~ NB. the "~" reverses the arguments.
NB. e.g. 1 $~ 5 becomes 5 $ 1.
NB. 5 $ 1 means create an array of size 5,
NB. using the number 1. The number is
NB. recycled because there is not enough number.
NB. For example, 5$1 2 3 would produce 1 2 3 1 2.
_1+ NB. add negative one to
7* NB. seven multiplied by
]/2 NB. if the input is 5, then this part
NB. becomes 2]5, which evaluates to 5.
NB. if there is no input, then this
NB. part is only 2.
3-byte attempt:
7^7
Output:
823543
Explanation:
7 raised to the power 7.
Notes: Looks like I am not the first one to discover this.
5-byte attempt:
Program:
*:i.5
Output:
0 1 4 9 16
Explanation:
*: means square. i.5 means generate a list from 0 to 4
6-byte attempt:
Program:
10,5$5
Output:
10 5 5 5 5 5
Explanation:
5$5 means create an array of size 5 (on the left of $), using the number 5 (on the right of $). The number is recycled because there is not enough number.
For example, 5$1 2 3 would produce 1 2 3 1 2.
Lua, 20 bytes (bonus: 11 bytes)
Program:
print(("a"):rep(40))
Output:
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
(Change 40 to 39 if newline is counted)
Bonus:
print(("a"):rep(36*(io.read()or 2)))
(If newline is counted, use print(("a"):rep(38*(io.read()or 2)-1)) [13 bytes] instead.)
Cubix, 15 bytes
Non competing due to language age.
While having some fun with @ETHproductions language, I thought this would be interesting. It turned out a little longer than I thought it would and I'm sure it can be improved.
(.O.NU.\!@O$..u
This maps to a cube with edge length 2
( .
O .
N U . \ ! @ O $
. . u . . . . .
. .
. .
Outputs
109998887776665554443332221110
N push 10 to the stack
U turn left moved forward turn left
O output number of TOS
$ skip a no op
( decrement TOS, followed by a number of no ops
u turn right, move forward and turn right, more no ops
O output number of TOS, more no ops
\ reflect to the east
! jump end program @ if truthy
O output number of TOS
$ skip N at start of program
Fuzzy Octo Guacamole, 8 bytes
42*![o;]
Also could use:
8 ![o;]
Or
81*![o;]
But that is cooler.
Prints 8 "8"s and 8 newlines, including a trailing one.
Explanation:
4: Push 4 to the stack.
2: Push 2 to the stack.
*: Pop and multiply the top 2 items on the stack and push the result (8)
!: Set the loop counter to the top. Is now 8.
[: Start a loop that lasts 'loopcounter' (8) iterations.
o: Peek at the top of the stack and push it to the temp variable.
;: Print the temp var.
]: End the loop.
Python 2, 11 bytes
print`0`*21
This outputs 21 zeroes and a newline.
000000000000000000000
From the Python 2 documentation:
A
'\n'character is written at the end, unless the print statement ends with a comma.
Z80 machine code, 16 bytes
3E 1F 0E 02 1E 2A F5 CD 05 00 F1 3D F2 02 01 C7
This was made on an Osborne Executive running CP/M version 3.0 using SID. Here is a disassembly (with comments following # characters for readability)
MVI A,1F # Set register A equal to 0x1F (iterations-1)
MVI C,2 # Write is BDOS call 2 (CP/M's system calls)
MVI E,2a # I'm writing '*' as output. Its ASCII value is 0x2a
PUSH PSW # Push operates on register pairs. This pair contains A.
CALL 5 # Do the BDOS call (which destroys some registers)
POP PSW # But we can get A back from the stack.
DCR A # Decrement the loop counter
JP 102 # If last result is non-negative, go to address 0x102
RST 0 # Otherwise, exit
All programs are loaded at a fixed address of 0x100, so the jump to 0x102 is well-defined. After running this, CP/M wants to print a newline character. If we count that as output from the program, change the second byte from 1F to 1E.
Gogh, 3 bytes
6GJ
You can run it like this:
./gogh o '6GJ'
Or without implicit output (4 bytes):
8GJ¡
You can run this using:
./gogh "" "8GJ¡"
The inverted exclamation point outputs the TOS.
Explanation
6 “ Push the integer literal 6 ”
G “ Push a range (0, TOS] ”
J “ Join the TOS ”
Mathematica, 9 bytes
Echo[16!]
If I am correct, this should output:
>> 20922789888000
with a trailing newline.
Perl 5, 16 bytes - 25 = -9
$_ =$]x($_*2||4)
This is an oddball approach to the problem.
Run with the -p command line argument.
I saw a Perl answer below that used a special variable to print more text - and thus shorten their byte count. So I used a much more verbose special variable. It prints 8 characters with a 2 character variable name. Thus, with a byte count of 16 (padded with one whitespace character to make it 16), it prints 2 * $], where $] is the Perl version printed as 5.xxxxxx, dependent upon your Perl version. Without input it prints it four times, equaling 8*4 or 32, which is double the byte count of the code.
I love Perl.
Mumps, 31 - 25 = 6 bytes
My submission was supposed to be unique (but I hadn't checked all of the answers yet) in that the basic "Assume 2x" code and the bonus-enabled code would work out to be the same length!
Basic code:
F J=1:1:28 W 1
Which is 14 bytes.
Here's the initial bonus-enabled code that takes input, anything that equates to '0' including any non-numeric input assumes 2, then outputs the correct number of output characters. This version is 39 bytes not including the bonus.
R I S:+I=0 I=2 F I=1:1:I F J=1:1:39 W 1
Calculating the bonus 39-25=14 bytes as well!
Too bad (for my narrative) that I looked it over and came up with a shorter version of the bonus code:
R I S:+I=0 I=2 F I=1:1:I*31 W 1
This is only 31 bytes long, so 31-25=6 bytes total, and the header reflects this.
PlatyPar, 1 byte
#
# starts a number, but since no number is found after it, it is substituted with 59.
Here's a "real" answer:
77^
Prints the result of 7^7, or 823543, which is of length 6.
Binary-Encoded Golfical, 13+1 (-x flag)=14 bytes
Noncompeting, language postdates the question.
Hexdump:
00 90 01 00 09 17 17 17 17 17 17 17 1D
This encoding can be converted back into the original graphical representation using the included Encoder utility, or run directly by adding the x flag.
Original image:

Magnified 64x, with color labels:

Explanation: Stores 9, prints it seven times (with a newline each time), then turns around and prints it seven more times.
MATLAB, 5 bytes
a=123
Which displays
a =
123
By my count that is 10 bytes of output if you include the new-line as 1 byte.
Python 2, 11 -1 -6 -11 bytes
'M'*input()*14
Prints 14 * input Ms. Requires a REPL environment.
There may be a way to make it shorter, but at this point I doubt it.
Changes
- Saved 5 bytes by not using
int(). - Saves 5 more bytes thanks to @cat and using a REPL environment.
SWI-Prolog, 3 bytes
nl.
This outputs:
\n
true.
(the \n is printed as an actual linefeed, not the two characters).
Perl, 11 bytes
print"J"x22
Using the lovely x operator, prints 22 Js.
I may be able to find a shorter answer.
Note: This answer did not work when the question was asked, so it is not a competitive solution.
Pyth, 6 - 25 = -19 bytes
mb.xE2
First, we attempt to take STDIN input and evaluate it. It this throws an error, we use 2 instead. Then, we make a list of that many newline characters. Newline characters take 4 characters to represent ('\n') and there are 2 bytes of list overhead ([] or ,) per element, so it comes out to exactly 6 times longer than the above number.
Sass, 30 bytes
codegolf is absolutely awesome
if you try to compile this with sass the result is the following error
Invalid CSS after "...olutely awesome": expected "{", was ""
/* 60 bytes */
Mouse-2002, 32 - 25 = 7 bytes
A quine is not possible in Mouse, unfortunately, else I would have gone that way.
?&DUP 0=[1]32*y:(y.x.>^1!x.1+x:)
Explained:
? &DUP ~ get some input; dup it
0 = ~ if 0
[ ~ then
2 ~ push 2 instead
] ~ fi
32 * y: ~ push 32* and assign into y
( ~ while(true)
y. x. > ^ ~ cmp
1 ! ~ print a 1
x. 1 + x: ~ increment x
) ~ endwhile
$ ~ (implicit) end prog
Perl 6, 3 points
say 'a'x 21 # 11
# say adds a newline
print 'a'x 28*(@*ARGS[0]//2)
# 28 - 25 = 3
Python, 15 bytes
print 'aaaaa'*6
Prints:
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
Which is 30 bytes.
JavaScript (ES5), 68 bytes - 25 bonus = 43
alert(Array(1+(+prompt()||2)).join(document.scripts[0].textContent))
(in case your browser won't allow for the snippet to run for security reasons, try this fiddle http://jsfiddle.net/thePivottt/c3v20c9g/ )
This script only works in a browser following at least DOM3 (with Node.textContent) and ECMAScript 5 (or perhaps an older version). I tried to make is as standard conforming and compatible as possible. It also assumes that the script is in the first script element of the document.
It actually concatenates multiple copies of the script itself, which is pretty awesome. Note that the snippet tool on SE puts extra whitespace around the script. We could ignore that whitespace with .trim() but I don't find it necessary considering the program is perfect without SE's meddling. Just save this HTML5 file if you want to see it run perfectly.
<!DOCTYPE html>
<html>
<head>
<title>Minimalist HTML5 page</title>
<script>alert(Array(1+(+prompt()||2)).join(document.scripts[0].textContent))</script>
</head>
</html>
This script uses prompt and alert because console.log is not part of any standard, even if most modern browsers use it. If the number of repetitions passed is not a valid number or is empty, it defaults to 2. If the input is a decimal number, the program crashes due the the invalid array length.
The code uses a few interesting features of JavaScript:
Array(1+(+prompt()||2))Array(INT)creates an Array of INT cells.+prompt()takes an input and turns it into a number. If we passed the input as a string, theArrayfunction would simply wrap it in a one-element array.+prompt()||2returns the input if it is truthy, else it returns 2.This whole code creates an array of N empty elements, where N is one more than the amount of repetitions asked.
.join(document.scripts[0].textContent)The array's
join(STRING)method creates a string by concatenating all the cells, putting the provided STRING between values. In this program, there are N+1 empty elements in the array, or exactly N in-between spots. The result will be a string containing N times the provided STRING.document.scripts[o]is the first<script>element of the document.The
textContentofNodeinstances returns the whole text found inside them and their child nodes, including scripts.
CJam, -17 bytes
r2e|i8,*
The source code is 8 bytes long and qualifies for the -25 bytes bonus.
Try it online in the CJam interpreter.
How it works
r e# Read a token from STDIN.
2 e# Push 2.
e| e# Logical OR; keep the token if it's not empty, 2 otherwise.
i e# Cast to integer.
8, e# Push [0 1 2 3 4 5 6 7].
* e# Repeat the array the corresponding number of times.
Common Lisp REPL, 9
(write -)
- is a variable that holds the currently evaluating expression in the REPL, while write returns whatever it writes. So it writes (write -) then returns "(write -)" which is printed by the REPL without the quotes. (If this was done in an REL instead of an REPL, then it'd be a quine instead.)
Minkolang 0.9, 11-25 = -14 bytes
This language was created after this challenge, but not for it.
nd1+?2["d].
Explanation
This takes an integer from input, pushing a 2 on the stack if it's -1 (i.e., the input is empty). Then I use the clever quine trick: the " pushes the whole program (except the ") onto the stack. To make up for the ", I duplicate the top of stack with d. This is printed out n or 2 times and then the program stops. In the case where there is no input, there is indeed a -1 on the stack. However, Minkolang outputs nothing for negative numbers, so it does not add anything.
Vitsy, 14 11 - 25 = -14 Bytes
Note: This language was made after this question was asked, but it was not created for this task.
2a{b*\[DO];
I'm pretty sure this can be golfed down a little more, but here you go:
2a{b*\[DO];
2 Push 2 to the stack as the backup value - if input is pushed, then it will already exist in the stack.
a Push "\n" (the literal) to the stack as an integer - this will be our output.
{ Rotate the stack to the left
b* Multiply the top value (used to be the back-most (2 or input) value) by 11.
\[..] Repeat as many times as the top item of the stack specifies for all instructions within []
DO Duplicate the top value, then output it.
; End execution.
Burlesque - 7 Bytes
blsq ) '*14.*Q
**************
It just prints 14 asteriks, while the length of the program is 7 bytes. As for the bonus:
ri12.*'*j.*Q
is 12 bytes long and prints 12*n (number provided on STDIN) asteriks.
Simplex v.0.5, 22 - 25 = -3 bytes
i?[{u(' R)22vM}ug#]2O3
i ~~ take input as number
?[ ] ~~ do inside if byte is nonzero
{ } ~~ loop inside until zero byte met
u v ~~ up/down strip traversal
( )22 ~~ repeats the inner 22 times
'@R ~~ pushes an @ and goes right
ug ~~ goes to the string strip and clears the strip
# ~~ cease!
2 ~~ sets the current byte to two (default N)
O3 ~~ goes to the third byte in the source code
Essentially, for each pass of an integer N (input), the string @@@@@@@@@@@@@@@@@@@@@@ is printed once, i.e., N*"@@@@@@@@@@@@@@@@@@@@@@". Since the (...) is a preproccesed command, variable inputs cannot be handled. If they could, then I might shorten the code to something like ('@R)ig whilst handling the special cases. Wouldn't that be something?
Hassium, 55 Bytes
use Math;func main(){ for(x=0;x<7;x++)print(Math.pi); }
Output:
3.141592653589793.141592653589793.141592653589793.141592653589793.141592653589793.141592653589793.14159265358979
Run and see online here
[this is a sticky note] This answer has multiple versions.
Due to the fact that I honestly am not quite sure what "input" means here. The first is the one I would use to score myself. Go down to the second to find an explanation. For scoring 1 point, do I tie with the Matmematica one? Or for scoring -1 (-5?) points, do I win? Hmm.
Anywho, this was quite a fun challenge. Maybe I can make my answer a bit better but anyways.
Python 2.7, 26 - 25 = 1
If input means input from stdin:
print("|"*26*input())[:-1]
Python 2.7, 24 - 25 = -1
If input means a variable:
n=2;print("|"*24*n)[:-1]
Wuut?
n=2 # Set a variable n to 2
; # Separate statements (like a line break)
print # Print..
( # This is in 2.7, not 3, where print is a
# statement, not function
"|" # Any character works here
*24 # Multiply said character by 24
*n # Multiply resulting string by n
)
[:-1] # Remove one character due to the line break
# automatically created by print.
Python 2.7, 20 - 25 = -5.
If input means a variable, and you don't count n=2; as part of the program:
Simply change 24 to 20:
print("|"*20*n)[:-1]
Go, 59 Bytes
package main
import"fmt"
func main(){fmt.Printf("%118d",0)}
Prints 0 formatted with padding
Here is a version with argument (145-25 Bytes):
package main
import("os"
"fmt")
func main(){i:=2
if len(os.Args)>1{fmt.Sscanf(os.Args[1],"%d",&i)}
fmt.Printf("%"+fmt.Sprintf("%d",i*145)+"d",i)}
APL, -8 bytes
'*'⍴⍨17×{0::2⋄⎕}⍬
Explanation:
{0::2⋄⎕}⍬: Try to read a number from the keyboard. If the user entered a valid number, return it; if not, return2.17×: multiply it by 17 (the length of the code)'*'⍴⍨: output that many asterisks.
Pyth, 4 bytes
*8"1
will print out
11111111
CJam, 1 byte
A
Prints 10. Very straightforward.
Javascript, 3 bytes!
1e5
Returns 100000. Y'all JS golfers are overthinking it!
R, 3 2 bytes
Code
!0 # NOT FALSE
Outputs
TRUE
Wow, finally R, finally.
It seems that {} work too, it outputs NULL
Bonus 33 16 bytes:
Code
rep(1,number*16)
Outputs
# if number is not defined
> rep(1,number*16)
> Error: object 'number' not found # output is 32 (or 2*16) bytes long error
# if number is defined
> number = 3
> rep(1,number*16) # output is 16*number bytes long
> 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
JavaScript, 2 bytes!
Even shorter than the 3 bytes solution:
!0
Returns true after running.
Retina, 25 24 - 25 = -1 bytes
^$
11
1
11111111!
&!`111
Use the -s flag to run the code from a single file. Input is in unary.
For reference, without the bonus, there's a 1-byte solution:
!
Really any single character would do, so long as it's a valid regex (so an unmatched parenthesis wouldn't). This will just print the number of matches (zero in this case) followed by a newline, which makes two bytes.
Explanation
A translation of the sed answer, requires 25 bytes (computed as 5x5) instead of 40 (see revision history). However, we can do better in Retina:
First, we default the input to (unary) 2 if it's empty with:
^$
11
Now we turn each 1 into eight 1s and an exclamation mark with:
1
11111111!
What we ultimately want is to print 24 bytes for each of those chunks. The idea is to get a "free" multiplication by using Match mode's options to a) print all matches and b) consider overlapping matches. We also note that each match is terminated by a linefeed. So if each match is 3 bytes, we'll get 4 bytes per line, and need 6 lines. How many possible 3-byte matches are there in a string of 8 ones?
11111111
111
111
111
111
111
111
Six. How convenient :). So we the final stage is simply:
&!`111
Which means that for each unit of source code length requested, we print:
111
111
111
111
111
111
with a trailing newline, which is exactly 24 bytes.
Note that this is why we needed to append the exclamation mark to each line: it ensures that we don't get additional matches which are shared between chunks.
POSIX bc, 4 bytes
10^7
This creates the output 10000000.
C#, 77 bytes
102 bytes - 25 bonus
class c{static void Main(string[]a)=>System.Console.Write(new string('x',102*int.Parse(a[0]??"2")));}
Creates a string of the specified length, defaulting to 2.
Funciton, 78 bytes
Not very advanced. Just output 156 As. Of course you can change 65 to any two-digit ASCII code. If non-printable characters are allowed as well, you could shorten it by 6 bytes by outputting character #1 144 times.
╔═══╗┌─╖╔══╗
║156╟┤…╟╢65║
╚═══╝╘╤╝╚══╝
Python 2.7, 26 24 - 25 = -1 byte
def s(c=2):print'A'*24*c
24 characters long, prints twice its length on no input:
>>> s()
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
prints n*length for any other input:
>>> s(1)
AAAAAAAAAAAAAAAAAAAAAAAA
>>> s(3)
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
T-SQL, 16 bytes
SELECT SPACE(32)
This returns a string of 32 spaces. Can't think of anything fancier at the minute.
Python 3, 30 - 25 = 5
print(int(input()or 2)*30*"X")
It expects input on standard input, an empty input is treated the same as 2.
If we can use the REPL, rather than running as a script, you can remove the print call, to save 7 bytes and bring our score down to -2:
>>> int(input()or 2)*21*"X"
1
'XXXXXXXXXXXXXXXXXXXXX'
(Note that we multiply by 21, rather than 23 because of the quotation marks that appear in the string's repr.)
A Python 2 version of the same code can be written for three extra bytes (we need to add raw_ to the input, but can replace the pair of parentheses around print's arguments with a single space):
print int(raw_input()or 2)*33*"X"
Python 2, 11 bytes
print 9**21
displays 109418989131512359209\n (22 chars)
Bash + GNU coreutils, 26 24 - 25 = 1 -1 byte
The x file:
yes|head -c$[24*${1:-2}]
(no trailing newline)
Running:
$ bash x 1 | wc -c
24
$ bash x | wc -c
48
$ bash x 3 | wc -c
72
Old version with 26 bytes:
The x file:
yes|head -c$((26*${1:-2}))
(no trailing newline)
Bash + GNU coreutils, -1 byte
printf %24s `seq ${1-2}`
Score is 24-25
A non-bonus version for +5:
seq 5
which produces 1 nl 2 nl 3 nl 4 nl 5 nl.
Sed, 40 - bonus = 15
s/^$/11/
s/.*/&&&&&/
s//&&&&&&&&/
s/.//
There's no final newline. Input is in unary, as you'd expect for sed.
We begin by defaulting the input to two. Then we multiply it by 5 and then by 8 for a total multiplication of 40. Our output includes a newline, so we must subtract one before it's printed.
Test results
$ for i in '' 1 11 111 1111; do sed -e 's/^$/11/;s/.*/&&&&&/;s//&&&&&&&&/;s/.//' <<<"$i" | wc -c; done
80
40
80
120
160
DOS, 7 bytes
date /t
outputs di 06-10-2015 (and a newline) on my system, but I'll admit it's locale dependent. So my second best is:
echo %PATH:~0,33%
which outputs C:\WINDOWS\system32;C:\WINDOWS;C: (and a newline).
Seed, 10 bytes
4 56111240
This compiles to the Befunge program (found by brute force)
9k.@
which produces the following 20 bytes when run (tested in CCBI, note the trailing space):
0 0 0 0 0 0 0 0 0 0
Being unfamiliar with Befunge 98, I had to double check the spec a few times for this one:
kseems pretty broken to me, executing one more time than intended due to the IP moving into the repeated instruction- Befunge 98's stacks have infinite zeroes at the bottom
.outputs as a number, followed by a space
><>, 19 + 2 (-v flag) - 25 = -4 bytes
l?!2f4+*v
-1o;!?::<
Thanks Cole and Sp3000
First checks the stack length, if it's 0 put 2 on the stack. Multiplies it by 21 (code length), then outputs the unicode representation of that number and decrements it by 1, loops until 0. (you'll have to inspect the output to see the characters, since the browser won't display them)
Self-modifying Brainfuck, 31 - 25 = 6 bytes
Checking for no input is a hassle...
>,>+<[>-]>[<++>->]<<[<<[.<]>>-]
Explanation:
See the If(x==0) algorithm I used (the one by Ben-Arba).
>, Take a byte of input x
>+<[>-]>[<++>->]<< If x == 0 (no input), x++ (add 2 :D)
[<<[.<]>>-] Print the program's source code in reverse x times
Without the bonus (10 bytes):
<[.<]>[.>]
Wishful thinking:
If we didn't have to default the input to two (13 - 25 = -12 bytes):
>,[<<[.<]>>-]
Shakespeare, 768
Yeah, Shakespeare's not much of a golfing language. Outputs 1,536 spaces.
Rosencrantz and Guildenstern: A Series of Tedious Events.
Rosencrantz, a count of extraordinary determination.
Guildenstern, a spacy character.
Act I: The Long Conversation
Scene I: A Tortured Friendship
[Enter Rosencrantz and Guildenstern]
Rosencrantz:
You are a gentle, noble, valiant, loyal, loving companion.
Guildenstern:
You are nothing!
Scene II: Asking the Hard Questions
Rosencrantz:
Speak your mind.
Guildenstern:
You are as fair as the sum of yourself and a daisy. Are you as
daring as the sum of a big, bold, fiery, feisty, rough, rowdy,
ham-fisted, hawk-eyed, broad-shouldered, bright-eyed lad and a
large, yellow, vicious, hairy, wild, scary, long-tailed,
sharp-clawed, small-eared lion?
Rosencrantz:
If not, let us return to scene II.
Edit: 256
Okay, I'll actually golf it. Note that the above does not compile in any existing Shakespeare implementation because I wrote it painstakingly by hand (but am prepared to defend its correctness.)
The below translates to C with one warning in spl-1.2.1, and outputs 512 spaces:
Ummm.Ajax,1.Puck,2.Act I:I.Scene I:A.[Enter Ajax and Puck]Ajax:You old old old old old cow.Puck:You are zero!Scene II:B.Ajax:Speak thy mind.Puck:You are the sum of you and a red cat.Are you as big as the square of me?Ajax:If not, let us return to scene II.
C, 82 bytes (with bonus)
main(int a,char**b){b&&b[1]&&(a=atoi(b[1])-1);a&&main(a-1,0),printf("%.80f",.0);}
Usage:
$ wc main.c
1 2 82
$ ./a.out | wc
0 1 164
$ ./a.out 4 | wc
0 1 138
$ ./a.out 133475 | wc
0 1 10944950
MUMPS, 4 bytes
w ?8
Well, I'm not sure if this really counts. What this program does is advance the output cursor 8 characters to the right. On every terminal I've used, this is indistinguishable from outputting 8 spaces, but is it really the same thing? I dunno.
Powershell, -10
"a"*15*$args[0]
Powershell, 2
This answer without the bonus is probably golfier though
$?
Outputs;
True
Brainfuck, 14 bytes
+++++++[....-]
This is a little mathematical exercise. Let's denote the number of + characters in the code by a, and the number of . characters by b.
The code outputs a*b bytes, with values from a down to 1 (these are non-ASCII bytes, but it seems OK according to the spec). The code's length is a+b+3. So we have
a*b = 2 * (a+b+3)
Trying different values for a and b, we see that the minimum for a+b+3 is achieved for
a = 4 or a = 7
b = 7 b = 4
Insomnia, 1
7
Output:
00
8, A, B are 3 other programs that satisfy the requirement. Their output contains NUL characters, though.
Julia, 9
warn(⊆)
prints
"WARNING: issubset\n"
QBasic, 2 bytes
?1
Nonnegative numbers in QBasic are output with both a leading and a trailing space. The PRINT command (for which ? is a shortcut) outputs a newline by default. Thus, I count 4 bytes of output: space 1 space newline.
R, 3 bytes
10;
will print
[1] 10
C, 23 (without bonus)
main(){printf("%46d");}
Outputs an uninitialized value, padded by spaces to 46 bytes. Trying to do it with a bonus, I arrived to a tie. I don't know whether it's unfortunate or cool.
C, 23 (with bonus)
main(x){printf("%*d",(~scanf("%d",&x)?x:2)*48);}
The code has 48 bytes. I use bit-complement ~ to check whether scanf returned -1.
Brainfuck, 25 bytes
Prints 50 characters, most of which are control characters.
+++++++[>+++++++<-]>+[.-]
TI-BASIC, 1 byte
0
Output:
0 ;there is a newline; counts as char
Thanks to Thomas Kwa for his spectacular observation. The i/o looks as thus:
0
0 ;right-aligned, but newline is part of output.
GolfScript, 11 - 25 = -14 bytes
~2]0=11*(n*
Given n, outputs n times as many newlines as the length of the code in bytes (= 11). Given no (i.e. empty) input, outputs 22 newlines.
The implementation is very straightforward:
~evals the input,2]0=replaces an empty input with 2,11*multiplies the input number with 11 (the length of the program),(decrements the number by 1 (to account for the automatically inserted trailing newline), andn*repeats a newline the given number of times.
JavaScript (ES6), 24 30 - 25 = 5 bytes
alert('s'.repeat(30*prompt()))
Ruby, 5 bytes
p 1e6
Outputs 1000000.0 and a newline, which is 10 bytes in summary
Haskell, 19 bytes
main=print[92..102]
Outputs: [92,93,94,95,96,97,98,99,100,101,102] and a NL.
><>, (15 + 3) - 25 = -7
2}f*:?!;1n1-30.
Like torcado's answer, but a one-liner. Takes input via the -v flag, e.g.
py -3 fish.py double.fish -v 5
and outputs 15*<input> ones.
><>, 5 bytes
"nn#;
Here's a version without any bonuses. Outputs 5935110110.
GolfScript, 1 byte
1
At the end of a GolfScript program, the interpreter outputs everything that's on the stack, and a trailing newline. So the output of the above program is 1 with a trailing newline, two bytes.
C, 25
main(){printf("%*p",50);}
This makes use of UB, but it should work. At least it works with gcc 5.2.0
Ruby, 22 bytes - 25 bytes = -3 bytes
c=->n=2{p ?d*21*n}
c[]
The reason the value shows up as 21 bytes in the code itself is that the quotation marks are printed, effectively reducing the number of bytes I need to print by 2 (left paren and right paren).
C#, 63 62 bytes
class P{static void Main(){System.Console.Write($"{1,124}");}}
Will print 123 spaces followed by 1.
Pyth, 8 - 25 = -17 bytes
mU2?zvz2
Note: This only works in the online compiler, because it removes the trailng newline.
Output form:
[[0, 1], [0, 1], [0, 1]]
Element, 16 bytes - 25 bonus = -9
_2:1<[2]16*'[X`]
Explanation:
_2:1<[2]16*'[X`]
_ take input
2: duplicate it
1< test "if less than one" (like an empty input)
[2] FOR/IF push 2 if true
16* multiply by 16
' move result to control stack
[ ] FOR
X` output the letter X
Element, 6 bytes
9 12^`
prints 282429536481
Explanation:
9 push 9
12^ to the twelfth power
` output
PHP 7, 9 Bytes
<?=str_repeat(1,($argv[1]??2)*34);
Uses the short opening tag with echo <?= and the null coalesce operator ?? which falls back to 2 if $argv[1] is not set, without throwing an error.
TI-Basic, 3 bytes
1ᴇ5
Prints 100000.
Pyth, 6 bytes
*4"aaa
Explanation:
*4"aaa
-------+------------
"aaa | Print "aaa"
*4 | 4 times
Pyth, -7 bytes
*.xvw2*2"aaaaaaaaa
Plain and simple.
*.xvw2*2"aaaaaaaaa
-------------------+----------------------
*2"aaaaaaaaa | Print twice the "a"s
* | times
.xvw | try to evaluate input
2 | otherwise, 2
dc, 10 - 25 = -15
2?A*Ar^1-n
Takes a blank line for "no input".
Calculates 10 ^ (10 * n) - 1, where n is the input, or 2 if input is empty. Prints a string of 9s of the required length.
2push 2 to the stack in case input is empty?push input to the stackApush 10 to the stack (dc has shortcutsA-Ffor 10 - 15)*pop twice and multiply (multiply input by 10)Apush 10 to the stackrreverse top two stack elements^exponentiate 10 ^ (10 * input)1-subtract 1 from the top of stacknprint with no newline.
Stuck, -13 Bytes
i_0>;2?12*N*
This prints a bunch of newlines (N). Empty input is considered to be 0 (or anything less than 0). So, if 4 was given, it will print 48 newlines.
Old Answer - 3 Bytes
6Rj
will output
123456
Will be giving the bonus a shot.
CJam, -9
q_,{i}{;2}?G*'X*
Explanation
q_,
Reads the entire input and pushes it, then pushes the length.
{i}{;2}?
If the length of the input is over zero, convert it to an integer. Otherwise, pop the input and push 2.
G*
Pushes 16 (the program length), then multiplies it by 2 if there is no input, or by the input.
'X*
Pushes X and multiplies it by the top of the stack.
Python 3.4, 14 13 bytes
print("a"*26)
JavaScript (ES6), 50-25=25
a=prompt();alert("0".repeat(48*(isNaN(a|0)?2:+a)))
gs2, -18 bytes
CP437: W↕0!↨.2
Hex dump: 57 12 30 21 17 2e 32
W reads numbers from STDIN into a list. ↕0 appends a 2 to the list, and ! extracts the first element. Then ↨. (the list [0,1,2,3,4,5,6]) is repeated (2) this many times.
This is very similar to Dennis's CJam answer -- gs2 just combines r and i into one byte.
Note: I had to fix a bug in the gs2 implementation for this to work: previously, each program had a hidden newline appended to its output, which was entirely unintentional. It only surfaced after I tried to solve this program (the language was designed for anarchy golf, which ignores trailing newlines in all problems), and I only pushed a fix to master just now, so feel free to take this answer with a grain of salt.
JavaScript (ES6), 23 bytes - 25 = -2
(n=2)=>'x'.repeat(23*n)
Just for fun here's a quine version with a score of 27 bytes -25 =2
a=(n=2)=>`a=${a}`.repeat(n)
Perl, 10 9 bytes
Uses @primo's suggestion of $=.
print$=x9
$= is a shortcut for $FORMAT_LINES_PER_PAGE, which defaults to 60.
Example:
$ cat doubler.pl
print$=x9
$ perl doubler.pl
606060606060606060
Perl, 18 - 25 = -7
print$=x(<>*9||18)
The special variable $=, a.k.a. $FORMAT_LINES_PER_PAGE, begins its life as 60, and therefore only needs to be duplicated half as many times as byte output needed.
Befunge-98, 26-25=1
&:#v_v>1.1-v
*d2<2<^_@#:<*
Run it in this interpreter. Apparently, it can't take input.
Befunge-93, 30 - 25 = 5 27-25=2
&:#v_v>1.1-v
*93<2<^_@#:<*
There is a trailing space on the first line, and this is done because it's shorter to make 27 than it is to make 26 with Befunge-93. This outputs 27*n 1s in a row.
awk, 29 - 25 = 4 bytes
{printf"%0"($0?$0:2)*29"d",0}
Prints the wanted number of zeros.
C#, 104 bytes (79 point with bonus)
class a{static void Main(string[] p){System.Console.Write(new System.String('1',104*int.Parse(p[0])));}}
you can run the program by using an argument for example test.exe 2 prints 208 character '1'
q, 10 3 bytes
3#0
Outputs 6 bytes: "0 0 0\n".
q (bonus), 27 bytes
1#[;"x"]27*2^first"J"$.z.x;
C++, 80 bytes
#include<iostream>
int main(){int i=0;while(i<20){std::cout<<&i;i++;}return 0;}
note the newline character is two characters. (if you don't want it to be, change i<20 to i<=19 to get back to the same byte count.)
Sample output (will change every time)
0088FA0C0088FA0C0088FA0C0088FA0C0088FA0C0088FA0C0088FA0C0088FA0C0088FA0C0088FA0C0088FA0C0088FA0C0088FA0C0088FA0C0088FA0C0088FA0C0088FA0C0088FA0C0088FA0C0088FA0C
same 8 character memory address 20 times.
Macaroni 0.0.2, 23 chars
print tobase pow 32 9 2
Prints 329 in binary, which happens to conveniently turn out to be 46 characters long (it's 1000000000000000000000000000000000000000000000), without a trailing newline.
Microscript, 1
0
Prints the digit 0, followed by a newline.
Python 2.6, 10
print`-.1`
Prints -0.10000000000000001, which is 20 chars.
Note that the string repr shows more precision. print-.1 just gives -.1, and print.1/3 gives 0.0333333333333 for only 13 digits of accuracy.
Python 2, 11
print`id`*1
Print the string representation of the built-in id, which is 22 chars:
<built-in function id>
The *1 is to get the code to 11 chars. You could also do print id;00.
More boring alternative 11's are:
print'1'*22
print 9**21
dc, 19 - 25 = -6
2?19*[1n1-d0<l]dslx
Takes a number (2 is pushed to the stack as backup) and multiplies it by 19. Prints a 1 (no newline) and decrements the number. Loops while the number is greater than 0.
Ruby, 24 - 25 = -1
$><<?x*24*(gets||2).to_i
><>, 29 + 2 (-v flag) - 25 = 6
l0=?21-:0(?;fe+1-ao:0=f*e+0.~
Takes input on the stack, which I believe is populated through -v on the official interpreter. Prints newlines only.
Mouse, 21 bytes
1I:(I.43<^9!1I.+I:)$
Ungolfed:
1 I: ~ Begin a loop index at 1
( I. 43 < ^ ~ While I < 43...
9 ! ~ Print 9 to STDOUT
1 I. + I: ~ Increment I
)$
Julia, 42 bytes - 25 = 17
print("@"^42((r=readline())>""?int(r):2))
This reads a line from STDIN using readline(). If it's empty, i.e. no input has been provided, then n is defined to be the input converted to an integer. Otherwise n is 2. We then print 42n @s to STDOUT.
Ruby, 6 bytes
p ?a*9
Prints "aaaaaaaaa" (including the quotes) and a newline.


