Skip to main content
David G.'s user avatar
David G.'s user avatar
David G.'s user avatar
David G.
  • Member for 5 years
  • Last seen this week
  • Maine, USA
revised
Sleep for 1000 years
add a word I lost... "work"
Loading…
revised
Sleep for 1000 years
Incorporate corvus-192's find.
Loading…
awarded
awarded
awarded
answered
Loading…
comment
A rainbow of identity functions
did you forget the empty program?
comment
Generate Gmail Dot-Aliases
On my GCC 9.2.1 x86_64 machine, it works. On my GCC 9.3.0 armv7l machine, it loses the first character.
comment
Generate Gmail Dot-Aliases
1) Lots of undefined behavior. It may work.... or kill you. 2) What's with the separator? Apparently you've used a NUL (undefined behavior) at the start as your separator. This may be accidental, as it comes from j being initialized to 1, or more if you give extra parameters. With 64 parameters, there is no output at all. 3) I tried the bonus version with 58 characters before the @. Tries to make 2^58 processes. Drove the machine into the ground, and fork() can fail.
comment
Golf Me a World Clock 🌐🕖
If I had known I was going to shorten it by 1/3... :-) xxx& instead of (xxx) works, unless you try two invocations ( f 12:30; f 16:16 ) and expect to be able to reasonably read the results. I note it but do not recommend it.
comment
Golf Me a World Clock 🌐🕖
While i does have to be initialized, it does not have to be 0. blank works. It turns out that the $(( )) construct treats empty variables as 0. If you want, you can make it a one liner by using a space or ; instead of newline between the i= and for. Doesn't save bytes, but can be cute. Another twist. If you enclose the line in parentheses, the use of the variable is in a subprocess, so doesn't survive. So if we can assume i (or some variable) to be uninitialized, it won't be afterwards either. And (xxx) is one byte shorter than i=;xxx
comment
Golf Me a World Clock 🌐🕖
I decided to see what I could do with GNU date... Instead of "today", one can write "jan1" or "Mon", or even just the letter for ones local timezone (which for TIO, would be "Z"). Alas, if you put nothing there, the "+2hour" becomes the timezone.
comment
Golf Me a World Clock 🌐🕖
Two more, if you've done the previous. The escaped space before "hour" is needed when writing "$d hour" but not if writing "$((i++))hour" In the former case, writing "$dhour" became a 5 character variable reference.
comment
Golf Me a World Clock 🌐🕖
A weird one: eliminate c, make d iterate over the names, set "i=" before the loop, use $d instead of ${c[d]} and $((i++)) instead of $d. seems to save another 7 characters. If you are willing to trust that i is undefined, you can save 3 more by not initializing it at all.
comment
Golf Me a World Clock 🌐🕖
Another big one: Since none of the city names include a %, you can put the ${c[d]} between the + and the %R, and eliminate the printf altogether. It think that brings it down to 90.
comment
Golf Me a World Clock 🌐🕖
@Noodle9 - you missed dropping the space between -d and $1today...
comment
Golf Me a World Clock 🌐🕖
Changing %H:%M to %R can save 3 btyes. Might be specific to the version of date, but works on TIO.
comment
Golf Me a World Clock 🌐🕖
c=(Accra Lagos Rome Kyiv Dubai) saves ten bytes. Shells only need quotes if something is special. So you can save five more by remove all the " and ' on the second line, and putting a \ before the space in the -d option. Save one more by removing the space between the -d and its parameter. (101)
revised
Print all integers
Initializing i is unneeded. A default empty string works ok.
Loading…
answered
Loading…