Skip to content

Instantly share code, notes, and snippets.

View rfprod's full-sized avatar
☯️

Vadim rfprod

☯️
View GitHub Profile
@rfprod
rfprod / Pairwise.markdown
Last active April 22, 2017 15:53
Pairwise

Pairwise

Function returns the sum of all indexes of elements of 'arr' that can be paired with one other element to form a sum that equals the value in the second argument 'arg'. If multiple sums are possible, function returns the smallest sum. Once an element has been used, it cannot be reused to pair with another.

A script by V.

License.

@rfprod
rfprod / SimonGame.markdown
Last active November 25, 2017 19:29
Simon Game

Simon Game

Simon game software implementation. User is presented a random series of button presses. Each time user inputs a series of button presses correctly, user sees the same series of button presses but with an additional step. User hears a sound that corresponds each button both when the series of button presses plays, and when user personally presses a button. If user presses a wrong button, user is notified that he has done so, and that series of button presses starts again to remind the pattern so user can try again. User can see how many steps are in the current series of button presses. User can hit restart button during gameplay, and the game will return to a single step. User can play in strict mode where if user gets a button press wrong, notification is presented that user has done so, and the game restarts at a new random series of button presses.

@rfprod
rfprod / CaesarsCipher.markdown
Last active April 22, 2017 15:54
Caesar's Cipher

Caesars Cipher

A common modern use of the simplest and most widely known ciphers, Caesar cipher, is the ROT13 cipher, where the values of the letters are shifted by 13 places. Thus 'A' ↔ 'N', 'B' ↔ 'O' and so on.

The rot13() function takes a ROT13 encoded string as input and returns a decoded string. All letters must be uppercase.

The CaesarCryptoCoder() function takes a string of characters and a shift value. It uses double length alphabet, including all lower case and upper case characters: a-zA-Z.

The CaesarsCipher class should be instantiated with new provided a shift value. The instance can be used to encode/decode strings. Resulting string letters are converted to upper case after encoding/decoding.

@rfprod
rfprod / TicTacToeGame.markdown
Last active April 22, 2017 15:54
Tic Tac Toe Game

Tic-Tac-Toe Game

Computer always moves first, user can't win, the best result is draw.

A Pen by V on CodePen.

License.

@rfprod
rfprod / WikipediaViewer.markdown
Last active April 22, 2017 15:54
Wikipedia Viewer
@rfprod
rfprod / freeCodeCampCamperNews.markdown
Last active April 22, 2017 15:54
FreeCodeCamp Camper News
@rfprod
rfprod / TwitchUsersStatus.markdown
Last active April 22, 2017 15:54
Twitch User Status
@rfprod
rfprod / LocalWeatherApplication.markdown
Last active April 22, 2017 15:55
Local Weather Application
@rfprod
rfprod / OptionalArguments.markdown
Last active April 22, 2017 15:55
Optional Arguments

Optional Arguments

A function that sums two arguments together. If only one argument is provided, it returns a function that expects one argument and returns the sum. For example, add(2, 3) should return 5, while add(2) should return a function. Calling this returned function with a single argument will then return the sum. If either argument isn't a valid number, returns undefined.

A script by V.

License.

@rfprod
rfprod / EverythingBeTrue.markdown
Last active April 22, 2017 15:55
Everything Be True

Everything Be True

Checks if the predicate (second argument) is truthy (not "", 0, undefined, null, NaN) on all elements of a collection (first argument).

A script by V.

License.