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 »

Posts by user‭

68 posts
77%
+5 −0
Challenges Juggler sequences

Scala, 78 67 64 bytes Saved 3 bytes thanks to Razetime Stream.iterate(_)(x=>math.pow(x,x%2+.5).toInt).takeWhile(_>1):+1 Try it in Scastie! Stream.iterate(_) //Make an infinite list by r...

posted 3y ago by user‭  ·  edited 3y ago by user‭

Answer
80%
+6 −0
Challenges Golf a FRACTRAN interpreter

APL (Dyalog Unicode), 33 bytes {×x←⊃(2⌷⍵)(÷⍨(/⍨)0=|)⍺×1⌷⍵:x∇⍵⋄⍺} Try it online! The first case doesn't work because it gets really big, but the other two do. The input is taken on the left a...

posted 3y ago by user‭  ·  edited 3y ago by user‭

Answer
71%
+3 −0
Challenges Make my number a set

Haskell, 51 31 bytes Saved 20 bytes thanks to Hakerh400! data S=S[S] f i=S$map f[0..i-1] Try it online! S is a recursive data structure, because sets of varying element types can't be repr...

posted 3y ago by user‭  ·  edited 3y ago by user‭

Answer
75%
+4 −0
Challenges Make my number a set

APL (ngn/apl), 6 bytes {∇¨⍳⍵} Try it online! Dyalog APL and dzaima/APL appear to not give empty vectors for ⍳0, so I used ngn/APL. I don't know how to turn on boxing there, though, so there'...

posted 3y ago by user‭

Answer
66%
+2 −0
Challenges Length of a Sumac Sequence

Scala, 83 bytes x=>x.init#::Stream.iterate(x)(x=>x++(x,x.tail).zipped.map(_-_))indexWhere(_.last<1) Try it online! Takes input as a list of two numbers. The fact that the length can...

posted 3y ago by user‭  ·  edited 3y ago by user‭

Answer
60%
+1 −0
Challenges 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 w...

posted 3y ago by user‭  ·  edited 3y ago by user‭

Answer
66%
+2 −0
Challenges Truthify an array

Scala 3, 68 bytes _.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 ...

posted 3y ago by user‭  ·  edited 3y ago by user‭

Answer
66%
+2 −0
Challenges 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(↑,⍥⊂↓)⍵} { } ...

posted 3y ago by user‭  ·  edited 3y ago by Shaggy‭

Answer
71%
+3 −0
Challenges Obligatory Quine Challenge

Scala 3, 80 bytes @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 i...

posted 3y ago by user‭

Answer
60%
+1 −0
Challenges Cumulative Counts

Scala 3, 50 44 bytes ? => ?.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.to...

posted 3y ago by user‭  ·  edited 3y ago by user‭

Answer
66%
+2 −0
Challenges 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! +/¨...

posted 3y ago by user‭  ·  edited 3y ago by user‭

Answer
75%
+4 −0
Challenges 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: ...

posted 3y ago by user‭  ·  edited 3y ago by user‭

Answer
60%
+1 −0
Challenges Solve Goldbach's Conjecture

APL (Dyalog Unicode), 32 bytes (SBCS) {⊃(⊢(/⍨)⍵=+/¨),∘.,⍨(⊢~∘.×)⍨1↓⍳⍵} Try it online! {⊃(⊢(/⍨)⍵=+/¨),∘.,⍨(⊢~∘.×)⍨1↓⍳⍵} ⍳⍵ ⍝ Range from 1 to n ...

posted 3y ago by user‭

Answer
60%
+1 −0
Q&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 se...

posted 3y ago by user‭

Answer
60%
+1 −0
Q&A 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" i...

1 answer  ·  posted 3y ago by user‭  ·  edited 3y ago by user‭

Question code-golf tips
71%
+3 −0
Challenges Word Set Square

Scala, 99 bytes 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!

posted 3y ago by user‭

Answer
71%
+3 −0
Challenges Reverse an ASCII string

Scala, 9 bytes _.reverse Try it in Scastie! Explanation: _.reverse _ //The function argument . //Call a method reverse //Reverse the string

posted 3y ago by user‭

Answer
75%
+4 −0
Challenges Partial Sums of Harmonic Series

Scala, 55 bytes (Stream from 1 map 1.0./scanLeft.0)(_+_)indexWhere _.<= Try it online! Written in a more sane manner: n => Stream.from(1).map(1.0/_).scanLeft(0.0)(_+_).indexWhere(_ &g...

posted 3y ago by user‭

Answer