Skip to main content
Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
isaccepted:yes
hasaccepted:no
inquestion:1234
Views views:250
Code code:"if (foo != bar)"
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Saves in:saves
Status closed:yes
duplicate:no
migrated:no
wiki:no
Types is:question
is:answer
Exclude -[tag]
-apples
For more details on advanced search visit our help page
Results tagged with
Search options not deleted user 85978

Code-golf is a competition to solve a particular problem in the fewest bytes of source code.

1 vote

Output ISO8601 date string from seconds and nanoseconds

Python 3.8 (pre-release) 106, 81 bytes lambda a,b:datetime.fromtimestamp(a+b//1e3/1e6).isoformat() from datetime import* Try it online!
jaaq's user avatar
  • 617
2 votes
0 answers
87 views

Generate square sub-matrices of 1's [duplicate]

Back again, stealing another question from stackoverflow. You are given a list of integers >= 0. Generate in order square 1-matrices where the side length is given by the list entry of the current in …
jaaq's user avatar
  • 617
1 vote

Remove loops from a walk

Python 3.8 (pre-release), 168 164 163 126 125 bytes l=[p:=0] n="" for s in input(): if(p:=p+1j**(ord(s)%15))in l:x=l.index(p);l=l[:x+1];n=n[:x];p=l[x] else:l+=[p];n+=s exit(n) Try it online! …
jaaq's user avatar
  • 617
12 votes
11 answers
3k views

Simulate a 1D Game-of-Life-ish Model

This question just trended over on code-review and I figured you might like it adapted as a codegolf challenge: You are given a non-empty list of x houses represented as booleans. Each day, the house …
jaaq's user avatar
  • 617
4 votes

Print the last, middle and first character of your code

Python 3, 19 bytes 13 bytes print( ')(') The print function appends a newline by default so the code starts with a newline. The last character of the code is a ")" so that's printed first. To make t …
jaaq's user avatar
  • 617
7 votes
14 answers
4k views

Output ISO8601 date string from seconds and nanoseconds

One reason why ISO8601 is the best date string format, is that you can simply append as much precision as you like. Given 2 integers representing seconds and nanoseconds that have passed since 1970-01 …
jaaq's user avatar
  • 617
4 votes

Output a Super Mario Image

Python3, 921 916 752 751 539 534 476 bytes And here's a mandatory fair version. I used a script to count the individual characters, should be identical: w,s,d,r=' *.#' m='--' n=m*5 A=d*2 B=d*3 C=d*4 D …
jaaq's user avatar
  • 617
17 votes
14 answers
3k views

Generate a random point outside a given rectangle within a map

Introduction Given this visualization of a playing field: (0,0) +----------------------+(map_width, 0) | A | |-----+-----------+----| | D | W | B | |-----+-----------+--- …
jaaq's user avatar
  • 617
0 votes

Print/Output all positive numbers in which every multi-digit substring in its decimal repres...

Python 3.8 (pre-release), 194 bytes r=range s=str l=lambda _:len(s(_)) [*map(print,[t for t in r(1,10**4) if all(all(int(x)%b for b in r(2,int(x))) for x in [s(t)[i:j+1] for i in r(l(t)) for j in r …
jaaq's user avatar
  • 617