Maxim Mikhaylov
  • Member for 4 years, 10 months
  • Last seen more than a month ago
Sum of all integers from 1 to n
5 votes

dc, 7 bytes d1+*2/p OR d2^+2/p OR dd*+2/p Try it online!

View answer
Output with the same length as the code
4 votes

dc, 2 bytes Kp Try it online! Pushes the current precision on the stack (which is 0) and prints it with a trailing newline.

View answer
What my dog really hears
4 votes

sed, 37 33 bytes 36 bytes sourcecode + 1 byte for -r flag. s:(rex)|\w:\1*:Ig s:(rex)\*:\1:Ig Try it online!

View answer
Insist on an answer
4 votes

AWK, 8 11 bytes NF{exit} Wait for input. If the number of fields in input is more than 0, exit. EDIT: I've just realized that this doesn't work for input containing whitespace characters only. ...

View answer
What's my middle name?
4 votes

Perl 5, 27 18 bytes Need to run with -n option. / (.+) /&&print$1 Try it online! Wanted to do something similar in sed first, but, unfortunately, it doesn't support non-greedy quantifier. ...

View answer
Is the number binary-heavy?
2 votes

R, 74 62 bytes x=scan();n=strtoi(intToBits(x)[0:log2(x)+1]);2*sum(n)>sum(n|T) Edit: Thanks Giuseppe! -12 bytes Try it online!

View answer
Pause twice as long
2 votes

Bash, 37 bytes for((t=1;;t*=2)){ sleep $t;echo $1;}; For some reason TIO won't show the output until you stop the program execution. Try it online!

View answer
Ring me when our cup noodles are ready
2 votes

Bash, 68 43 bytes for((e=`date +%s`+50;`date +%s`<e;)){ :;};w Lists logged in users after 50 seconds. Edit: Thanks a lot, manatwork! -25 bytes. Try it online!

View answer
Be the First 1 (leave only the first Truthy)
2 votes

sed, 16 19 bytes 15 18 bytes sourcecode + 1 byte for -r flag (or -E flag for BSD sed). : s/1(0*)1/1\10/ t Try it online! Edit: Thanks Riley for pointing out a mistake.

View answer
Let's do some “enciph5r47g”
2 votes

C (tcc), 113 bytes Since the function creates a copy of an input string, the maximum size of input is 98 characters (more than enough to fit the longest test input). Of course, this can be changed to ...

View answer
Create a codeblock tool
2 votes

sed, 16 10 9 bytes s/^/ / Try it online! Edits Reduced solution size from 16 to 10 bytes thanks to Kritixi Lithos. -1 byte thanks to seshoumara.

View answer
Reciprocal of a number (1/x)
2 votes

bc + sh, 14 10 bytes 1/read()<NEWLINE> Run bc with -l which sets the default scale to 20. That way both input and output have 20 digits after the decimal point. Edit: Thanks DigitalTrauma for ...

View answer
Find the Missing Letter
1 votes

R, 67 bytes l=letters;L=LETTERS;a=scan(,'');`if`(a==l&&T,l[a!=l][1],L[a!=L][1]) Try it online!

View answer
Find the nearest biquadratic number
1 votes

R, 47 44 37 35 bytes n=scan();which.min(((1:n)^4-n)^2)^4 Try it online!

View answer
What do you get when you multiply 6 by 9? (42)
1 votes

dc, 22 bytes [42 1]sX[k6=X]sZd9=Z*p Try it online!

View answer
Raise integer x to power x, without exponentiation built-ins
1 votes

dc, 24 23 26 22 bytes This is my first attempt writing a recursive macro in dc. I am sure it is a sub-optimal solution which can be improved a lot. dsr1+[lrr1-d1<F*]dsFxp Try it online! Edit: ...

View answer
Swap indices and values
1 votes

Bash, 109 bytes Too bad there is no built-in for array max value. a=($@) for((x=m=1;x<=m;x++)){ for((y=0;y<$#;)){((m<a[y]))&&((m=a[y]));((a[y++]==x))&&printf "%d " $y;};echo;...

View answer
The forbidden built-in
1 votes

Bash, 61 bytes a=($@) for((t=0;t<$#;t+=3)){((a[t+1]<a[t]))&&echo ${a[t+2]};} Try it online!

View answer
Easier communication means faster coding means fewer coders means …
1 votes

bc, 76 bytes while(1)"EASIER COMMUNICATION MEANS FASTER CODING MEANS FEWER CODERS MEANS "

View answer
What's my middle name?
1 votes

Bash, 31 19 bytes echo ${@:2:$[$#-2]} Try it online! Breakdown: Prints parameter expansion from second to second last element. Edit Removed commented code from breakdown section, since it's now ...

View answer
Raise a single number
1 votes

sh, 118 bytes Input integers are passed as arguments to the script. l=("$@");for i in "$@";{ for j in "$@";{(($i<$j))&&{ l[$x]=$j;echo ${l[@]};exit;};};shift;x=`expr $x+1`;};echo ${l[@]} ...

View answer
Who has a comma for a middle name?
0 votes

Bash, 26 bytes echo ${!#}, ${@:1:$[$#-1]} Try it online!

View answer
Shorten the Java Package
0 votes

sed, 57 22 bytes I expected sed solution to be a little shorter than this... Edit: The shorter solution uses regex from Martin Ender's answer. 21 bytes sourcecode + 1 byte for -r flag (or -E flag ...

View answer
Make me an Easter egg!
0 votes

Bash, 50 bytes echo " __ /$1$1\\ /$1$1$1$1\\ |$1$1$1$1| \____/" I've also tried to do pattern substitution during parameter expansion, but it seems like the most straightforward way to do this is ...

View answer
It's [current year] already, folks, go home
0 votes

Gawk, 64 60 bytes GNU Awk has a couple of built-in function to get current time and date. BEGIN{print"It's "strftime("%Y")" already, folks, go home."} Edit The script can run from a file (-f), ...

View answer
plz send teh codez!
0 votes

sh + sed, 72 bytes Uses character sets: 1, 3, 4, 5. let "" sed "s/.*Plz send teh codez!.*/-$? flag comment/ tz s/.*/+$?/ :z" At first, I wanted to go with pure sed, but I had no idea how to avoid ...

View answer