Activity for trichoplax
Type | On... | Excerpt | Status | Date |
---|---|---|---|---|
Edit | Post #287238 |
Post edited: Add extra consideration about negative offsets to Sandbox questions |
— | over 1 year ago |
Edit | Post #287238 |
Post edited: Consider whether to limit offsets to less than grid width and height. |
— | over 1 year ago |
Comment | Post #290106 |
I see what you mean. I tried the `map` without the parentheses and it fails, and I tried omitting the `map` and just applying to a single argument `'I'` and again it only works with the parentheses. Sorry for the false hope... (more) |
— | over 1 year ago |
Edit | Post #287238 |
Post edited: Format terminology section for clarity |
— | over 1 year ago |
Edit | Post #287238 |
Post edited: Be explicit about restricting offsets to be coprime |
— | over 1 year ago |
Comment | Post #290106 |
I don't know Haskell, but I tested your latest code using the following:
```haskell
main = do
let result = map(\n->(scanl(*)1$cycle[5,2])!!(length$takeWhile(/=n)"IVXLCDM")) ['I', 'V', 'X', 'L', 'C', 'D', 'M']
print result
```
This gives the correct results for all inputs:
```text... (more) |
— | over 1 year ago |
Comment | Post #290104 |
To summarise the difference between `def` and `lambda` in Python, the following give equivalent results:
```python
def double(n):
return n * 2
```
```python
double = lambda n: n * 2
``` (more) |
— | over 1 year ago |
Comment | Post #290104 |
```python
def f(n):i="IVXLCDM".index(n);return(4*(i%2==1)+1)*10**(i//2)
```
This can be tested as follows:
```python
def f(n):i="IVXLCDM".index(n);return(4*(i%2==1)+1)*10**(i//2)
for c in "IVXLCDM":
print(c, f(c))
``` (more) |
— | over 1 year ago |
Comment | Post #290104 |
```python
lambda n:(4*("IVXLCDM".index(n)%2==1)+1)*10**("IVXLCDM".index(n)//2)
```
This can be tested as follows:
```python
f=lambda n:(4*("IVXLCDM".index(n)%2==1)+1)*10**("IVXLCDM".index(n)//2)
for c in "IVXLCDM":
print(c, f(c))
``` (more) |
— | over 1 year ago |
Comment | Post #290104 |
I haven't tested the Haskell code, but there's a problem with the Python code that I'll explain below.
In Python, a lambda function cannot have multiple statements. If you try to run the current code, it will give an error. I can think of 2 different approaches to avoid this problem:
- Use a `lam... (more) |
— | over 1 year ago |
Comment | Post #290106 |
The same applies to this answer as I [mentioned on your Python answer](https://codegolf.codidact.com/comments/thread/8720#comment-22430). It just needs an input method to make it valid. (more) |
— | over 1 year ago |
Comment | Post #290104 |
Welcome to Code Golf Codidact!
We have a guide to acceptable input and output methods on Meta, and this currently only specifies that [input may be taken by direct insertion into the source code for languages that have no other option](https://codegolf.codidact.com/posts/282784/282794#answer-28279... (more) |
— | over 1 year ago |
Edit | Post #289996 |
Post edited: Explicitly exclude output as a Roman numeral |
— | over 1 year ago |
Comment | Post #289996 |
Good point. I will edit to make explicit that output in Roman numerals is not acceptable.
As for choosing a text encoding where the output always equals the input, I would likely vote to agree that should be a forbidden loophole if you added it to [Code Golf - Default Rules: Loopholes](https://cod... (more) |
— | over 1 year ago |
Comment | Post #289996 |
I'm happy to stick with the [defaults for I/O](https://codegolf.codidact.com/posts/282784) unless there's some loophole I need to close.
One of the answers there mentions using a character code instead of a number, which would allow outputting 1000 as "Ϩ" (unicode codepoint U+03E8) but I'm not sur... (more) |
— | over 1 year ago |
Edit | Post #287238 |
Post edited: Consider excluding words that use the same grid position more than once |
— | over 1 year ago |
Comment | Post #290065 |
Nice challenge!
Nothing broken, but just an observation in case it wasn't intentional: I notice that the test cases match the examples, with the exception of the example "TWO BIRDS WITH TWO STONE", where the test case differs: "TWO BIRDS WITH ONE STONE".
Both still work so nothing needs changin... (more) |
— | over 1 year ago |
Comment | Post #290027 |
Same point, just smaller probabilities. Only a suggestion - it's your call. (more) |
— | over 1 year ago |
Edit | Post #290000 |
Post edited: Reduce input range to make room for formatting within the post length limit |
— | over 1 year ago |
Edit | Post #290000 |
Post edited: Emphasise key terms at the point of their introduction |
— | over 1 year ago |
Comment | Post #287403 |
I decided to go with negative and zero inputs. I restricted the input range to -72 to 72 so that no output would be more than 8 characters long, but the test cases exceeded the post length limit, so I further restricted the input range to -62 to 62. (more) |
— | over 1 year ago |
Edit | Post #287403 |
Post edited: Mark as finalized |
— | over 1 year ago |
Edit | Post #290000 | Initial revision | — | over 1 year ago |
Question | — |
Shortest representation in generalised Roman numerals Find the shortest representation of an integer in generalised Roman numerals. Since there is more than one way to generalise, only the following definition applies to this challenge. Definition The digits used are the same as standard Roman numerals: Digit|Value |----: I|1 V|5 X|10 L|50 C|10... (more) |
— | over 1 year ago |
Edit | Post #287403 |
Post edited: Adjust input range for test cases excluded by post length limit |
— | over 1 year ago |
Edit | Post #287403 |
Post edited: Add back in test cases excluded by post length limit |
— | over 1 year ago |
Edit | Post #287403 |
Post edited: Add test cases and clarifications |
— | over 1 year ago |
Comment | Post #287403 |
Having written some code to generate test cases, the negative inputs take significantly more time to solve, so if I include them I will keep the size of inputs that you are required to accept fairly small. (more) |
— | over 1 year ago |
Edit | Post #287403 |
Post edited: Remove ambiguity for prefix and suffix calculation explanation |
— | over 1 year ago |
Edit | Post #287403 |
Post edited: Apply consistent full stops for lists of sentences |
— | over 1 year ago |
Edit | Post #287403 |
Post edited: Use more consistent ordering for negative input example |
— | over 1 year ago |
Edit | Post #289956 |
Post edited: Mark as finalized |
— | over 1 year ago |
Edit | Post #289996 | Initial revision | — | over 1 year ago |
Question | — |
Single digit Roman numeral Given a single character, which is a valid Roman numeral, output its value. Values There are 7 valid single character Roman numerals, with the following values: Character | Value | ----: I | 1 V | 5 X | 10 L | 50 C | 100 D | 500 M ... (more) |
— | over 1 year ago |
Edit | Post #287403 |
Post edited: Include negative input and zero input |
— | over 1 year ago |
Comment | Post #287403 |
Now that I have noticed this, I am inclined to include both zero and negative integers as possible inputs, but I'll wait to see if anyone has reason to avoid either/both. (more) |
— | over 1 year ago |
Comment | Post #287403 |
Standard Roman numerals only support positive integers.
This particular generalisation of Roman numerals happens to be able to represent zero and negative integers. Should code be required to support these, or should inputs only be positive integers?
## Examples
- `VVX` is **10** - (**5** + **... (more) |
— | over 1 year ago |
Edit | Post #287403 |
Post edited: Use table instead of code block for definition section |
— | over 1 year ago |
Edit | Post #289956 |
Post edited: Right align numbers in table |
— | over 1 year ago |
Edit | Post #289956 | Initial revision | — | over 1 year ago |
Article | — |
Single character Roman numeral [FINALIZED] Now posted: Single digit Roman numeral Given a single character, which is a valid Roman numeral, output its value. Values There are 7 valid single character Roman numerals, with the following values: Character | Value | ----: I | 1 V | 5 X | 10 L | 50... (more) |
— | over 1 year ago |
Comment | Post #289926 |
I hadn't though of `or`. Even better. (more) |
— | over 1 year ago |
Comment | Post #289926 |
This applies in python, because `and` has lower precedence than the comparison operators, while `&` has higher precedence than the comparison operators.
I'm not familiar with SageMath but if it uses [the same operator precedence rules as python](https://docs.python.org/3/reference/expressions.html... (more) |
— | over 1 year ago |
Comment | Post #289926 |
In general they will take the same number of bytes in cases where `&` requires parentheses for operator precedence but `and` does not:
```python
(X)&(Y) # 7 bytes
X and Y # 7 bytes
```
However, in the specific case where `and` follows a digit, the space before the `and` can be omitted ... (more) |
— | over 1 year ago |
Comment | Post #289926 |
I know that sounds counterintuitive. In python the parentheses are redundant with `and`, because it has lower precedence than the comparison operators. (more) |
— | over 1 year ago |
Edit | Post #289926 |
Post edited: Typos |
— | over 1 year ago |
Suggested Edit | Post #289926 |
Suggested edit: Typos (more) |
helpful | over 1 year ago |
Comment | Post #289926 |
[Rules for function submissions](https://codegolf.codidact.com/posts/286366/286367#answer-286367) suggests that in a language where a function can be used without naming it, the naming does not need to be included in the answer.
In your case, if SageMath allows using a lambda directly (such as usi... (more) |
— | over 1 year ago |
Comment | Post #289926 |
In testing my example code for the challenge wording I discovered the same problem - the `gcd` function would only accept 2 arguments. It turned out I was using an old version of Python. [From version 3.9 onwards it supports arbitrarily many arguments](https://docs.python.org/3.9/library/math.html#ma... (more) |
— | over 1 year ago |
Comment | Post #289925 |
From the challenge wording:
> You will also take an integer `i` as input and then either:
> - Output the `i`<sup>th</sup> term (0-indexed or 1-indexed, but please specify) of the `n`-based sequence,
> - Output the the first `i` terms of that sequence, or,
> - Forego taking `i` as input and outp... (more) |
— | over 1 year ago |