@Lossberg by the way, I do a #toyprogrammingchallenge here, you can look at the origination of it all the way back the 'Ninety-Nine Bottles of Beer" challenge. https://qoto.org/@Absinthe/102805659580967435
Feel free to play at any of them that interest you. There is no timebox on these. Watch for the tag #toyprogrammingchallenge and include it on any answers you offer to any of them.
Okay folks, this should be simple, but maybe not.
The goal is to write a function that takes a positive integer and returns a list of its prime factors. So if you did 12 you should get the list [2, 2, 3]
As neither 1 nor zero are prime, as a result should return an empty list.
This is taken from a #tdd #Kata, so if you have not done this one I encourage you to do so. If you are not into #TDD then solve it however you like.
#coding #codingclub #club #programming #programmingclub
Is anyone interested in, or has anyone been a part of a programming or coding club?
#tdd #kata #vim #python #testfirst
This is for python, but could be easily tweaked for any other development system.
Your suggestions and opinions are appreciated.
If you like to do code kata and you like to use Vim, here is a script that will create your 2 starter files (<kataname>.py and test_<kataname>.py)
#!/bin/sh
#
# kata, a script for starting up a new kata exercise
#
# Given a name for the kata the script will create 2
# files. One with the same name as the kata with '.py'
# extension added to the end and another named 'test_'
# followed by the kata name and '.py' extension. It will
# be opened in a 3 window layout of Vim with a vertical
# terminal to the left in which you can run 'pytest' or
# 'python -m unittest' or whatever appropriate runner
# you use.
#
# If these files don't alreay exist they will be created
# with an import , and basic docstrings.
#
if [ $# -eq 0 ]; then
printf "Usage:\n\t $0 <kataname>\n"
exit 0
fi
if [ ! -f "$1.py" ]; then
printf '"""%s module."""\n\n' "$1" > "$1.py"
fi
if [ ! -f "test_$1.py" ]; then
printf '"""Unit tests for %s module."""\n\n\n' "$1" > "test_$1.py"
printf 'import %s\n\n' "$1" >> "test_$1.py"
fi
vim -c ':vert topleft term' -c 'wincmd p' -o "$1.py" "test_$1.py"
TDD is awesome. #TDD is anyone out there using TDD? Anyone learning to use TDD? Do you want to?
@Absinthe It is non-intrusive on spacemacs and doom-macs. If you know the command you type it so quickly the help at the bottom never shows. If you dont know the command and stop half way through it shows after a few ms delay. So it only shows when its needed and even then doesnt really get in the way
@Absinthe What i like about vim is the keys are easy to remember, its why i like evil-mode flavors like spacemacs. The popup help as you type in spacemacs and doom-macs though is a clear winning feature for me
@Absinthe Actually last I checked in 2019 vim was still a pretty strong choice among developers. Checkout the stackoverflow survey it goes into some crazy detail.
@Absinthe yea Spacevim, but its far less popular. I've never done a real deep dive on vim or emacs until lately. So I'm really not sure what Vim would offer me that Emacs + Evil wouldnt.
i find it very interesting that consent is mainly discussed within sexual scenarios
but i promise you need consent for any/every interaction online and offline. it’s not just for sex. it’s for hugs, for DMs, for flirting, for following, for collecting personal information too
just like. ask before doing things u giant doinks
exploiting intellectuals for my mathematical needs
While pondering about a pointless optimization of a pointless feature of one of my pointless projects, I stumbled upon a #toyprogrammingchallenge similar to this one
https://qoto.org/@Absinthe/103194125533950090
but different.
A couple of ways to put it.
Colloquial(mathy jargon):
Given a prime factorization of a number, generate all of its factors(prime or otherwise) in ascending order.
Down to code(with fumbling):
Given a multiset(in ascending order) of prime numbers, generate all numbers... whose prime factors are subsets of that set... too mathy?... maybe then "that can be obtained by multiplying numbers from that set together"... in ascending order.
Examples:
Input: 30 = (2,3,5)
Output: ([1,]2,3,5,6,10,15[,30])
Input: 60 = (2,2,3,5)
Output: ([1,]2,3,4,5,6,10,12,15,20,30[,60])
Oh, one thing, @Absinthe what programming language are you using for AoC? I was using Rust.