Skip to content

Instantly share code, notes, and snippets.

View Mr-Xcoder's full-sized avatar
🎯
Focusing

Victor Dumbrava Mr-Xcoder

🎯
Focusing
View GitHub Profile
@Mr-Xcoder
Mr-Xcoder / 05AB1E-Challenges.md
Last active March 2, 2018 10:07
05AB1E Mini Challenges

List of 05AB1E challenges

This Gist will contain challenges of varying difficulty, involving features that are somewhat specific to 05AB1E, for people to try out. The contents of this will then be added to The 05AB1E Lounge, where they will have their own tab.

  • Given a list of integers, return the longest prefix with the maximal mode. In case two or more elements of a prefix occur the maximal number of times, select the highest one. Current record: 7 bytes. Test cases:
    [-5, -3, -5, 3, 6, -5]            -> [-5, -3]
    [5, 3, 9, 4, 4, 9, 5, 6, 6, 4]    -> [5, 3, 9, 4, 4, 9, 5, 6, 6]
    [5, 9, 3, 7, 3, 9, 4, 3, 0, 8, 4] -> [5, 9, 3, 7, 3, 9, 4]
    
@Mr-Xcoder
Mr-Xcoder / BestOf2017.md
Last active April 23, 2018 13:39
Winners of "Best of PPCG 2017"
@Mr-Xcoder
Mr-Xcoder / DeltasSum.md
Last active January 11, 2018 16:55
Sum of the deltas

You have a list of elements a1, a2, ..., an. Now what is the sum of their deltas? You have the following items to sum:

  • a2 - a1
  • a3 - a2
  • ...
  • an - an - 1

What do you get by summing them?

(a2 - a1) + (a3 - a2) + ... + (an - an - 1) = a2 - a1 + a3 - a2 + ... + an - an - 1. What does that equal? -a1 + an