« first day (4294 days earlier)      last day (557 days later) » 
00:00 - 15:0015:00 - 00:00

12:56 AM
@py3_and_c_programmer same
@Sʨɠɠan your the one who made 2 seggans :D
@Sʨɠɠan BEGIN{for(i=2;i<99;i++){a=1;for(c=2;c<i;c++){if(i%c<1){a=0}}if(a){print(i)}} doesnt seem to work in awk (sry I have no idea how it works)
 
1:12 AM
@DialFrost anyone?
I've optimisied it slightly to for x in range(9,991,2): since primes arent even numbers
but it's oneeee number off
 
Is this Python?
And what's the code for?
 
prime numbers from 1 to 100 and yes its python
pretty sure the double exec is killing my runtime
 
Hardcode
 
Oh you're using exec?
Why?
 
@emanresuA waiiiit sry guys
I meant emirp numbers 1 to 1000
@forest idk :/ to shorten the code lol
 
1:20 AM
There are lots of prime generating and primality testing algorithms out there.
Are you optimizing for speed or size?
 
both
 
Those are opposing goals.
 
ikr
the first emirp challenge is asking you to do it from 1 to 1000
the next emirp challenge
is the exact same thing
except they want u to do it from 1 to 10000
so speed is require to bypass this
 
memoizing the primes would help
 
How much time does it give you?
 
1:21 AM
@forest 5s
@emanresuA ?
 
Oh that would be easy with even trial division.
 
@DialFrost no i wasnt
the other steggan created the hivemind
 
@Sʨɠɠan sussy
@forest wait gimme a sec lemme try that
 
@DialFrost Anyway, the typical way to generate primes in that range is the Sieve of Eratosthenes.
 
so i made a graph with a bunch of languages and how they relate to each other. each column is a 5 year time period. dotted lines are influences
 
1:23 AM
Ooh
 
argh its not uploading
 
You could also optimize it for time if you're using a more sophisticated primality test by first doing trial division (actually, using the modulo operator and checking the result) with several small hardcoded primes in order to skip most composite numbers.
 
so i made a graph with a bunch of languages and how they relate to each other. each column is a 5 year time period. dotted lines are influences (take 2)
 
Now do it with golflangs
 
try not to find a recent language that is not a descendant of C :P
@emanresuA i dunno that much, but ill try
 
1:26 AM
@Sʨɠɠan yes lmao
@forest what?lol
 
@Sʨɠɠan vyxal
 
@forest ?what again?
 
Actually that's descended from keg + python
 
@DialFrost Do you know that algorithm? See en.wikipedia.org/wiki/Sieve_of_Eratosthenes
 
no
 
1:27 AM
@emanresuA and python is... :P
 
unfortunately I've never seen that b4
:(
 
@DialFrost It's a very simple and popular prime sieve that works efficiently when generating small prime numbers.
 
python is actually pretty old
 
Jelly's descended from APL+J
 
even c is on the older side
@emanresuA i thought it was just j
oke lemme make a golflang one :D
 
1:29 AM
@forest i still dont get how to use it tho lmao
 
interesting to see that rust has prolog as an ultimate ancestor
 
@DialFrost There are a lot of prime sieves. The Sieve of Eratosthenes is just a very fast and simple one. It'd probably result in the fastest and also smallest code for generating primes up to a small limit. More complex sieves are required only if you're generating primes of astronomical sizes (in the hundreds of digits).
@DialFrost Look up a reference implementation of the algorithm in Python.
 
Wikipedia shows the pseudocode:
algorithm Sieve of Eratosthenes is
    input: an integer n > 1.
    output: all prime numbers from 2 through n.

    let A be an array of Boolean values, indexed by integers 2 to n,
    initially all set to true.

    for i = 2, 3, 4, ..., not exceeding √n do
        if A[i] is true
            for j = i2, i2+i, i2+2i, i2+3i, ..., not exceeding n do
                set A[j] := false

    return all i such that A[i] is true.
 
@emanresuA ooh nice
 
1:30 AM
@Sʨɠɠan Also maybe concatenate it to the regular one but recolour it
 
@forest I dont see any
 
@emanresuA ooh
 
I just searched "sieve of eratosthenes python".
 
That list is huge so you might want to avoid the more obscure nes
 
@forest isnt that infinite?
 
1:32 AM
Here's a naïve implementation:
def sieve1(n):
    loops = 0
    numbers = set(range(2, n))
    for i in range(2, int(n ** 0.5) + 1):
        for j in range(i * 2, n, i):
            numbers.discard(j)
            loops += 1
    return sorted(numbers), loops
 
@emanresuA yeah i havent heard of 80% of them
 
@DialFrost No.
It generates primes up to N.
 
theres a problem tho
emirp numbers challenge probably requires to do this like twice
 
Which is?
 
cuz it checks for backwards primes too
 
1:34 AM
Huh?
Here's an optimized version from SO:
def primes(upTo):
    isPrime = list(range(upTo))
    for p in range(2,int(upTo**0.5)+1): #p: 2,3,4,...,sqrt(N)
        print(p, isPrime[p])
        if isPrime[p]:
            for multiple in range(p**2,upTo,p): #mult: p^2, p^2+p, p^2+2p, ..., N
                isPrime[multiple] = False
    return [x for x in isPrime[2:] if x]
>>> list(primes(29))
[2, 3, 5, 7, 11, 13, 17, 19, 23]
 
An emirp (prime spelled backwards) is a prime number that results in a different prime when its decimal digits are reversed. For example both 13 and 31 are emirps, but 131 is not.
 
I thought you just wanted to generate primes up to a certain limit?
 
nope
:/
My code prime checked twice but it was too slow but small
this will significantly increase the code size
 
So you need a primality test as well.
 
a what?
 
1:40 AM
It's an algorithm that is fed an integer and returns whether it is prime or composite.
 
@forest uhhhh idk XD
for x in range(1,999):
 p=n=1
 exec("p*=n*n;n+=1;"*~-x)
 a=b=1
 exec("a*=b*b;b+=1;"*~-int(str(x)[::-1]))
 if p%n and a%b and a!=p:print(x)
I did this previously but its too slow
It checks for primes twice once for x and another for x[::-1]
 
How much memory do you have? You could just create a huge list of primes using a sieve and then checking for an emirp would be pretty simple. It wouldn't be the most efficient, but it could get it done in under 5s...
 
@forest for memory im not sure i think its just runtime
@forest checking for emirp is simple? how lol
 
@emanresuA jokes on you that's already been done
 
If you have a list of primes already, it's simple.
Even doing it inefficiently would be fine if you have an entire 5 seconds.
 
1:44 AM
@forest but...but
teach me :3
 
I'm not an expert in Python, but a simple approach if you already have the list is to iterate through it. Get the first prime, reverse the digits, and check if that integer exists in the list. It's highly inefficient but it's probably fast enough.
 
but
 
Alternatively, you could just use a simple primality test and feed it incrementing integers. If the integer has two more more differing digits, reverse them, and feed that into the test as well.
 
you have to check if the reversed digits number is prime too!
 
So?
 
1:46 AM
so you cant just ignore that
 
Just use a simple primality test and feed it both the original and reverse integer.
Push it onto the list. If you need the list in order, you can sort it at the end.
That would be more efficient than just generating a list of regular primes and then checking for emirps using brute force, even if the latter would likely finish in 5 seconds for a mere 1000 integers anyway.
 
tysm forest
All i had to do was google primarlity test python
really fast ^
 
@DialFrost For a primality test, you can use something like Fermat's little theorem.
 
i used def f(a):return not(a<2or any(a%x<1for x in range(2,int(a**0.5)+1)))
buts its wayyy too long
 
@lyxal Most of those are outdated nongolflangs
Also they're not time-dated at all
 
1:55 AM
@forest that doesnt seem to work
def CheckIfProbablyPrime(x):
    return (2 << x - 2) % x == 1
error: negative shift count
 
Are you using the same version of Python?
 
wait nvm
@forest not sure I used the other method using pow, although longer, it works
 
3
A: Explain a code to check primality based on Fermat's little theorem

ivarsj10sI believe, the code in your example is incorrect because binary left shift operator is not equivalent to power of a number, which is used in Fermat's little theorem. With base of two, binary left shift would be equal to power of x + 1, which is NOT used in a version of Fermat's little format. In...

 
def f(x):return pow(2,x-1,x)==1
for a in range(9,999):
 if f(a)and f(int(str(a)[::-1]))and a!=int(str(a)[::-1]):print(a)
finally code ^
 
OK
I gotta go. Later.
 
2:04 AM
aww
@forest note for you later when you read this: the method u suggested me, fermat's little therorem, doesnt seem to work with larger primes
 
I'm still here, just finishing up. Anyway if the Fermat test isn't working for a big number, it's because it was implemented wrong. The Fermat test (or rather, a variation called the Miller-Rabin test), works on exceptionally large numbers with many many hundreds or even thousands of digits.
 
@forest implemented wrong? oh shoot
 
Not necessarily wrong, but it could have been implemented in a way that doesn't work for big numbers.
Just like you can't use simple multiplication if you want to multiply massive numbers.
 
No, it's just a Python limit. You can't store arbitrarily large integers in variables.
 
2:07 AM
specifically only 1105 and 3327 are missing
 
There are ways around it of course. It's the same with a language like C where you have to use libgmp if you want to actually handle huge numbers that are larger than can be fit in any of the C types.
 
from 1 to 10000
 
Yes, those are Carmichael numbers.
They fool the Fermat test. You'd have to use a probabilistic test like Miller-Rabin to detect those, but in your case, you can probably just hardcode the Carmichael numbers if your upper prime bound is small enough that you can enumerate them all beforehand. Use this sequence: oeis.org/A002997
In number theory, a Carmichael number is a composite number n {\displaystyle n} , which in modular arithmetic satisfies the congruence relation: b n ≡ b ( mod n ) {\displaystyle b^{n}\equiv b{\pmod {n}}} for all integers b {\displaystyle b} which are relatively prime to n {\displaystyle...
 
@forest oh shoot
is there another test that doesnt get fooled? lol
 
Yes, Miller-Rabin, but it is slower and more complex.
Yeah, hardcode the Carmichael numbers and check them prior to the Fermat test. See A002997. There aren't that many in the ranges relevant to you.
 
2:11 AM
@forest darn I checked SO the code for it is longggggggggggg
 
Yep, but it's fast.
Like I said, if you're handling small numbers (under 10,000), you can easily just hardcode the Carmichael numbers so they don't fool the Fermat test. That'll give you a nice and fast primality test that you can use.
 
"hardcode the Carmichael numbers so they don't fool the Fermat test" explain please thx lol
sorry I dont understand what you mean
 
If x is a Carmichael number
    return prime
If x is prime according to Fermat test
    return prime
else
    return composite
That's the pseudocode for what I mean. Btw, be aware that the Fermat test is probabilistic, so you may need to run it multiple times for a single input while using a different random "witness number" each time. It's still extremely fast despite that though. The Miller-Rabin test has a provable accuracy bound given random witnesses, but it is also much more complex (which it needs to be if your primes are in the hundreds of digits).
 
hmm
anyways congrats on your near 100k!
 
Oh, I am near 100k... I didn't notice that. Neat! Thanks.
 
2:16 AM
99.7k :P
tried using all(pow(k, n, n) == k for k in range(1, n)), didn't work :P - it just printed the same output
f=lambda x:(2**x-2)%x<1 or all(pow(k,x,x)==k for k in range(1,x)) complete function
either i used the wrong code or im being dumb
 
Might be. I have to go now (for real this time) though. I'll be back tomorrow, most likely.
But I'm sure other people will be able to help you before I get back.
 
@forest aww ok cya
 
cya
 
 
2 hours later…
4:38 AM
Aug 19, 2021 at 12:57, by Aaron Miller
@PyGamer0 Frick you, now I feel like I need to port Doom over to Vim, but I really don't want to.
vimdoom will sound cool
also reading that i got an idea, a Minecraft mod that runs doom
 
Exists probably
 
5:05 AM
@emanresuA yeah looks like it does
 
i think so too
 
5:22 AM
doom is so hard lol
 
5:44 AM
CMC: Make a Python program that prints 1 and a newline forever without any kind of loop or iterator
 
f=lambda _:f(print(1))
f()
 
exec("print(1);open(__file__,'r')"
 
That's missing a close-paren and just opens the file
 
exec("print(1);exec(open(__file__,'r').read())")
 
exec((s:="print(1);exec(s)"))
 
5:52 AM
@lyxal that doesn't work cuz missing "
 
So why does it fail on TIO
 
Walrus operator
 
Plain python 3 on TIO is before 3.8
 
5:54 AM
tried on py3.8 pr it worked
@lyxal why @Dennis doesn't like Python 3.8?
 
@py3_and_c_programmer it's not that Dennis didn't like it, it just wasn't released back then :p
 
there's the pre-release
 
So he doesn't care about updating :P
 
Well he hasn't been around since early 2020 I think
 
Ok forget that
What was the first Python release you worked in
Me=3.7
 
5:59 AM
2.6 probably
Might have been 2.5
 
When was it
I started in 2020
But no longer a noob
 
@py3_and_c_programmer 2014
 
I was still in kindergarten then
oh no tmi again
 
6:19 AM
0
A: Sandbox for Proposed Challenges

py3_and_c_programmerRGB to Hexadecimal and vice-versa code-golfcolor Based off a Scratch project The pen extension in Scratch has a set pen color to () block. The () is normally a color dropdown, but you can also use the join()() block. In the join()() block, normally a hex value is in the first input, but the sec...

 
@RadvylfPrograms okay for a feed, that was quick
 
@SandboxPosts this exists but is closed
 
 
1 hour later…
7:35 AM
0
A: Sandbox for Proposed Challenges

mousetailLongest Cyclic Quine Chain code-challengequine Write a program of upto 100 bytes that outputs another program that outputs another program etc. until after a finite number of iterations outputting the original program again. Each program in the cycle must have a length less than or equal to 100 b...

 
@Bubbler Ah so should I revert my challenge into Hex -> RGB or that exists too?
 
I don't see any
 
is there a challenge here on CGCC about pernicious numbers?
 
Nope
@Bubbler But since it's closed and mine has a scoring criterion, maybe I should just add that there is another question which qualifies this as a dupe but it was closed
 
probably yes
 
7:45 AM
Fine then
 
@DialFrost i didnt see any when i googled it
 
@DialFrost but why?
 
@Bubbler wanted to see if I can post it :3
 
trademarked
 
please don't post code.golf holes to cgcc
 
7:48 AM
holes?
 
it's a code.golf term for "challenges"
 
Intended for mousetail?
 
no, to DialFrost
@DialFrost ^
 
8:02 AM
@Bubbler but technically every single code.golf hole is on cgcc
 
No?
 
nearly*
evil numbers etc. etc.
 
No.
 
@Bubbler but for anarchy its fine?
 
No?
because the solutions there are eventually revealed too
 
8:07 AM
@Bubbler why not
Someone posted a question about how someone got a 41 byte solution or smth
@Bubbler ?
 
and code.golf is no fun if you can copy paste the best code from the internet
 
That's an exception
 
@Bubbler yes
unless you golf it even more
 
@emanresuA ?
 
That's an exception
 
8:09 AM
why?
@Bubbler I'm talking about anarchy here :3
 
ah you mean anarchy -> CGCC?
 
ya?
 
that's probably fine
though it doesn't mean they're actually good challenges
 
so its alright to ask how someone got (this no. of bytes which beats everyone else)?
 
Yes but it would not be as well-recieved today
 
8:12 AM
yes but if it's also related to a code.golf challenge then please don't
 
@emanresuA why so?
 
Site culture has changed a bit
 
as in, "dXwY challenges are bad, don't ask for answers in one language, etc."
 
tips questions are somewhat more permissive
so e.g. "I have this code for this task in this lang but how do I improve it?" is an ok tips question
 
@Bubbler "task" doesn't mean homework we assume
 
8:24 AM
the task being homework is fine if the OP does have working code already... I guess? :P
 
our policy on homework is ambiguous is your tone
 
well, most homework Qs are asking to solve it without the OP solving it first, and they're obviously out
 
 
2 hours later…
10:26 AM
guys
can you put multiple statements in list compre?
e.g. [hi=2;hi+=1 for x in range(5)]
 
11:04 AM
and why doesnt this work in ruby? while x<1{puts "hi"}
 
@DialFrost no, you have to use expressions
 
@PyGamer0 ah mkay
 
hello all!
 
hello!
 
how things?
 
11:18 AM
good
 
@graffe trying to use the images library in julia but everything fails so i give up :P
 
@graffe bad
 
@PyGamer0 hang on you can't just give up!
what is the exact problem?
@DialFrost oh no.. why ?
 
@graffe hang on let me just redo the steps from 3b1b's tutorial
 
@graffe I'm 58th place in ruby for fibonacci numbers and I can't find any way to golf down 4 bytes, and 81st in python (cant find any way to golf 2 bytes)
and I just realised you can do 1e6 in python :/
 
11:20 AM
@DialFrost ok that is terrible news. You have my sympathy
@PyGamer0 which julia version
 
@graffe i built from main
 
@PyGamer0 umm. what version does that make it?
 
Version 1.9.0-DEV.unknown
 
why not got for a stable release?
go for
 
23 hours ago, by PyGamer0
% jl
               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.8.2 (2022-09-29)
 _/ |\__'_|_|_|\__'_|  |
|__/                   |


SYSTEM: caught exception of type
@graffe images fails to precompile
 
11:25 AM
can you try julia 1.8.1? It's the version I am using
We can then do it step by step together
@v1.8) pkg> add Images
Updating registry at `~/.julia/registries/General`
Updating git-repo `https://github.com/JuliaRegistries/General.git`
Fetching: [========================================>] 99.9 %
this is how far I have got so far
I guess I could have gone for 1.8.2
but not a dev version
when you add Images it does take a few minutes
 
hang on
i think it fails in Pluto.jl
let me try the same code locally
 
have you successfully added Images?
 
@graffe yeah
 
it's quite exciting to look at when you add packages with all the rotating black and white circles :)
ok.. where is Pluto.jl?
let me see if I can run it
trying add Pluto
that worked
@PyGamer0 at what point does Pluto fall for you?
 
importing Images
in a notebook\
ok so update: i tried in a terminal:
https://dzaima.github.io/paste#07ZhNb@M2EIbv@RU8ukBkfVmfp8JI0k03i1043fYQBAJFjWzZkqhQVJDsYvvbO5Sd2K4lx80GKBD4JIuceT0znHlM@Hwy@TwJyRWnybkQXIREPlZAzqikf6gPM1qTkpM0gzwhdfYNTq4lZQspKIPwhNyYt2QKshK8AiEfBw9hqNxOSRqG149FzPNfTgghv5IxrYEMdfUYzvPQttDXuiWSV1oO95CTmqHE0vZvfThv8ozqFX4TnUKt/351Zukfyr@MqV4LpicYnV42RQwiUuHWStIcoaR9S7KS5U0Cg4InYfiJJ02O4UQVlTMMSYqsnHaHNHIMFBitBR7@Za@CeDk29dqGg2LOaxN8EnE8D2Xc55iW7lsxk5uszLMSklu09J4to5V0lHIR8UZWjRxUi2kYtq5fFtPL5BRtcfkpy1OSQMXlqlJ/ApNcfF9u/cC9PMqxR3p292wxXjIBEiJUr5@3v9BMfN8M5etlKd3RD3SoeSOwtzrPSn0PLrb1dV1VG7@nxLVEQzyErCTwUAmo
 
11:32 AM
@PyGamer0 I don't really understand what you have done. I just installed a completely new julia 1.8.1 install
add Pluto
import Pluto
Pluto.run()
 
i think it is a problem with my julia version then....
 
and then in the window I did import Images as you can see in the picture
can you just install a normal stable release. That is 1.8.2
 
@graffe i'll try later, i have to go now, thanks o/
 
ok no problem
it's always fun to run julia :)
 
11:49 AM
0
A: Sandbox for Proposed Challenges

Andrew ParksMultiply a positive decimal number by a positive integer power of 10 code-golf number string Inputs: A positive decimal number s as a string A positive integer exponent e, that will not exceed 100 Output: A string containing the result of multiplying s with 10^e Test cases: "9326512457371624718...

 
I still don't understand at all what this answer means, despite it being "obvious": https://codegolf.meta.stackexchange.com/a/23689/91213

Can someone explain what OP is trying to say?
 
12:06 PM
@graffe i have one complaint with julia so far, function -> fn :P
 
@PyGamer0 :)
 
rust has better keywords :P
 
wait until you see the horror of string concatenation
 
It's pretty easy, use[a, b].concat();
 
yes I meant the + vs * operators
 
12:12 PM
In what language?
 
julia
 
2
Q: Power sequence differences

The ThonnuYour task Given two positive integers \$x\$ and \$d\$ (such that \$d<x\$), output the 5th term of the \$d\$th difference of the sequence \$n^x\$ Example Let's say we are given the inputs \$x=4\$ and \$d=2\$. First, we get the series \$n^4\$: \$0^4 = 0\$ \$1^4 = 1\$ \$2^4 = 16\$ \$3^4 = 81\$ ... ...

 
@mousetail they insist, for weird reasons, that * is the right symbol for string concatenation
 
At least it's better than PHP which uses .
 
and that + is definitely not
hence the need for this package github.com/pkofod/PlusPlus.jl
 
12:15 PM
Lol now you've confused C programmers
 
:)
 
@graffe iirc that is from ... Alexander Stephanoc (his book says something about that i think)
i dont remember
and i dont remember the spelling of his name either
 
@PyGamer0 I have already argued this case to the julia devs but they don't really want to listen
 
1:17 PM
@py3_and_c_programmer They've been unusually quick lately
Almost makes me feel bad about unceremoniously executing them once NPSP is ready
 
 
1 hour later…
2:39 PM
so yesterday i posted a graph of programming language relationships, divided into 5 year segments. at the request of @emanresuA here is that with golflangs:
user image
2
 
Wow, so the only HBCS lang that doesn't get included is mine :p
 
What do the colors mean? And what is the difference between a solid and dashed line?
 
@RadvylfPrograms never knew you had one?
 
Risky, the first ½BCS here
 
@mousetail black is praclang. red is 1st gen, green 2nd gen, blue 3rd gen, purple frac byte
oops
@mousetail dashed line is an influence, while solid is descendant
 
2:44 PM
Nibbles is frac byte
Also it was inspired by GolfScript
 
@RadvylfPrograms oops forgot
 
I watched some random talk recently that said that SQL was a functional language, but it's not right?
 
@Sʨɠɠan where is flax
 
@Sʨɠɠan very nice. I didn't know Rust was a descendant of C and Erlang
 
@PyGamer0 arrgh ofc i forgot
@RadvylfPrograms what lines can i draw?
 
2:48 PM
Now add all the Esolangs
 
Is awk missing? I think that is an ancestor or perl
 
yeah i skipped a few intermediates
ill add it
 
@Sʨɠɠan It's not inspired by anything, but HBL might be inspired by it, I don't remember if DLosc was developing it in parallel with or as a response to Risky
 
cool. I am not sure Python is really closely related to C is it?
 
its more related to ABC, but wiki says c inspired it
 
2:49 PM
Yea python and C are very intertwined
 
is Julia really descended from Perl?
 
Not really the language itself but the standard library has a lot of functions with seemingly nonsensical names which are taken from C
 
@mousetail ok.. I didn't know and I program in both :)
what about the julia/perl link?
I also program in both those languages and it seems surprising
 
@graffe wikipedia listed quite a lot more that i decided to leave out
 
I think lisp is much closer
Maybe julia stands for “Jeff’s uncommon lisp is automated”?
as they say
 
2:53 PM
some langs i connected myself knowing syntax and stuff, but idk julia
 
I would connect it to list if you want one connection
 
yes I see perl in the list ". To achieve this, Julia builds upon the lineage of mathematical programming languages, but also borrows much from popular dynamic languages, including Lisp, Perl, Python, Lua, and Ruby."
but I don't know why it is there
in any case lisp is the main one
@Sʨɠɠan I've ask about perl on the julia slack
apparently the connection is PCRE
 
00:00 - 15:0015:00 - 00:00

« first day (4294 days earlier)      last day (557 days later) »