Skip to main content
added 14 characters in body
Source Link
Leibrug
  • 111
  • 5

JavaScript (ES2015), 147 138 137 134134 133 bytes

((o,x,r)=>{for(i=0;i<24;){b=i%12,c=b||12,o+='0'[r](i<10)+i+++x+' '[r]((c<10)+1)+c+x+(i<13?'a':'p')+"m\n"}return+"m\n";return o})('',':00','repeat')

In this version I took advantage of String.repeat() method to get rid of lengthy .slice() and .join() and moved incrementation inside loop.

Previous version:

((o,x,i)=>{for(;i<24;i++){b=i%12;o+=[`0${i+x}`.slice(-5),(b||12)+x+(i<12?'a':'p')+'m'].join(' '.repeat((b>0&&b<10)+1))+"\n"}return o})('',':00',0)

Gives output with trailing newline. Tested in Firefox Scratchpad. Not sure if passing arguments to IIFE is OK with "no input" rule.

It's my first submission, so hello to everyone! :)

JavaScript (ES2015), 147 138 137 134 bytes

((o,x,r)=>{for(i=0;i<24;){b=i%12,c=b||12,o+='0'[r](i<10)+i+++x+' '[r]((c<10)+1)+c+x+(i<13?'a':'p')+"m\n"}return o})('',':00','repeat')

In this version I took advantage of String.repeat() method to get rid of lengthy .slice() and .join() and moved incrementation inside loop.

Previous version:

((o,x,i)=>{for(;i<24;i++){b=i%12;o+=[`0${i+x}`.slice(-5),(b||12)+x+(i<12?'a':'p')+'m'].join(' '.repeat((b>0&&b<10)+1))+"\n"}return o})('',':00',0)

Gives output with trailing newline. Tested in Firefox Scratchpad. Not sure if passing arguments to IIFE is OK with "no input" rule.

It's my first submission, so hello to everyone! :)

JavaScript (ES2015), 147 138 137 134 133 bytes

((o,x,r)=>{for(i=0;i<24;)b=i%12,c=b||12,o+='0'[r](i<10)+i+++x+' '[r]((c<10)+1)+c+x+(i<13?'a':'p')+"m\n";return o})('',':00','repeat')

In this version I took advantage of String.repeat() method to get rid of lengthy .slice() and .join() and moved incrementation inside loop.

Previous version:

((o,x,i)=>{for(;i<24;i++){b=i%12;o+=[`0${i+x}`.slice(-5),(b||12)+x+(i<12?'a':'p')+'m'].join(' '.repeat((b>0&&b<10)+1))+"\n"}return o})('',':00',0)

Gives output with trailing newline. Tested in Firefox Scratchpad. Not sure if passing arguments to IIFE is OK with "no input" rule.

It's my first submission, so hello to everyone! :)

added 15 characters in body
Source Link
Leibrug
  • 111
  • 5

JavaScript (ES2015), 147 138 137137 134 bytes

