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 user‭

Type On... Excerpt Status Date
Answer A: Length of a Sumac Sequence
[Scala], 83 bytes x=>x.init#::Stream.iterate(x)(x=>x++(x,x.tail).zipped.map(-))indexWhere(.last //List(t1, t2) a.k.a. the second partial sequence x.init //List(t1) a.k.a. the first partial sequence #:: //prepended to Stream //an infinite stream of partial sequences .iterate(x) ...
(more)
about 3 years ago
Edit Post #281460 Post edited:
about 3 years ago
Edit Post #281460 Post edited:
about 3 years ago
Edit Post #281460 Post edited:
about 3 years ago
Comment Post #281459 @Quintec Oh, I just realized that the really cool definition includes all divisors, not just the proper divisors.
(more)
about 3 years ago
Edit Post #281460 Initial revision about 3 years ago
Answer A: Really Cool Numbers
[APL (Dyalog Unicode)], 30 29 bytes Saved 1 byte thanks to Razetime (could've saved 1 more with a tradfn, but I didn't feel like it) {∧/(0=1|+/÷≢)¨1↓¨g¨(g←∪⊢∨⍳)⍵} Try it online! This answer was incorrect before because it only checked if the number's proper divisors were cool,...
(more)
about 3 years ago
Edit Post #281421 Post edited:
about 3 years ago
Edit Post #281421 Initial revision about 3 years ago
Answer A: Truthify an array
Scala 3, 68 bytes ```scala .zipWithIndex.flatMap(.zipWithIndex.filter(.1)map(.2)map .->) ``` Try it in Scastie! Takes a `List[List[Boolean]]`, returns a `List[(Int, Int)]`. This abuses underscores a bit (which is why Scala 3 is needed), but I'm proud of it. Explanation: ```scala .zipWithI...
(more)
about 3 years ago
Edit Post #281389 Post edited:
about 3 years ago
Comment Post #281401 These look awesome. Do you have explanations?
(more)
about 3 years ago
Comment Post #279422 Python tries to evaluate while parsing, and I guess it can't handle something that big.
(more)
about 3 years ago
Edit Post #281389 Post edited:
about 3 years ago
Edit Post #281389 Post edited:
about 3 years ago
Edit Post #281389 Initial revision about 3 years ago
Answer A: Beaver Code Decryption
APL(Dyalog Unicode), 34 29 bytes SBCS Saved 5 bytes thanks to Razetime! ``` {2>s←⌈2÷⍨≢⍵:⍵⋄,⍉↑∇¨s(↑,⍥⊂↓)⍵} ``` Try it on APLgolf! ``` {2>s←⌈2÷⍨≢⍵:⍵⋄,⍉↑∇¨s(↑,⍥⊂↓)⍵} { } ⍝ Define a dfn taking argument ⍵ s→ ⍝ s will be the size of on...
(more)
about 3 years ago
Edit Post #281387 Initial revision about 3 years ago
Answer A: Obligatory Quine Challenge
Scala 3, 80 bytes ```lang-scala @main def m={val s="@main def m={val s=%c%s%1$c;printf(s,34,s)}";printf(s,34,s)} ``` Try it in Scastie! The `printf` replaces `%c` and `%1$c` in string `s` with the quote character (34 in decimal), and replaces `%s` with the contents of `s`.
(more)
about 3 years ago
Comment Post #279770 @dzaima There is if you're willing to go into Unicode (`⩘` and others), but I guess that'd just make it really complicated and would be difficult for languages without Unicode.
(more)
about 3 years ago
Edit Post #281372 Post edited:
about 3 years ago
Comment Post #281371 I don't know, there's a template for reading the stuff in the code section, but I usually do something like [this](https://tio.run/##SyzI0U2pTMzJT///P@1R2wQNQwXDR72d2jGajzpm6Nk@6l3x/1HfVKCEQpoCUErBCAwNwdBYwZgLLmmsYK5gqmCiYAmUNgZiMwWz/wA) and then subtract 2 bytes.
(more)
about 3 years ago
Edit Post #281372 Post undeleted about 3 years ago
Edit Post #281372 Post edited:
about 3 years ago
Edit Post #281372 Post edited:
about 3 years ago
Comment Post #281371 Btw, since this isn't a train, you might want to add a `⎕` to the end and make it a tradfn that takes input from stdin.
(more)
about 3 years ago
Edit Post #281373 Post edited:
about 3 years ago
Edit Post #281373 Initial revision about 3 years ago
Answer A: Cumulative Counts
Scala 3, 50 44 bytes ```scala ? => ?.indices zip?map(?take +1 count .==) ``` Try it in Scastie! This is an annoying, stupid approach. The more elegant one using `inits` was much longer (`x=>x.inits.toSeq.reverse.tail zip x map( count .==)`). ```scala ? => //The input ?.indices //The ind...
(more)
about 3 years ago
Edit Post #281372 Post deleted about 3 years ago
Edit Post #281372 Initial revision about 3 years ago
Answer A: Cumulative Counts
[APL (Dyalog Unicode)], 11 7 bytes (SBCS) Razetime and rak1507 came up with 7 byte equivalents of my original dfn (this one's rak1507's). See their solutions below. +/¨⊢=,\ Try it online! ``` +/¨⊢=,\ ,\ ⍝ Prefixes of the list = ⍝ Compare every prefix ⊢ ⍝ to...
(more)
about 3 years ago
Edit Post #281287 Post edited:
about 3 years ago
Edit Post #281287 Initial revision about 3 years ago
Answer A: Output 256 in many different ways
Scala (`-language:postfixOps`), 4 solutions 1. Just 256: ``` 256 ``` 2. Casting a character: ``` +'Ā' ``` The character `Ā` is 256 in decimal, and the unary `+` turns it into an `Int`. 3. Hashcode of a string: ``` ""## ``` There are two backspace characters in the string (\u0008...
(more)
about 3 years ago
Edit Post #281286 Initial revision about 3 years ago
Answer A: Solve Goldbach's Conjecture
[APL (Dyalog Unicode)], 32 bytes (SBCS) {⊃(⊢(/⍨)⍵=+/¨),∘.,⍨(⊢∘.×)⍨1↓⍳⍵} Try it online! ``` {⊃(⊢(/⍨)⍵=+/¨),∘.,⍨(⊢∘.×)⍨1↓⍳⍵} ⍳⍵ ⍝ Range from 1 to n 1↓ ⍝ Drop the 1st number (make 2 to n) (⊢∘.×)⍨ ...
(more)
about 3 years ago
Edit Post #281285 Initial revision about 3 years ago
Answer A: Tips for golfing in Scala
Making a function with `val` can be shorter than with a `def` If you're pattern matching, you can use Scala's special syntax and omit `match` when assigning an anonymous function to a `val`. As you can see, it's a lot shorter: ```scala val g:List[Int]=>Int={case h::t=>h+g(t)case =>0} def f(l:Li...
(more)
about 3 years ago
Edit Post #281284 Initial revision about 3 years ago
Question Tips for golfing in Scala
What general tips do you have for golfing in Scala? I'm looking for ideas that can be applied to code golf problems in general that are at least somewhat specific to Scala (e.g. "remove comments" is not an answer). This has been copied from a tips question on Code Golf SE.
(more)
about 3 years ago
Comment Post #280785 "the index of each element is preserved" That suggests A1, B1, and C1 are *all* at index 1 in the output. I feel like you could remove that sentence, since the sentence after it is clear enough.
(more)
about 3 years ago
Edit Post #281084 Initial revision about 3 years ago
Answer A: Word Set Square
Scala, 99 bytes ```scala s=>{val x=s+s.reverse s(0)+"\n"+x.tail.init.zipWithIndex.map{case(c,i)=>c+" "i+c+"\n"}.mkString+x} ``` Try it in Scastie!
(more)
about 3 years ago
Edit Post #281031 Initial revision about 3 years ago
Answer A: Reverse an ASCII string
Scala, 9 bytes ```scala .reverse ``` Try it in Scastie! Explanation: ``` .reverse //The function argument . //Call a method reverse //Reverse the string ```
(more)
about 3 years ago
Edit Post #281027 Initial revision about 3 years ago
Answer A: Partial Sums of Harmonic Series
[Scala], 55 bytes (Stream from 1 map 1.0./scanLeft.0)(+)indexWhere . Stream.from(1).map(1.0/).scanLeft(0.0)(+).indexWhere( >= n) ``` Explanation: ```scala ( Stream from 1 //Make an infinite list of integers, starting at 1 map 1.0./ //Find the reciprocal of each (d...
(more)
about 3 years ago