Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »

Activity for trichoplax‭

Type On... Excerpt Status Date
Comment Post #291390 From the Output section: > Your output is valid if rounding it to $6$ decimal places results in the output shown in the relevant test case. Note that the competing code does not need to round the output, only to produce output that would match the test cases if it were rounded. So the Python co...
(more)
11 days ago
Comment Post #291320 Interesting. I understand now. Note that the code is no longer restricted to just that one version of Python - it works in the latest version (3.12) just fine. If you change the language in the heading back to just "Python" then the leaderboard will group this answer correctly with the other Pytho...
(more)
24 days ago
Comment Post #291320 No need to apologise. I don't feel that I have any obligation to test answers, I just sometimes like to out of curiosity. I see you have since made the code even shorter. I have no idea how it works, but it does...
(more)
26 days ago
Comment Post #291320 I know this isn't consistent with how semantic versioning is supposed to work, but it's my best current guess at why it doesn't work on my machine. I suppose it's also possible there's an inconsistency between operating systems. I tested this on Linux (Fedora 39), on python 3.8.19, 3.9.19, 3.10.14...
(more)
27 days ago
Comment Post #291320 It looks like there was a lot of discussion about whether to permit assignment expressions in comprehensions when they were first introduced in python 3.8. It may be that a change was made to python 3.9 after the version you are using. When I run the 222 byte version on python 3.9.19 I get an error m...
(more)
27 days ago
Comment Post #291299 Would it still work if you replace ```python range(3) ``` with ```python 0,1,2 ```
(more)
about 1 month ago
Comment Post #287238 Testing a texts
(more)
about 2 months ago
Comment Post #291091 I've edited the Test cases section to clarify this flexibility.
(more)
about 2 months ago
Comment Post #291091 When the input is a valid Roman number, the output does not need to be specifically the string "VALID". From the first bullet point of the Output section, you just need to "output a consistent value" which "must not be one of the strings from the list of 50". Hopefully this saves you some bytes.
(more)
about 2 months ago
Comment Post #291002 I have now edited to change the challenge to match the previous comment. Is there any problem with this? Anything to improve?
(more)
2 months ago
Comment Post #291002 Another possible challenge: Given a string of Roman numerals, output either "valid" or a string from the list of 50 that proves it invalid. This may involve the Kolmogorov complexity challenge as a subchallenge. Is this good or bad?
(more)
2 months ago
Comment Post #291002 As written, the challenge is simply to validate a string of Roman numerals. I suspect that in most languages the golfiest way will be regex, and the list of 50 substrings will not be used. As such, they are irrelevant background info about Roman numerals, rather than being part of the challenge. I'm ...
(more)
2 months ago
Comment Post #290667 I find this much more clear. Potential improvements: - The explanation section at the end could be broken up with subheadings or a numbered list. - The heading "Explanation" might be better changed to something that makes immediately clear that this section is optional. Perhaps "Background" or "R...
(more)
3 months ago
Comment Post #290667 This appears to be an interesting challenge, wrapped up in an interesting but unnecessary concept. The challenge would work without the concept, and be understood by more people. For this reason, my personal preference would be to have the simple statement of the problem at the start of the challe...
(more)
4 months ago
Comment Post #290615 Yes, this is a valid solution - it meets all the challenge requirements. No need for HTML specification compliance here...
(more)
4 months ago
Comment Post #290590 Nice solution. 31 bytes is much better than I was expecting for the first answer. > The best solution is frequently the easiest one. Does this mean you believe 31 to be optimal? I suspect 30 is possible...
(more)
4 months ago
Comment Post #290200 I believe convention is to include any imports in the total length of the code. I couldn't find a Meta post specifically about this, but it is mentioned in an answer to another Meta post: - [Default Rules: Libraries](https://codegolf.codidact.com/posts/282802/282803#answer-282803) > However, yo...
(more)
6 months ago
Comment Post #287238 When you say "test program" do you mean a program to test answers, or an example implementation?
(more)
7 months ago
Comment Post #287238 I try to post a range of golf challenges, because some people want a very simple challenge that they can tackle quickly on a short break, while other people enjoy a more complex challenge. I expect some people prefer different levels of complexity at different times. I acknowledge that this is not...
(more)
7 months 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)
7 months 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)
7 months 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)
7 months 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)
7 months 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)
7 months 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)
7 months 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)
7 months 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)
7 months 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)
7 months 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)
7 months 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)
7 months ago
Comment Post #290027 Same point, just smaller probabilities. Only a suggestion - it's your call.
(more)
7 months 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)
7 months 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)
7 months 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)
7 months 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)
7 months ago
Comment Post #289926 I hadn't though of `or`. Even better.
(more)
7 months 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)
7 months 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)
7 months 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)
7 months 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)
7 months 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)
7 months 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)
7 months ago
Comment Post #289866 Good idea - for this challenge even the non-golfed code should be short. I have an implementation in Rust that I've been using to check test cases, but maybe I'll write some example code in Python to include in the challenge wording.
(more)
8 months ago
Comment Post #289866 Thank you! For the largest input I might go with 255 or 127 for 8 bit integers, or maybe 65535 or 32767 for 16 bit integers. I'll have a think. Whichever upper bound I settle on, I'll include some test cases that include it.
(more)
8 months ago
Comment Post #289866 Good question. I'm now torn between - allowing input to be already sorted, to reduce the challenge down to its simplest form - requiring code to handle input in any order, to create competition between approaches that don't require sorting, and approaches that require sorting but where the cost of ...
(more)
8 months ago
Comment Post #287139 Thank you! And thanks for the saved byte - it made me realise I should adjust my generating code to sort by fruit length in bytes (which resulted in a similar replacement to your suggestion, for the same number of bytes).
(more)
8 months ago
Comment Post #289782 One thought which makes me lean towards keeping it a single question: The line between different types is not always clear. Some languages have floating point for non-integer values, other languages have fixed point, or an arbitrary precision decimal or rational type. Since there might be some ove...
(more)
8 months ago
Comment Post #289782 So I think splitting answers will be needed even if this is split into more questions. I don't personally see a need to split this question, but I don't see a problem with splitting it either.
(more)
8 months ago
Comment Post #289782 Similarly if an answer gives 2 rules for string length, they cannot be separately voted on. For example, if someone says "string inputs only have to be supported up to N characters" but also says "for language X it's M characters" then someone may agree with the general rule but not with the exceptio...
(more)
8 months ago
Comment Post #289782 I was commenting as a hint to answerers. I don't see a problem with several related rules being discussed under one question - that's similar to how the other "default-rules" questions work. The concepts you have listed in the question are all very closely related, so I like them being in one ques...
(more)
8 months ago