((o,x,r)=>{for(i=0;i<24;i++i=0;i<24;){b=i%12;o+='0'[r]b=i%12,c=b||12,o+='0'[r](i<10)+i+x+'+i+++x+' '[r]((b>0&b<10c<10)+1)+(b||12)+x++c+x+(i<12i<13?'a':'p')+"m\n"}return o})('',':00','repeat')

In this version I took advantage of String.repeat() method to get rid of lengthy .slice() and .join() and used & operator instead of &&moved incrementation inside loop.

Previous version:

((o,x,i)=>{for(;i<24;i++){b=i%12;o+=[`0${i+x}`.slice(-5),(b||12)+x+(i<12?'a':'p')+'m'].join(' '.repeat((b>0&&b<10)+1))+"\n"}return o})('',':00',0)

Gives output with trailing newline. Tested in Firefox Scratchpad. Not sure if passing arguments to IIFE is OK with "no input" rule.

It's my first submission, so hello to everyone! :)

JavaScript (ES2015), 147 138 137 bytes

((o,x,r)=>{for(i=0;i<24;i++){b=i%12;o+='0'[r](i<10)+i+x+' '[r]((b>0&b<10)+1)+(b||12)+x+(i<12?'a':'p')+"m\n"}return o})('',':00','repeat')

In this version I took advantage of String.repeat() method to get rid of lengthy .slice() and .join() and used & operator instead of &&.

Previous version:

((o,x,i)=>{for(;i<24;i++){b=i%12;o+=[`0${i+x}`.slice(-5),(b||12)+x+(i<12?'a':'p')+'m'].join(' '.repeat((b>0&&b<10)+1))+"\n"}return o})('',':00',0)

Gives output with trailing newline. Tested in Firefox Scratchpad. Not sure if passing arguments to IIFE is OK with "no input" rule.

It's my first submission, so hello to everyone! :)

JavaScript (ES2015), 147 138 137 134 bytes

((o,x,r)=>{for(i=0;i<24;){b=i%12,c=b||12,o+='0'[r](i<10)+i+++x+' '[r]((c<10)+1)+c+x+(i<13?'a':'p')+"m\n"}return o})('',':00','repeat')

In this version I took advantage of String.repeat() method to get rid of lengthy .slice() and .join() and moved incrementation inside loop.

Previous version:

((o,x,i)=>{for(;i<24;i++){b=i%12;o+=[`0${i+x}`.slice(-5),(b||12)+x+(i<12?'a':'p')+'m'].join(' '.repeat((b>0&&b<10)+1))+"\n"}return o})('',':00',0)

Gives output with trailing newline. Tested in Firefox Scratchpad. Not sure if passing arguments to IIFE is OK with "no input" rule.

It's my first submission, so hello to everyone! :)

added 13 characters in body
Source Link
Leibrug
  • 111
  • 5

JavaScript (ES2015), 147 138138 137 bytes

((o,x,i,r)=>{for(;i<24;i++i=0;i<24;i++){b=i%12;o+='0'[r](i<10)+i+x+' '[r]((b>0&b<10)+1)+(b||12)+x+(i<12?'a':'p')+"m\n"}return o})('',':00',0,'repeat')

In this version I took advantage of String.repeat() method to get rid of lengthy .slice() and .join(), and used & operator instead of &&.

Previous version:

((o,x,i)=>{for(;i<24;i++){b=i%12;o+=[`0${i+x}`.slice(-5),(b||12)+x+(i<12?'a':'p')+'m'].join(' '.repeat((b>0&&b<10)+1))+"\n"}return o})('',':00',0)

Gives output with trailing newline. Tested in Firefox Scratchpad. Not sure if passing arguments to IIFE is OK with "no input" rule.

It's my first submission, so hello to everyone! :)

JavaScript (ES2015), 147 138 bytes

((o,x,i,r)=>{for(;i<24;i++){b=i%12;o+='0'[r](i<10)+i+x+' '[r]((b>0&b<10)+1)+(b||12)+x+(i<12?'a':'p')+"m\n"}return o})('',':00',0,'repeat')

In this version I took advantage of String.repeat() method to get rid of lengthy .slice() and .join(), and used & operator instead of &&.

Previous version:

((o,x,i)=>{for(;i<24;i++){b=i%12;o+=[`0${i+x}`.slice(-5),(b||12)+x+(i<12?'a':'p')+'m'].join(' '.repeat((b>0&&b<10)+1))+"\n"}return o})('',':00',0)

Gives output with trailing newline. Tested in Firefox Scratchpad. Not sure if passing arguments to IIFE is OK with "no input" rule.

It's my first submission, so hello to everyone! :)

JavaScript (ES2015), 147 138 137 bytes

((o,x,r)=>{for(i=0;i<24;i++){b=i%12;o+='0'[r](i<10)+i+x+' '[r]((b>0&b<10)+1)+(b||12)+x+(i<12?'a':'p')+"m\n"}return o})('',':00','repeat')

In this version I took advantage of String.repeat() method to get rid of lengthy .slice() and .join() and used & operator instead of &&.

Previous version:

((o,x,i)=>{for(;i<24;i++){b=i%12;o+=[`0${i+x}`.slice(-5),(b||12)+x+(i<12?'a':'p')+'m'].join(' '.repeat((b>0&&b<10)+1))+"\n"}return o})('',':00',0)

Gives output with trailing newline. Tested in Firefox Scratchpad. Not sure if passing arguments to IIFE is OK with "no input" rule.

It's my first submission, so hello to everyone! :)

Add shorter code
Source Link
Leibrug
  • 111
  • 5
Loading
Source Link
Leibrug
  • 111
  • 5
Loading