The challenge is as simple as it suggests, you have to print a string without using single/double quotes in source code.
The string is:
The quick brown fox jumps over the lazy dog
Standard loopholes apply
code-golf, shortest code wins
Code Golf Stack Exchange is a question and answer site for programming puzzle enthusiasts and code golfers. It only takes a minute to sign up.
Sign up to join this communityThe challenge is as simple as it suggests, you have to print a string without using single/double quotes in source code.
The string is:
The quick brown fox jumps over the lazy dog
Standard loopholes apply
code-golf, shortest code wins
#coding:U7
print+ACI-The quick brown fox jumps over the lazy dog+ACI-
There are some other ways to get strings without strings in Python but I think UTF-7 is the shortest method.
from idlelib.idle_test.htest import*
print(str(globals())[3242:3285])
import test.test_builtin as t
print([*open(t.__file__)][1080][22:65])
Under the assumption that function submissions are OK (the wording 'you have to print' is a little ambiguous), the following works for 64, thanks to ovs:
from test.test_binascii import*
BinASCIITest.rawdata[:43].decode
FOX.COM:
00000000: b409 ba08 01cd 21c3 5468 6520 7175 6963 ......!.The quic
00000010: 6b20 6272 6f77 6e20 666f 7820 6a75 6d70 k brown fox jump
00000020: 7320 6f76 6572 2074 6865 206c 617a 7920 s over the lazy
00000030: 646f 6724 dog$
Unassembled Listing:
B4 09 MOV AH, 9 ; DOS write string syscall
BA 0108 MOV DX, OFFSET FOX ; address for string
CD 21 INT 21H ; write to stdout
C3 RET ; return to DOS
FOX:
54 68 65 20 71 75 69 ; The qui
63 6B 20 62 72 6F 77 ; ck brow
6E 20 66 6F 78 20 6A ; n fox j
75 6D 70 73 20 6F 76 ; umps ov
65 72 20 74 68 65 20 ; er the
6C 61 7A 79 20 64 6F ; lazy do
67 24 ; g$
Alternately...
BE 010F MOV SI, OFFSET FOX ; source data pointer
B4 B0 MOV AH, 0B0H ; MDA video RAM segment is B000
8E C0 MOV ES, AX ; move segment to ES
BF 0140 MOV DI, 80*4 ; write output to third row
B1 2B MOV CL, 43 ; length of data to copy
F3 A5 REP MOVSW ; copy data to video RAM
C3 RET ; return to DOS
FOX:
0754 0768 0765 0720 ; The
0771 0775 0769 0763 ; quic
076B 0720 0762 0772 ; k br
076F 0777 076E 0720 ; own
0766 076F 0778 0720 ; fox
076A 0775 076D 0770 ; jump
0773 0720 076F 0776 ; s ov
0765 0772 0720 0774 ; er t
0768 0765 0720 076C ; he l
0761 077A 0779 0720 ; azy
0764 076F 0767 ; dog
This copies the raw input string directly to the video buffer RAM of the IBM PC Monochrome display adapter (MDA)... real mode is fun huh? It uses the rep movsw
instructions to copy a block of data in memory quickly with one instruction (okay, technically two) in the CPU (this is one of the techniques used by "8088 Domination" to achieve full motion video on an IBM PC/XT). Now, each character in video RAM is made up of two bytes, one being the character and the other video attributes, so in order to do the copy entirely by the CPU, the attribute byte is (wastefully) repeated for each character. This is probably the "fastest" way to produce the required output, not the shortest. It would be 62 bytes to use lodsb
, stosw
and loop
, but what fun would that be?
“Þgʂ9¡ạȤÞ|Ẹ`X ³ṀÞȯʂȧ0Rỵ»Ṗ
Generated using this golfing tip. However, the string compressed is The quick brown fox jumps over the lazy dogA
, because compressing The quick brown fox jumps over the lazy dog
has a single quote in the resulting compression. That's why there is an extra Ṗ
on the end.
Thanks to
$><<
(-1 character)q
in %q
(-1 character)$><<%(The quick brown fox jumps over the lazy dog)
Or if you feel this is cheatish,
puts:The_quick_brown_fox_jumps_over_the_lazy_dog.to_s.tr ?_,?\
#define s(x)#x
f(){puts(s(The quick brown fox jumps over the lazy dog));}
n=>String.fromCharCode(84)+(111863585492878046599964977000016072026261675295708949484669367104n.toString(36).replace(/0/g,String.fromCharCode(32)))
Takes a massive Bigint and turns into string. Appends 'T' on the front and replaces 0s with spaces.
I got this Bigint by writing a custom parseInt function for bigInts.
(n=>(/The quick brown fox jumps over the lazy dog/+'').slice(1,-1))()
is shorter.
\$\endgroup\$
– user202729
Feb 19 at 9:41
\A=The quick brown fox jumps over the lazy dog@end
Note that due to the way TIO runs the code, is possible to ignore that normally the tool would wait for input indefinitely. Just like the sed solution does. In our case would mean to get rid of @end
.
alert`The quick brown fox jumps over the lazy dog`
-2 for @RedwolfPrograms!
51 32429737401852232227804295321578416370544555457622262891879921280324727410131817586348135470079420921373938348260737299348550007805068404867624897650263347568409592608258945989033792510474363164709158118555665232935403908551415888090695760298337219819413274977014408722140235669339108001709528995376914900494019798521214727367535169036319615676199584661126257462974800782884967804763256678000063025237472650538076831876942979826335539886276642624472204985016283691316313249488093825552581263195700506490263014623798470563718844847334940964632636436478404543496272112184140337568637349767918641524452384959486975049813859244670160569884744538279036643294867674161431756929550170395739925307134312406291063668809195567313928307910934660574895433141956111513050736041440669472422865481546405020220238818265794921314653725749392385549924210837964649297239381603259476675148489582680939048820717739905271461370132524025785160026801625672272913416389786086946626728842588663673416395169524016926695769334183833366462685756958054189820999370092892855665559717806826530952610964256124463840218293029538229042911551526509745973128558291005365222643503139067010483637086697955919587162384655443959408291567894061028044826636171014388153130769792397282335858985323269310727311039012381122390183102126191168963870116881629339035600546009305431793687183913979054151312200573069395058914262857368132993952655571167118263728070696377852599343989848263167312887211748226689125561718255196655446099711296568221690530717651328503948183228932786503716890383195810396161663632504174142420921735055441162618914957825032056019218584287089599270312541933094119409995775035365862244691419255488688879630142415739738796957474249592086989231999568273454247198389863139439897248192949030226324637037937607004428557202644332945222019553599908855943840883606735602486216245714280716148378430738983808375466562604692991701163078094015860708365913183037140180020776525026891135163345427911749533164462233906885068864798951466382247930357444595606617682531499045805835102155190109668901179666311163071611393282924908189215675892953256826649762594463293867383921972181952997833560371571545190945543033351108064265894854803319008655145213765667074789305055723258530694850418765677462165413557272747961130459219342146615095862014137406489375157766959799291089215740196734079295172946350338663239451562589633216908805028629767462044463310475859283605554743731396818983359527612902567406307270838160926586311672252276690909354125055468912844343806046309796590149977323343332039095076680537362333773750051043281967620781236684580688649899599894791764969639275247700776637892615729757899608628514791667795106390376246890330575517824338764219021396958188958235055290896924249770944905659304681507478975095888248103169710912376599445302527257479613158446721050489248195749488706928558735504718025170935741927323467065794383909264457377594759523882192572296622475035751867680970240211437389756819919638407630960455110442606184193067264026141442171015623711890501422832367613695746709948930222515546724629930195488846499833510347190238482605529712469516320662254965090537614222803226025037648742876211599475358691270287755703426317789504791647288818094389174889178573580598175570821287862758983375715639329891266282896317497458005992191139964542011830637498271478110468502674393216859832483523846852947729597069648468842312470305612006735746914087851111863997172391046681759459717971339014228407596211606417529911960602633662917218720051142716331417860009772581365446262780647646418500423648076144228803333865749659637573281088970874066190954610017331862257246361741824782593741016661509572232545061179819355083596692463192474875464520654705101238310664069208813642792125365891708422505379476584155456776493814635231239825935897403100406936196140704838776238310181628800965542553245149025785815694829007293441508673278634434393099554617206350471993124294146473223803396140559107993151916604380084564196399191982675386425933781135023405813878560810911153051095111172727827562315672649547451906884909529341748636764617809729125248176744783875171881994494661071091480821671589718868607994061101658834308895511447169347092505317193264713843584225041739742162139615184271208729165766894113261390708005524455403964360001552052851223029438111062677888351614960807231998971170744469120735054941364852035861789961456545482174278167451365198392286797936260598391554539740121786335810235570524225329612724009830128551592000736194663644492357667898401754216577349274688996071736360199860450232121205159661637932235969680399373088268724804194099965948284358384664286149651501196550155931592955688202307383256425808908360994584627214121376440256818514869392424603087404217294979511369359948459573631775019525795573110275783934235199702189982612969716612616508351305655318312319486010392592157314968285379869378912113522095965649729099115605356241123179504354566820658787022336272843821844715646333822931169249872471238626118062323471860990377660833924224274094180580136050575857503743877680958738176417004535235720993081602279459631882804537975038042695906570668840344258511048701065981677058092545466225138676631339274835498382950945975860148934573988454849267759159804871532850967404424313944412626460725075303852487458407061889843250010267681061549983383885517498653116487011021079103989316108811109008770135791239838420661388515658017897357568826303410520911442509698130259852050618861653089916760408088001501974667676344087690829884515856400221313702290665500426239922177968490710919109801428997746905364162697265448993444147272056571598272452921613022253660898170377475487980316100990266472152354084519726174449151923669875611521325472099357098237652386225613770136784967490867846277011538640258407591060362265437805361893353145097381084278893254852019021049798422190799867511036289820193043831619335483618825799351343292624280903179091725616885889942253970580420823474060588689641162749365310499490972123386293257773534507217296099232061044762268495401392799744
The quick brown fox jumps over the lazy dog
/!/he /T!quick brown fox jumps over t!lazy dog
[[ The quick brown fox jumps over the lazy dog]] write
Does not work on TIO, but works locally in 0.98 stable. [[ ...]]
is a multiline string literal which pushes the string on the stack.
R/ The quick brown fox jumps over the lazy dog/ raw>> write
Constructs a regex, extracts the raw string representation from it, and then prints the string.
o=chr(111):s=chr(32):msgbox chr(84)+chr(104)+chr(101)+s+chr(113)+chr(117)+chr(105)+chr(99)+chr(107)+s+chr(98)+chr(114)+o+chr(119)+chr(110)+s+chr(102)+o+chr(120)+s+chr(106)+chr(117)+chr(109)+chr(112)+chr(115)+s+o+chr(118)+chr(101)+chr(114)+s+chr(116)+chr(104)+chr(101)+s+chr(108)+chr(97)+chr(122)+chr(121)+s+chr(100)+o+chr(103)
Oh god works for vbscript too
e
s, so using a variable will save you 10 bytes. There are also two h
s, r
s and u
s which will save you 3 bytes each.
\$\endgroup\$
– Neil
Feb 19 at 10:28
iThe quick brown fox jumps over the lazy dog
Trick learnt from @Dingus here: Print your username by ONLY using the characters in your username
I
, a
, A
, and probably some other things that I don't remember because I don't use vim that much.
\$\endgroup\$
– PkmnQ
Feb 19 at 4:47
😭god yzal eht revo spmuj xof nworb kciuq ehT😲⏪⏬⏩
Explanation
😭 god yzal eht revo spmuj xof nworb kciuq ehT 😲 ⏪ ⏬ ⏩ explanation
😭 begin quote string
god yzal eht revo spmuj xof nworb kciuq ehT
😲 end quote string
⏪ open loop
⏬ pops and outputs top of stack as character
⏩ close loop
"
in the code, if you post into answer body in SE
\$\endgroup\$
– Wasif
Feb 21 at 9:54
Anonymous prefix lambda taking (and ignoring) a dummy argument.
{0::21↓2⊃⎕DM⋄The quick brown fox jumps over the lazy dog
}
{
dfn:
0::
if any error happens:
⎕DM
get the Diagnostic Message (a list of three strings; the error message, the offending code line, a line with ∧
indicating the error position)
2⊃
pick the second element (i.e. our code, with some spacing normalised)
21↓
drop 22 characters from the front
⋄
now try:
The
…dog
this expression which fails with a value error on dog
.
The quick brown fox jumps over the lazy dog
Save it as .html file and then run, will print in the browser
Write-Host The quick brown fox jumps over the lazy dog
But a newline at the end.
Write-Host -n The quick brown fox jumps over the lazy dog
For no newline
echo -n The quick brown fox jumps over the lazy dog
No newlines for the 51 bytes one. Remove the -n
to print the newline too and get 3 bytes saved
echo The quick brown fox jumps over the lazy dog
The quick brown fox jumps over the lazy dog
Trick learnt from @Wezl: Print your username by ONLY using the characters in your username
console.log(`The quick brown fox jumps over the lazy dog`)
Yeah, backticks work
print<DATA>;
__DATA__
The quick brown fox jumps over the lazy dog
0x27
and0x22
? (Some answers are using0x201C
(left double quotation mark) or0x275D
(heavy double turned comma quotation mark ornament).) \$\endgroup\$ – Dingus Feb 19 at 5:23Do X without Y
can be interesting, but it usually isn't because there are only so many ways to do it creatively (and most have already been done). \$\endgroup\$ – Lyxal Feb 19 at 5:27