Codeforces celebrates 10 years! We are pleased to announce the crowdfunding-campaign. Congratulate us by the link https://codeforces.com/10years. ×

wjomlex's blog

By wjomlex, 8 years ago, In English,

I did the first problem pretty quickly after learning how to duplicate the top element of the stack (it took me way too long to figure out what "dup" meant).

And then I spent 30 minutes trying to figure out how you do loops only to realize that of course there aren't any loops, 'cause it's a functional language XD

(As kilotaras has pointed out, there are indeed general loops in Factor. There's even a keyword called "loop" :P)

Besides problem A, most of my code follows the same paradigm: a recursive function that keeps track of the input we haven't used, and the answer we've calculated on the input we have used.

After a couple problems I learned about "::" for binding function parameters to local variables. Boy, does that save time.

And now that the contest is over I see that there's a "prime" function. That would surely speed up my Problem I enough because right now it's just horrendously naive trial division.

Editorial

A quick mini-editorial of how your recursive state might look for each problem:

  • A: No recursion necessary!
  • B: (output string, left-most portion of number)
  • C: (output string, current divisor, unfactored portion of number)
  • D: (processed portion of string, unprocessed portion)
  • E: (boolean flag that keeps track of if you've seen "H", "Q", or "9", unprocessed portion of string)
  • F: (number of zeros so far, left-most 10 or so non-zero digits, factorial remaining to multiply by)
  • G: I haven't done this, but it's a more complicated version of B. I think it's easily the hardest problem.
  • H: (processed portion of string, unprocessed portion)
  • I: (boolean flag that keeps track of if all suffixes have been prime so far, left-most unprocessed digits) I also reuse my function from C to factor each number
  • J: (A stack representing unmatched open parentheses, unprocessed portion of string)

Code

Read more »

 
 
 
 
  • Vote: I like it
  • +37
  • Vote: I do not like it

By wjomlex, 8 years ago, In English,
Goin' to World Finals again! This time with the University of Toronto, and with Jacob Plachta and Qiyu Zhu as teammates.

Read more »

 
 
 
 
  • Vote: I like it
  • +20
  • Vote: I do not like it

By wjomlex, 9 years ago, In English,
After 4 years of the ACM-ICPC, it's finally World Finals time :)

Andrew Henry (lordklotski) is on our team, as is Hua Huang (not on Codeforces).

Hoping for some simulation or parsing problems with hard implementation :D

Read more »

 
 
 
 
  • Vote: I like it
  • +19
  • Vote: I do not like it