Skip to content
This repository was archived by the owner on Dec 1, 2021. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Description

Given a list of integers separated by a single space on standard input, print out the largest and smallest values that can be obtained by concatenating the integers together on their own line. This is from [Five programming problems every Software Engineer should be able to solve in less than 1 hour](http://www.shiftedup.com/2015/05/07/five-programming-problems-every-software-engineer-should-be-able-to-solve-in-less-than-1-hour), problem 4. Leading 0s are not allowed (e.g. 01234 is not a valid entry).

This is an easier version of [#312I](https://www.reddit.com/r/dailyprogrammer/comments/67q3s6/20170426_challenge_312_intermediate_next_largest/?utm_content=title&utm_medium=hot&utm_source=reddit&utm_name=dailyprogrammer).

# Sample Input

You'll be given a handful of integers per line. Example:

5 56 50

# Sample Output

You should emit the smallest and largest integer you can make, per line. Example:

50556 56550

# Challenge Input

79 82 34 83 69
420 34 19 71 341
17 32 91 7 46

# Challenge Output

3469798283 8382796934
193413442071 714203434119
173246791 917463217

# Bonus

**EDIT** My solution uses permutations, which is inefficient. Try and come up with a more efficient approach.
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# Description

One way to think about bitwise *addition* (using the symbol `^`) as binary addition without carrying the extra bits:

101 5
^ 1001 9
----
1100 12

5^9=12

So let's define XOR multiplcation (we'll use the symbol `@`) in the same way, the addition step doesn't carry:

1110 14
@ 1101 13
-----
1110
0
1110
^ 1110
------
1000110 70

14@13=70

For this challenge you'll get two non-negative integers as input and output or print their XOR-product, using both binary and decimal notation.

# Input Description

You'll be given two integers per line. Example:

5 9

# Output Description

You should emit the equation showing the XOR multiplcation result:

5@9=45

**EDIT** I had it as `12` earlier, but that was a copy-paste error. Fixed.

# Challenge Input

1 2
9 0
6 1
3 3
2 5
7 9
13 11
5 17
14 13
19 1
63 63

# Challenge Output

1@2=2
9@0=0
6@1=6
3@3=5
2@5=10
7@9=63
13@11=127
5@17=85
14@13=70
19@1=19
63@63=1365
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Description

A knight piece in chess can only make L-shaped moves. Specifically, it can only move x steps to the right and y steps up if (x,y) is one of:

(-1,-2) ( 1,-2) (-1, 2) ( 1, 2)
(-2,-1) ( 2,-1) (-2, 1) ( 2, 1)

(For this problem, assume the board extends infinitely in all directions, so a knight may always make eight moves from any starting point.) A knight starting from (0,0) can reach any square, but it may have to take a roundabout route. For instance, to reach the square (0,1) requires three steps:

2, 1
-1, 2
-1, -2

(Notice that the x's add up to 0, and the y's add up to 1.) Write a program, that, given a square (x,y), returns how many moves it takes a knight to reach that square starting from (0,0).

# Example Input

3 7

# Example Output

4

Optional: also output one route the knight could take to reach this square.

# Credit

This challenge was suggested by /u/Cosmologicon, a well-known moderator of this sub. Many thanks! This one was hiding in the archives ...
Loading