Activity for __blackjack__
| Type | On... | Excerpt | Status | Date |
|---|---|---|---|---|
| Comment | Post #295629 |
Groups can be accessed by indexing the match object: `match.group(0)` → `match[0]`. And the `$` at the end should be unnecessary. We don't really mind _where_ the empty string is matched. :-) (more) |
— | 6 months ago |
| Comment | Post #284061 |
`r=reversed;print(*r(x),*r(y))` is one byte shorter. (more) |
— | 6 months ago |
| Edit | Post #295619 |
Post edited: One byte less. |
— | 6 months ago |
| Edit | Post #295624 | Initial revision | — | 6 months ago |
| Answer | — |
A: Single digit Roman numeral Python 3.8+, 49 byte ```python lambda c:5((i:="IVXLCDM".find(c))&1)10(i>>1) ``` Testing: ```python f=lambda c:5((i:="IVXLCDM".find(c))&1)10(i>>1) print(map(f,"IVXLCDM")) ``` 52 bytes My first attempt. Really simple and straight forward. If the rules would allow `1000.0` as r... (more) |
— | 6 months ago |
| Edit | Post #295619 | Initial revision | — | 6 months ago |
| Answer | — |
A: The 50 substrings that validate any string of Roman numerals Python, 205 bytes Coding the string with the substrings as base 95 number is the shortest I get with this approach: ```python n=0 for c in"),|9'OJ#SdHlCSD(LqRhc.|)#s]`N:?foSIb.BJVa=AH^).&&we(E^5J{,":n=n94+ord(c)-32 S="" while n:S+=" IVXLCDM"[n&7];n>>=3 f=lambda s:next((a for a in S.spl... (more) |
— | 6 months ago |
| Comment | Post #285833 |
In Python 3.8 this will print a `SyntaxWarning: "is not" with a literal. Did you mean "!="?`. (more) |
— | over 3 years ago |
| Comment | Post #287054 |
@#53588 I know what that is, and it feels a bit useless to me here because it isn't called and can't be called from somewhere else because it has no name or other means to actually reference it in a call. So `f=` would have to be included to be callable at all.
Well, IMHO. As @#53890 pointed ... (more) |
— | almost 4 years ago |
| Comment | Post #287054 |
Moving the `f=\` into the header feels like cheating to me. This is two bytes longer to be actually usable/callable. (more) |
— | almost 4 years ago |
| Comment | Post #287050 |
Thanks for the heads up and done. 🙂 (more) |
— | almost 4 years ago |
| Edit | Post #287050 |
Post edited: Inserted crossed out former size. |
— | almost 4 years ago |
| Edit | Post #287050 |
Post edited: Saved one byte by replacing `x if c else y` by `c and x or y` |
— | almost 4 years ago |
| Comment | Post #287050 |
I thought of that but it means always calculating both results and then pick one, but `m` must be at least 1 for this to work because if it is 0 then `int(D,m+1)` will raise a `ValueError: int() base must be >= 2 and <= 36, or 0`. (With `0` meaning that `int()` will parse the first argument like... (more) |
— | almost 4 years ago |
| Edit | Post #287050 | Initial revision | — | almost 4 years ago |
| Answer | — |
A: Presumptuous base conversion Python 3, 60 59 bytes ```python D=input();m=int(max(D),16);print(m and int(D,m+1)or len(D)) ``` Quite straight forward implementation. Input string is assigned to `D`. `m` is the the `max()` letter in `D` converted to `int()` with base 16. `max()` works because Python strings/chara... (more) |
— | almost 4 years ago |
| Edit | Post #287038 | Initial revision | — | almost 4 years ago |
| Answer | — |
A: "Hello, World!" Z80 Assembler, 50 bytes ```z80asm org 256 ld de,m ld c,9 jp 5 m:db"Hello, world!\r$" ``` With assembler there's usually the problem which machine or operating system the program is for. I've chosen CP/M here as it runs on a variety of different machines with a Z80 processor. CP/M p... (more) |
— | almost 4 years ago |
| Comment | Post #282457 |
`r=str.replace;print(r(str(eval(f"({r(r(input(),' ', ')*('),'i','j')})")).strip("()"),"j","i"))` (more) |
— | about 4 years ago |
| Edit | Post #286962 | Initial revision | — | about 4 years ago |
| Answer | — |
A: Multiply complex numbers. Python 3, 63 bytes ```python print(str(eval(f"({input().replace(' ',')(')})")).strip("()")) ``` Try it online! Similar to hyper-neutrino's answer. Doesn't replace i by j and back, and uses f-string instead of strings and `+` to make it a bit shorter. (more) |
— | about 4 years ago |
| Edit | Post #286920 |
Post edited: `list()` replaced by `[*…]` |
— | about 4 years ago |
| Edit | Post #286924 | Initial revision | — | about 4 years ago |
| Answer | — |
A: Cumulative Counts Python 3, 70 bytes ```python def f(a): d={};r=[] for x in a:d[x]=d.get(x,0)+1;r+=[d[x]] return r ``` Try it online! (more) |
— | about 4 years ago |
| Comment | Post #286920 |
Why a comment and not an answer? (more) |
— | about 4 years ago |
| Edit | Post #286920 |
Post edited: Shortened import. |
— | about 4 years ago |
| Edit | Post #286920 | Initial revision | — | about 4 years ago |
| Answer | — |
A: Find n Niven Numbers Python, 98 bytes ```python from itertools import f=lambda n:[islice(filter(lambda k:k%sum(map(int,str(k)))==0,count(1)),n)] ``` `itertools.count()` generates integer numbers starting from 1, `filter()` filters out the Niven numbers, `itertools.islice()` limits the result to `n` item... (more) |
— | about 4 years ago |
