Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

Return to Answer

added 268 characters in body
Source Link
brhfl
  • 1.5k
  • 11
  • 14

dc, 164(削除) 164 (削除ここまで) 162 bytes

zzzzzzzC*PzzzzzzzzzzzzzzzzzzzzzzzzzzzSzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzS zzS?zzzzzzzzzzzzS$zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzSwzzzzzzzzzzzzzzzPzzzzzzzzSLzPzPzzzzPL$PLzzzzzzzzzzzzS$zzzzzzzzzzzzzzzzzzzzzzzzzzzzzPzzzzzzzzzzzzzzzzSwzzzzzzzzzzzzzzzPzzzzzzzzSLzPzPzzzzPL$PL PLwPzPzzzzPLLPAI*PL?P

Try it online! Try it online!

There's likely a better/more interesting approach. I tried using the ASCII+256 trick that dc has, but that outputs additional characters as well (even if they're non-printing), and once I got to 'o', the wonderfully prime 111, I ran into trouble even getting a value of 111+(multiple of 256) that factored cleanly. So here's a fairly straightforward (albeit golfed where possible) solution:

In dc, z is a command that pushes the stack depth onto the stack. That means we can use it as an increment. This is how I create most of my ASCII values for this challenge (printed with P), which I push onto named stacks with S and pop back onto the main stack with L.

dc lets you use the hex values A-F even when the input radix is decimal (default). Luckily, our first letter,(削除) Luckily, our first letter, 72, is a multiple of 12, so I save a byte or two here by multiplying 6*12 and printing immediately (zzzzzzzC*P). (削除ここまで) My 164-byte version used multiplication early on to get 72 ('H'), iswhich was mildly clever but a multiple of 12holdover from an earlier attempt, so I save a byte or two here by multiplying 6*12 and printing immediately (zzzzzzzC*P)a waste of bytes. From thereNow, I incrementstart by incrementing and savesaving the space, the exclamation point, and the comma, and the 'W' - thesewhich are out of order, so Iand therefore can't print thembe printed yet. Next, I come to the 'H', which I print immediately, before I get to 'W', which I must save for later.

I simply print when I hit the 'e', then I increment up to 'l'. I print two of those and save one. When I make it to 'o', I first thought I'd have to save one of those for later, but everything is kind of in order at this point. I print an 'o', retrieve my comma, space, and 'W' from earlier, and now I'm right back to 'o'. I print this, and increment a few up to the highest necessary value, 'r' (114), which I print before loading and printing the 'l' I tucked away earlier.

Almost done! 'd' is ASCII value 100, which is easily made by multiplying 10*10 (fewer bytes than having stored it earlier and loading it now). Hex value A is 10, as is our input radix which we can retrieve with the command I. Multiply those, print, and then load and print our exclamation point from earlier. Hello, World!

dc, 164 bytes

zzzzzzzC*PzzzzzzzzzzzzzzzzzzzzzzzzzzzS zzS?zzzzzzzzzzzzS$zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzSwzzzzzzzzzzzzzzzPzzzzzzzzSLzPzPzzzzPL$PL PLwPzPzzzzPLLPAI*PL?P

Try it online!

There's likely a better/more interesting approach. I tried using the ASCII+256 trick that dc has, but that outputs additional characters as well (even if they're non-printing), and once I got to 'o', the wonderfully prime 111, I ran into trouble even getting a value of 111+(multiple of 256) that factored cleanly. So here's a fairly straightforward (albeit golfed where possible) solution:

In dc, z is a command that pushes the stack depth onto the stack. That means we can use it as an increment. This is how I create most of my ASCII values for this challenge (printed with P), which I push onto named stacks with S and pop back onto the main stack with L.

dc lets you use the hex values A-F even when the input radix is decimal (default). Luckily, our first letter, 72, is a multiple of 12, so I save a byte or two here by multiplying 6*12 and printing immediately (zzzzzzzC*P). From there, I increment and save the space, the exclamation point, the comma, and the 'W' - these are out of order, so I can't print them yet.

I simply print when I hit the 'e', then I increment up to 'l'. I print two of those and save one. When I make it to 'o', I first thought I'd have to save one of those for later, but everything is kind of in order at this point. I print an 'o', retrieve my comma, space, and 'W' from earlier, and now I'm right back to 'o'. I print this, and increment a few up to the highest necessary value, 'r' (114), which I print before loading and printing the 'l' I tucked away earlier.

