« first day (1898 days earlier)      last day (2939 days later) » 

2:02 AM
what happens now with gcj?
 
Yay, got them all right :)
 
@TheNumberOne couldn't get d large
how do you do it?
 
@TheNumberOne me too, hi-fiiive :)
 
Does anyone know of a function that takes any number >= 0 and performs the following transformation?
 0 => 0
 1 => 1
 n => 2
 
signum(n-1) + 1
 
2:09 AM
oo nice one
 
>:@*@<: in J
 
8 mins ago, by Maltysen
what happens now with gcj?
 
Dammit. My C-large just finished running now.
 
2:10 AM
@CᴏɴᴏʀO'Bʀɪᴇɴ min(n,2)
 
o_o that works too
 
@ChrisJester-Young wow were you brute forcing it?
 
a(n) = 2*[(n+2) mod (n+1)] - [n!^2 mod (n+1)]*[(n+1)!^2 mod (n+2)]
 
@Maltysen Yes.
 
G.f.: x*(1+x)/(1-x)=x*(1-x^2)/(1-x)^2
(G.f. = Generating function)
 
2:11 AM
I solved C (Coin Jam) large in CJam, of course :)
 
(PARI) a(n)=min(n, 2)
 
So my golfed code for C-large actually works
 
@ChrisJester-Young me and MarsUltor independently figured out a trick for brute-forcing it: skip candidates that have no prime factors greater than say 10k
 
@aditsu Of course you did. :-)
 
"Case #1:"N500{2E#+2b:_BSC,3>S*N}/
 
2:12 AM
98 bytes in python if anyone wants to give it a go
 
@Maltysen I just skipped ones that had the smallest prime factor > 100
 
@aditsu O_o
 
@TheNumberOne how fast? mine was .5 sec with 10k threshold
 
All my C large ones are of the form 110...0110...0110....011 for different amounts of 11s
 
@Maltysen Nice trick.
 
2:13 AM
oooh, the fractiles got a terrible correct percentage
 
@Sp3000 I used a different form of the 11 trick
 
85% on the small, 48% on the large
 
@Sp3000 There is an even more general form of this trick
 
@NathanMerrill the small was really easy, have no clue how to do large, so I just submitted my small at 26:59:30 and it obviously failed
guessing others did similar
 
Here's my Monte Carlo solution (which works for large too, of course):
#lang racket
(require srfi/2 math/number-theory)

(define (try n)
  (let loop ([i 10]
             [result '()])
    (if (= i 1)
        result
        (let* ([num (string->number n i)]
               [divisor (car (prime-divisors num))])
          (if (= divisor num)
              #f
              (loop (sub1 i) (cons divisor result)))))))

(define (perform n j)
  (define 2^n-1 (arithmetic-shift 1 (- n 1)))
  (let loop ([i j]
             [seen (set)])
    (when (positive? i)
      (or
       (and-let* ([num (number->string (bitwise-ior (+ (random 2^n-1) 2^n-1) 1) 2)]
 
2:15 AM
@xsot Yeah, 11s appeared to be enough though, so I left it at that (and reading the analysis, apparently 5 sets of 11s is even enough, so they were pretty lenient :P)
 
@ChrisJester-Young for C?
 
@Maltysen Yep.
 
@Maltysen 253 ms with large input
 
@TheNumberOne nice
 
on D-large, you can check for several spots on the original with a single check
 
2:16 AM
I have several people on my friends list from last year, but I'm still missing some people, so let's do this:
 
Oh, I didn't realise the analysis is already out
 
@xsot It's written ahead of time, and hidden until the end of contest.
 
@Doorknob wait now you know my email!
damn it
 
@ChrisJester-Young Not always :P Some take days to come out :P
 
@Maltysen Here's the code: pastebin.com/5skHV4MC
 
2:17 AM
lol all of you people overwriting each other
 
@Maltysen you appear as an anonymous user to me :P
(Assuming one of those is you. I see everyone as anonymous.)
 
I think they appear as anonymous until you enter chat.
 
@PhiNotPi Is it really PhitNotPi?
 
was CJam made for CodeJam?
 
2:18 AM
oh, you fixed it :P
 
@Doorknob Wat
 
Whoever's purple seems to enjoy jumping around the spreadsheet.
 
Alright then, here's my golfed attempt at C-large:
print'Case #1:'
i=8**5
exec"s=bin(i)[2:];print s+s[::-1],' '.join(map(str,range(3,12)));i+=1;"*500
 
wait, is purple an anteater for you all?
 
so can we talk about gcj methods of approach in here?
 
2:19 AM
@Winny we are
:P
 
:p
 
@Winny from now on, only after the round is over
 
ah gotcha
 
@Winny add your username to the spreadsheet
 
@Doorknob ah somebody finally took my suggestion :p
 
2:20 AM
@Maltysen sorry I missed the spreadsheet
 
@NathanMerrill not particularly, but I had CodeJam in mind
 
@aditsu On a related note: I feel bad for you for implementing CJam in Java, as Java has no mixins and GolfScript-like languages are a lot easier to implement with mixins.
@QPaysTaxes State machines are the bees' knees!
@QPaysTaxes They're certainly more powerful than regex.
 
@ChrisJester-Young didn't really seem to be a problem
 
@xsot Is it just me, or is listing out the numbers shorter?
 
@aditsu I didn't say it's a "problem" per se but it really is nicer to implement with mixins. I'm currently writing a C++ version that does use mixins and it's neat. :-)
 
2:23 AM
I've said it before, but regex is a terrible language because it is difficult to read.
 
gitlab.com/cky/cppjam (very incomplete, but check out ops.cpp).
 
so how did everybody do B
 
if somebody made a regex that was easy to read, it would be much better
 
@QPaysTaxes Of course.
 
i looked at it, and couldn't see how to do it, without bruteforcing
 
2:24 AM
@Winny i did bruteforcing
there was a really smart way tho
 
@Winny Look for how many times you cross over between + and -.
 
all you have to do is look at the first character
 
@Sp3000 I'm not sure if I got that but feel free to give it a go.
 
@xsot I mean, print s+s[::-1],3,4,5,6,7,8,9,10,11?
 
@NathanMerrill That'd be hard to do though. Regexes as they are now are pretty succinct.
 
2:25 AM
Dennis
 
Dennis
 
@El'endiaStarman which is their flaw. imagine if languages' keywords were all 1 letter
 
@Sp3000 Hahaha of course, it didn't occur to me to do that.
 
@quartata perfect ninja
 
@NathanMerrill I don't have to imagine. :P
 
2:26 AM
@xsot Of course, for that particular print statement, Python 3 has the advantage though
 
@QPaysTaxes Go to gitlab.com/cky/cppjam and look at mixins.h and ops.cpp.
 
how is d-large done?
 
@ChrisJester-Young wait, it is really just the number of crossovers? I'm pretty sure that's not it
 
@Sp3000 I see you on my friends list from last year's Code Jam; is it okay if I add you to this spreadsheet of PPCG users?
 
@NathanMerrill It is but disregard trailing +s.
 
2:26 AM
@NathanMerrill +1 if the last pancake is -
 
shrugs not like it's hard to find me anyway :P
 
@NathanMerrill Here's my solution:
 
@Sp3000 I'm too used to thinking in Python 2 instinctively. Python 3 is usually an afterthought.
 
@Maltysen consider a 4-length, 2 complexity: 12,34
 
#lang racket
(define (count-runs str)
  (let loop ([runs 0]
             [last #\+]
             [i (sub1 (string-length str))])
    (if (negative? i)
        runs
        (let ([cur (string-ref str i)])
          (loop (if (char=? cur last) runs (add1 runs)) cur (sub1 i))))))

(for ([i (in-range (call-with-input-string (read-line) read))]
      [line (in-port read-line)])
  (printf "Case #~a: ~a~%" (add1 i) (count-runs line)))
 
2:27 AM
import sys

with open(sys.argv[1]) as f:
    cases = f.readlines()[1:]

    for i, case in enumerate(cases):
        n=0
        last = ""
        for k in case[:-1]:
            if k != last:
                n += 1
            last = k
        print("Case #{}: {}". format(i+1, n - 1 + (case[-2]=="-")))
^ B
 
you can test block 1 by either testing the first section
or by testing the first item of each section
 
@xsot That's true :P It's just the small occasions which make 3 better (although it seems to be improving in terms of golfability due to recent updates like extended iterable unpacking and f-strings though, so that's fun)
 
Here's my pancake solution
 
and for block 2, you can test the second section, or the second item of a section
 
@NathanMerrill Makes sense when you consider the fact that for every place where you change sign, you have to do one flip to make them match up.
 
2:28 AM
sub solution ($S) {
    $S.subst(/\++$/,"")
      .comb
      .squish
      .elems;
}
not including boilerplate
it follows the sign-change counting
but with lazy builtins
 
@NathanMerrill huh?
 
@QPaysTaxes Like?
 
if we qual, are we in for all of round 1 or only 1a?
 
all of round 1
 
Rounds 1A, 1B, 1C. Solve any.
 
2:30 AM
Round 1 you can complete any of them
but if you complete say 1A
 
(or all, which I tend to end up doing)
 
you can't do B or C
by complete
I mean like qualify through
 
does each subround have 4 problems also?
 
@Maltysen ok, say your original block was 2 long, and we are doing 2 complexity (so there are 4 blocks)
 
@QPaysTaxes :-O
 
2:31 AM
@Maltysen From memory I think it varies a little depending
 
@NathanMerrill ok
 
to test if the 1st original block was gold, you can test blocks 1,2, or 3
 
@QPaysTaxes ba dum tish
 
@NathanMerrill why 3?
 
2:32 AM
oh world finals great
 
@KennyLau The contest analysis should tell you how, right?
 
oh really
 
@Maltysen because if the 1st was gold, and the second was lead, then L -> GL.
 
@NathanMerrill that's really smart
 
so, for complexity 3 and length 3
123,456,789;123,456,789;123,456,789
to check the 1st block
 
2:34 AM
k
 
you can either check any one of entire first 9 characters
or you can check any of the 123s
or any of the 1, 4s, or 7s
 
damn
that's awesome
 
anybody else do A in py?
 
@Winny me
 
so, by picking good numbers, you can actually check multiple blocks at once
 
for example, if you picked the first 6 above
 
all_digits = set("0123456789")

with open(input()) as f, open("results.txt", "w") as out:
cases = f.readlines()[1:]
for i, N in enumerate(cases):
digits = set()
n = 1
N = int(N)

if not N:
print("Case #{0}: INSOMNIA".format(i + 1), file=out)
continue

while digits != all_digits:
digits |= set(str(n * N))

n += 1

print("Case #{0}: {1}".format(i + 1, str(n * N - N)), file=out)
 
you would be checking the first block (because its in the first large area), the second block (because its in the second small area), and the 3rd block (because its the 3rd number in the small area)
 
@Winny .oO(I thought you're a Racketeer!)
 
@Maltysen d'oh forgot that 0 is falsy in python, been doing too much racket recently
 
2:37 AM
#lang racket
(define (count-sheep n)
  (define number->set (compose list->set string->list number->string))
  (let loop ([remaining (number->set 1234567890)]
             [i n])
    (let ([next (set-subtract remaining (number->set i))])
      (if (set-empty? next)
          i
          (loop next (+ i n))))))

(for ([i (in-range (read))]
      [n (in-port)])
  (printf "Case #~a: ~a~%"
          (add1 i)
          (if (zero? n)
              "INSOMNIA"
              (count-sheep n))))
 
@ChrisJester-Young i had a tough time understanding the problem, probably because of the language, so i did it in python since i'm much more comfortable with python (been using it for maybe 4 years, racket for 1)
 
n%1>0:t;{"Case #"t):t+": "@~:x{0""{\x+\1$`|.,10<}do;}"INSOMNIA"if n}/;
 
I also forgot str is iterable, silly me
 
@aditsu Nice.
 
thanks, my 2nd shortest submission :)
 
2:41 AM
are questions CWable?
 
sub solution ($N is copy) {
    if $N == 0 {
        return "INSOMNIA";
    }
    my @seen = 0 xx 10;
    my $i;
    until [*] @seen {
        my @digits = (++$i * $N).comb.unique;
        @seen[@digits] = 1 xx *;
    }
    return $i * $N;
}
 
@Maltysen only by moderators
 
@LockOpeners .oO(Perl 6?)
 
Yeah
 
we should have a codeJam series with CW questions where people try to post golfed code for the challenges
 
2:42 AM
@LockOpeners Nice. It looked too much like Perl to me to be anything else, and yet it's not Perl 5, so. :-)
 
:)
DId you see my B solution?
 
@LockOpeners what language is that?
 
Perl 6
 
@LockOpeners Nope.
 
@Maltysen That could be fun. Do they allow copy-pasting of questions?
 
2:43 AM
Perl is not dead (!)
 
[*] is a reduction with * btw
 
@Winny I code in Perl 5 a lot.
 
Here's B
 
@Winny I use Perl all the time.
 
@El'endiaStarman hmm ill check the terms
 
2:43 AM
sub solution ($S) {
    $S.subst(/\++$/,"")
      .comb
      .squish
      .elems;
}
 
I don't like Perl 6 though.
It sounds cool in theory but they changed the syntax too much
It feels like a completely different animal
 
It is a different animal
That's how it's meant to be :p
 
Which I don't like.
 
@Winny "User fsckww not found."
 
@Winny go-hero.net/jam/10/name/cky <-- no prizes for guessing what my "comfort language" is. ;-)
 
2:44 AM
I really think they should have changed the name
It's close to p5
but it's a big change too
I never used perl 5 though
so /o\
Almost all of my golf answers are p6 actually
 
@mınxomaτ a) Did I say a book? I meant a blog post. b) Haha, that's fine.
 
@Doorknob could it be my full email address? Where can I look up user stats?
 
This is still my favorite golf answer I've done codegolf.stackexchange.com/questions/74979/…
 
@Winny it should just be your username
 
nope
functions require whitespace after them
 
2:47 AM
ohhh right (!) winny3.14, i'll fix that
 
@El'endiaStarman I can't find anything that forbids it, but…
 
Does anyone here Grunt?
 
Probably perl 5
 
@QPaysTaxes This is Perl 6 which is super strict
 
2:47 AM
@QPaysTaxes ??
 
@Winny that worked!
 
In Perl 5 you can do that: the pop is a list operator
 
@Doorknob link please
 
@QPaysTaxes yes\
ಠ_ಠ
 
@Maltysen Any place you could ask to make sure it's alright? I doubt they would say no, but still.
 
2:48 AM
Does anyone know Grunt.js
 
In Perl 6 if there is an operator with the same name as a function you must use whitespace to differentiate
and also functions require whitespace after them
 
my C small (just the main line): putStr (unlines [concatMap (replicate 2) (showIntAtBase 2 intToDigit ((x + 64) * 2 + 1) "") ++ " " ++ unwords (map show [3..11]) | x <- [0..49]])
 
which is dumb
 
@ChrisJester-Young so is perl your first language? amazing, never would have considered that
 
Yeah readability is pretty dumb
 
2:48 AM
If they had just taken the cool functional aspects of Perl 6 and taken out all the dumb syntax stuff it would have been great
 
you can use parens
 
@Winny link to what?
 
It's not "dumb," it's a feature.
 
sum(@b) is fine
so is sum @b
but not sum@b
 
Using parens and using a list operator are very different.
 
2:49 AM
oops I wrote the large code initially ^^
 
@Winny No. My language progression was: 1990 QuickBASIC, 1994 x86 assembly, 1995 C, 1997 Java, 1998 R, 1999 Perl, 1999 PHP, 2000 C++, 2002 Scheme, 2009 Ruby.
 
pop isn't an operator in p6 though
 
@Doorknob where u search for submissions by user
 
@Winny Perl was my first language
 
it's just a function
 
2:49 AM
@Winny oh I just added you to my friends list
 
@Doorknob oh, hah, gcj has its own friends list?
 
but yeah
I reduce the whitespace in my golfs when I can
so any whitespace in them is required stuff
 
@Winny u no make it? awwww
 
Oh man going through my answers is fun
 
@Maltysen nahhh, I didn't realize gcj was on until early this morning and i had slept all day :))
 
2:52 AM
I wrote a ridiculously long thing explaining a function because there wasn't a doc page on it
and IMO it's very poorly written but i did it anyway
for the sake of other people understanding
3
A: Repdigit Base Finding

LockOpenersPerl 6, 45 43 42 bytes {grep 2..$^x-2: {[==] $x.polymod($_ xx*)}} Explained (sort of) For reference, a variable $^x in { ... } is the same as doing -> $x { ... } {grep 2..$^x-2: {[==] $x.polymod($_ xx*)}} { # Anonymous function taking $x grep ...

 
no wait, i somehow have 24h problem time, lol
 
that can actually be a byte shorter I think
 
anyway, i'm marking the next round on the calendar
 
oh
I suppose it can't
I probably tried using the grep function rather than the grep method before
which is why it's a method
(for reference, instead of doing foo.bar(baz) in p6 you can write bar foo: baz)
 
@QPaysTaxes Before "code golf" was a thing, it was called Perl golf.
 
2:57 AM
I did some regex golf stuff before code golf
but I never used perl 5 so
also p6 changes up regex too
mostly against golfing
 

« first day (1898 days earlier)      last day (2939 days later) »