Almost done! 'd' is ASCII value 100, which is easily made by multiplying 10*10 (fewer bytes than having stored it earlier and loading it now). Hex value A is 10, as is our input radix which we can retrieve with the command I. Multiply those, print, and then load and print our exclamation point from earlier. Hello, World!

dc, (削除) 164 (削除ここまで) 162 bytes

zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzS zzS?zzzzzzzzzzzzS$zzzzzzzzzzzzzzzzzzzzzzzzzzzzzPzzzzzzzzzzzzzzzzSwzzzzzzzzzzzzzzzPzzzzzzzzSLzPzPzzzzPL$PL PLwPzPzzzzPLLPAI*PL?P

Try it online!

There's likely a better/more interesting approach. I tried using the ASCII+256 trick that dc has, but that outputs additional characters as well (even if they're non-printing), and once I got to 'o', the wonderfully prime 111, I ran into trouble even getting a value of 111+(multiple of 256) that factored cleanly. So here's a fairly straightforward (albeit golfed where possible) solution:

In dc, z is a command that pushes the stack depth onto the stack. That means we can use it as an increment. This is how I create most of my ASCII values for this challenge (printed with P), which I push onto named stacks with S and pop back onto the main stack with L.

dc lets you use the hex values A-F even when the input radix is decimal (default). (削除) Luckily, our first letter, 72, is a multiple of 12, so I save a byte or two here by multiplying 6*12 and printing immediately (zzzzzzzC*P). (削除ここまで) My 164-byte version used multiplication early on to get 72 ('H'), which was mildly clever but a holdover from an earlier attempt, and a waste of bytes. Now, I start by incrementing and saving the space, the exclamation point, and the comma, which are out of order, and therefore can't be printed yet. Next, I come to the 'H', which I print immediately, before I get to 'W', which I must save for later.

I simply print when I hit the 'e', then I increment up to 'l'. I print two of those and save one. When I make it to 'o', I first thought I'd have to save one of those for later, but everything is kind of in order at this point. I print an 'o', retrieve my comma, space, and 'W' from earlier, and now I'm right back to 'o'. I print this, and increment a few up to the highest necessary value, 'r' (114), which I print before loading and printing the 'l' I tucked away earlier.

Almost done! 'd' is ASCII value 100, which is easily made by multiplying 10*10 (fewer bytes than having stored it earlier and loading it now). Hex value A is 10, as is our input radix which we can retrieve with the command I. Multiply those, print, and then load and print our exclamation point from earlier. Hello, World!

Source Link
brhfl
  • 1.5k
  • 11
  • 14

dc, 164 bytes

zzzzzzzC*PzzzzzzzzzzzzzzzzzzzzzzzzzzzS zzS?zzzzzzzzzzzzS$zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzSwzzzzzzzzzzzzzzzPzzzzzzzzSLzPzPzzzzPL$PL PLwPzPzzzzPLLPAI*PL?P

Try it online!

There's likely a better/more interesting approach. I tried using the ASCII+256 trick that dc has, but that outputs additional characters as well (even if they're non-printing), and once I got to 'o', the wonderfully prime 111, I ran into trouble even getting a value of 111+(multiple of 256) that factored cleanly. So here's a fairly straightforward (albeit golfed where possible) solution:

In dc, z is a command that pushes the stack depth onto the stack. That means we can use it as an increment. This is how I create most of my ASCII values for this challenge (printed with P), which I push onto named stacks with S and pop back onto the main stack with L.

dc lets you use the hex values A-F even when the input radix is decimal (default). Luckily, our first letter, 72, is a multiple of 12, so I save a byte or two here by multiplying 6*12 and printing immediately (zzzzzzzC*P). From there, I increment and save the space, the exclamation point, the comma, and the 'W' - these are out of order, so I can't print them yet.

I simply print when I hit the 'e', then I increment up to 'l'. I print two of those and save one. When I make it to 'o', I first thought I'd have to save one of those for later, but everything is kind of in order at this point. I print an 'o', retrieve my comma, space, and 'W' from earlier, and now I'm right back to 'o'. I print this, and increment a few up to the highest necessary value, 'r' (114), which I print before loading and printing the 'l' I tucked away earlier.

Almost done! 'd' is ASCII value 100, which is easily made by multiplying 10*10 (fewer bytes than having stored it earlier and loading it now). Hex value A is 10, as is our input radix which we can retrieve with the command I. Multiply those, print, and then load and print our exclamation point from earlier. Hello, World!

AltStyle によって変換されたページ (->オリジナル) /