Important Contest
Instructions!!
Please read the following instructions carefully. They contain important information on how to write and submit
your solutions to the judges. If you have any question regarding these instructions, please ask a volunteer before
the contest starts.
CodeWars System 2.0
CodeWars System 2.0 is the judge system for CodeWars 2017, please read the user guide before the contest starts.
You can find the user guide on the dashboard after you login the system.
Writing your Programs
CodeWars System 2.0 supports the following programming languages Please make sure you are able to program
in at least one of the following languages.Python 2
Python 3
C
C++ (C11)
Java
If you choice Java as the computer language to write your program, please make sure you name your Java class
as “codewars”. Here is an example,
public class codewars {
public static int gvar;
public static void say(String s) {
int x = 10;
System.out.print(s+x);
}
public static void main(String[] argv) {
float y = 0;
say("Hello, world\n");
}
}
You are strongly encouraged to submit Problem #0 (on the next page) prior to the start of the
competition to ensure that understand how to use the CodeWars System 2.0.
You can see Problem #0 (Points to Give Away, 30 points) is the last problem in the problem list on
the CodeWars 2.0 system.
Problem 0
Preface
The purpose of this question is to ensure that your program can be
performed correctly on the judge’s computer. You are strongly advised to
submit this question FIRST.
This is a variation of the classic program “Hello World!”. Please print out
“Hello HPE CodeWars 2017 Taipei!“.
Input
[none]
Output
Hello HPE CodeWars 2017 Taipei!
Points to Give
Away
30 Points
Problem 1
Damped Sine Wave
6 Points
Preface
A Damped Sine Wave is a sinusoidal function whose amplitude approaches
zero as time increases. Sine waves describe many oscillating phenomena.
When a wave is damped, each successive peak decreases as time goes on.
(See figure)
The most common form of damping is exponential damping in which the
outer envelope of successive peaks is an exponential decay curve.
Assume that simplified general equation for an exponentially damped
sinusoid is the equation shown below.
Input
Input is time t, which is a real number between 0 and 5.
Use these values in your program: π = 3.141592653,e = 2.718281828
Case 1: 2.0
Case 2: 1.4687
Output
Output a real number of y which rounds off to the 8th digit after the decimal point.
Case 1: 0.13533528
Case 2: -0.22578676
Figure
Equation
is the instantaneous amplitude at time t
Problem 2
Preface
Your mobile contract is about to expire, the telecom carrier provides you
with three new contract options (refer to figure 1). Please find the cheapest
option.
Find the Best
Option
6 Points
Note: Fixed monthly fee does not include voice or any other charges.
Input
Input your monthly voice and network traffic data separated by a space.
(Limitation: Voice traffic < 9999 minutes; network traffic < 99999 MB)
Case 1:90 800
Case 2:180 1200
Case 3:150 3500
Output
The output should be the name of the cheapest option.
Explanation:
Case 1:90 800 (Option A: $427; Option B: $509; Option C: $804; Option A is the cheapest option.)
Case 2:180 1200 (Option A: $614; Option B: $548; Option C: $809; Option B is the cheapest option.)
Case 3:150 3500 (Option A: $1,525; Option B: $890; Option C: NT$857; Option C is the cheapest option.)
Case 1:A
Case 2:B
Case 3:C
Figure 1
Problem 3
Preface
Missile Defense
System
When there are N anti-ship missiles simultaneously attacking our warships,
the Aegis Missile Defense System built on the ship can target 1 or 2 adjacent
attacking missiles at a time and destroy them to assure the warship’s safety.
How many different ways can the Aegis Missile Defense System destroy all
the attacking missiles? Don’t take the time factor into account. When you
answer the question, assume all missiles are attacking simultaneously and
the Defense System has enough time to destroy all missiles.
Please refer to Figure 1 below for 5 different ways to destroy the missiles
when 4 missiles are attacking.
Input
Input is the number of attacking missiles (a positive integer from 1 to 50).
Case 1: 10
Case 2: 20
Output
Output is the numbers of ways to destroy all the attacking missiles (also a positive integer).
Case 1: 89
Case 2: 10946
Figure 1
6 Points
Preface
Palindrome (迴文) is a word from ancient Greek, which is the combination
of the prefix: Palin- (meaning: Back, Again) and suffix: drome (meaning:
Run). It means that a word or a sentence has the property of reading the
same forward and backward. For example: “level” in English or “上海自來
水來自海上” in Chinese.
In the world of numbers, if the digits of a number line up the same way
from the front and from the back, it can also be called a "Palindrome", e.g.
Problem 4
Palindrome
Please help to check if the decimal numbers are Palindrome.
Input
The maximum number of digits is 10. If there are more than 1 digit, then
the 1st digit cannot be 0. The case of "overflow" is not considered here.
Case 1:12321
Case 2:0
Case 3:134331
Case 4:5555
Output
If the number is a Palindrome, the output should be "True"; else, the output should be "False"
Case 1:True
Case 2:True
Case 3:False
Case 4:True
6 Points
Problem 5
Preface
Jungle Adventure
Please help the explorer prepare enough goods and materials to walk
through the jungle undetected. Starting from the upper left corner on the
map (0,0), your target is to reach the bottom right corner.
Each number in the grid represents the goods required in order to pass
through that zone. Please help the explorer find the total required amount
of goods.
12 Points
You must follow the following rules after you start.
1. Only move downward or move right
2. The goods/materials you collect must be a prime number to
avoid being tracked
3. You must choose the path with less goods/materials unless it is not a prime number
After you pass through the jungle, sum up the numbers of goods and materials and report to the explorer.
(Refer to Figure 1)
The path to walk through this zone is: 11, 31, 47, 43, 13, 59, 23
Total number of goods and materials required is the sum: 227
Input
Input the value with multiple rows:
The first row is the length n of the square jungle, where n<20.
The following n rows list out the required goods and materials on the n-squared jungle, ranging from 1 to 999
(all numbers are unique and cannot be repeated). Materials and goods for each step is separated by a space.
Assume there will always be a path. Input cannot have a blocked path (example: all non-prime numbers) and
will never be the same numbers.
Case 1:
5
421 439
239 17
470 911
192 457
737 486
3 113 518
191 954 415
409 821 727
601 337 29
250 599 739
Case 2:
5
263 29
739 73
681 241
501 411
392 274
526
367
491
617
531
Case 3:
5
435
574
683
311
733
439
489
308
773
13
137
593
240
192
126
131
823
757
228
911
912
191
223
269
943
887
679
103
109
47
936
494
672
653
499
Output
Please calculate the total numbers of goods
Case 1: 2983
Case 2: 2771
Case 3: 2263
Figure 1
Preface
A and B are planning a very special card game, the rules are below:
1. There are N pieces of cards (1 <= N <= 100) on the table and 2
numbers x, y on each card (0 < x < 1000, 0 < y < 1000).
2. Player A will start by picking up a card at the very beginning, then
its Player B’s turn to pick up a card. They will keep taking turns
until the end of the game.
Problem 6
Card Game
12 Points
3. If a player wants to take a card, this card needs to meet one of the
following conditions below:
a. x number on this card must be larger than the x number
on all the cards which have been picked up before
b. y number on this card must be larger than the y number
on all the cards which have been picked up before
4. If the player cannot pick up any card, this player loses the game.
Since there are too many cards and Player A & B are both pretty good card gamers, as a bystander, you might
feel really sleepy watching the game.
Let’s figure out who is the game winner!!!
Input
The number N in the first row means the number of the cards
N numbers in the second row to present the value X of the 1st card to the Nth cards.
N numbers in the third row to present the value Y of the 1st card to the Nth cards.
Assume both players are super smart and always pick the most optimal card to win.
Case 1:
6
10 10 10 10 9 9
5 7 9 10 9 11
Output
Case 1:
A
Figure 1
Explanation
At the beginning, player A picks up the 5th card (9/9), no matter what player B picks up, player A can still pick up
one more card but Player B cannot. Check details in Figure 1 above.
Problem 7
Pokémon GO
Preface
12 Points
In Pokémon GO game, players usually capture a great amount of Pidgeys and
evolve them if they want to accumulate experience points and get upgraded in a
short time. It costs 12 candies to evolve a Pidgey and they will gain 500
experience points and 1 candy in return.
When the player successfully evolves their Pidgey into Pidgeotto, they can send
Pidgeotto to the Doctor Oak and exchange for 1 candy.
Evolving one Pidgey needs 15 seconds whereas transferring one Pidgeotto to the
Doctor is no time consuming. If the player uses the Lucky egg, they can double
the experience points they earn for half an hour.
Currently, Ash Ketchum has A candies, B Pidgeys and C Lucky eggs. Every evolution and transfer are continuously
in progress without any break. Only one evolution or transfer can occur at one time (you cannot do multiple
actions at the same time). Please help to calculate how many Pidgey evolutions he can complete and the
amount of the maximum experience points that he can earn.
Input
Input will be 3 integers separated by space: A candies (0 ≤ A ≤ 100000), B Pidgeys (0 ≤ B ≤ 30000), and C Lucky
eggs (0 ≤ C ≤ 500)
Case 1: 100 10 1
Case 2: 20000 3000 16
Output
Output will be 2 numbers, the number of evolved Pidgey and experience points gained, separated by space.
Case 1: 9 9000
Case 2: 1999 1924500
Preface
Mr. Wang has a list of songs for the Rooster Year party.
Problem 8
Who is my best friend
He uses 1 to n to index his songs. The more he likes a song, the smaller the
number used in the index.
12分
For example,
Song No.1 (his favorite song in the list): I’m in Love.
Song No.2 (his 2nd favorite song in the list): Mountain high.
Song No.3 (his 3rd favorite song in the list): Dancing Queen.
Song No.4 (his 4th favorite song in the list): Happy
Song No.5 (his 5th favorite song in the list): Umbrella
Song No.6 (his 6th favorite song in the list): Heaven
, and so on.
These songs form a song list.
For Mr. Wang, it is an ordered list W = {1, 2, 3, 4, 5, 6}.
In other words, W[i] = i where 1 <= i <= n (n is the total number of songs)
He sends the song list to 3 friends and asked each one of them to sort the list based on their preferences. The
more they like the song, the earlier it appears in the list. The more similar the sequence of a person’s song list is
to that of Mr. Wang’s, the more that person has similar taste of music to Mr. Wang.
The way to measure the similarity of the preference is by counting the inversions pairs. The less the inversion
pairs, the more the similarity shows.
Definition of an inversion pair: let G be an ordered list of distinct numbers, if exists a pair of (i, j) such that i < j
and G[i] > G[j], then <G[i], G[j]> is an inversion pair.
For example, see Figure 1 for preference sequence of Mr.Wang’s, Abbie’s, Barry’s and Chris’s.
In this case, Abbie has a preference sequence of {1, 2, 3, 4, 6, 5}. It has an inversion pair <6, 5>; total of 1
inversion pair.
Barry has the preference sequence of {6, 5, 4, 3, 2, 1}. It has inversion pairs <6, 5>, <6, 4>, <6, 3>, <6, 2>, <6,
1>,<5, 4>, <5, 3>, <5, 2>, <5, 1>,<4, 3>,<4, 2>,<4, 1>,<3, 2>,<3, 1>,<2, 1>; total of 15 inversion pairs.
Chris has the preference sequence of {3, 4, 1, 2, 6, 5}. It has inversion pairs <3, 1>, <3, 2>,<4, 1>,<4, 2>,<6, 5>;
total of 5 inversion pairs.
So among these 3 friends, the one who has the most similar sequence of preference to Mr. Wang’s is Abbie (1
inversion pair), then Chris (5 inversion pairs), and the least similar is that of Barry’s (15 inversion pairs).
Input
4 integer arrays of the same length. The length of each array ranges between 5 and 100 (inclusive) with no
integers repeated.
The first array represents Mr. Wang’s preference sequence of songs. It is a sorted array from 1 to n with n no
bigger than 100 and no less than 5.
The following 3 arrays represent the preference sequence of Abbie’s, Barry’s, Chris’s, respectively. Each one of
the array is an array of distinct integers from 1 to n in their preference order.
Arrays are separated by semicolon “;” without quotes.
Separator for the integers within an array is comma “,” without quotes.
Sample 1: 1,2,3,4,5,6;1,2,3,4,6,5;6,5,4,3,2,1;3,4,1,2,6,5
Sample 2: 1,2,3,4,5;5,4,3,2,1;1,3,2,4,5;2,4,1,3,5
Output
Output should print out A, B, C in the order of their preference similar to Mr. Wang’s. Please use A to represent
Abbie. B for Barry and C for Chris. If they happen to have the same similarity, output should print in the priority
of A then B then C.
Sample 1: ACB
Sample 2: BCA
Chris (C)
Mr. Wang (W)
Abbie (A) Barry (B)
1
1
6
3
2
2
5
4
3
3
4
1
4
4
3
2
5
6
2
6
6
5
1
5
Figure.1 Preference sequences
Preface
National Day at Number-Line Island is coming again. Being a leader of the
island, Donald Trump is considering where to host the ceremony. NumberLine Island is a special island where all of the residents live in a straight
line. In this case, Donald Trump, a master of Mathematics, would like to
host the ceremony at a location on the line where it saves every
participant’s time. The physical conditions of everyone in this Island is
different, so they all have different limited walking rate V_i.
Under this circumstances, Donald Trump would like to host the ceremony
at the place where “everyone can arrive in the shortest time”.
Donald Trump couldn’t figure out the best location to achieve this. Donald
Trump needs your help to solve this problem. Can you help him?
Problem 9
Gathering
18 Points
Input
The first input is N, representing the total numbers of residents on Number-line Island. (2 <= N <= 20000)
The 2nd line has N number of P which are integers. P_i stands for the i-th residents’ location. (1 <= P_i <= 10^6)
The 3rd line has N number of V which are integers. V_i stands for the maximum possible walking rate of the i-th
resident. (1 <= V_i <= 10^3)
Case 1:
3
713
121
Case 2:
4
5 10 3 2
2324
Output
Output the shortest possible time it takes for everyone to reach the optimal ceremony location. Please round off
the time to the sixth decimal place. Note: Although all of the residents are located on integer points, the location
of the ceremony doesn’t need to be on an integer point.
Case 1:
2.000000
Case 2:
1.400000
Preface
Problem 10
Ever since Donald Trump and Hillary Clinton sang LET ME LOVE YOU
together on a TV show, they became interested in each other voice. They
decided to have dinner together in a resturant and sing together with the
jukebox. It is both their first time to use a jukebox and they surprisingly
found that it is cash-operated. Unfortunately, they have limited budget.
K Song
18 Points
A song cannot be cut off once it starts. When a song is requested, you
must wait for the jukebox to finish playing the entire song. A song can be
requested only once and cannot repeat. Here comes the question: How
could Donald and Hillary achieve maximum satisfaction with limited coins
and time?
Input
In the first line:
Time limit: k minutes, 1<=k<=240
Money on hand: h dollars, 10<=h<=1000
Number of songs: c songs, 1<=c<=50
From the second to the c+1 line, there are four digits: b, n, m, a on every line.
b: length of the song, 1<=b<=10
n: request code for the song, 1<=n<=1000, n is distinct
m: price of the song, 1<=m<=100
a: Trump and Clinton’s preference to the song, 1<=a<=10, higher number is higher preference
The more satisfaction they gain from requesting a song, the higher their preference for the song.
k, h, c, b, n, m and a are all positive integers. There will be only one possible result for each combination.
Case 1:
10 100 3
3 101 5 5
4 102 1 3
3 103 6 6
Case 2:
20 10 7
3 101 5 5
4 102 1 3
3 103 6 5
1 104 8 3
2 105 6 2
2 106 4 1
2 107 6 4
Output
Select songs from the jukebox to reach highest total preference within limited time k and budget h. Please list the
song by their code in order from lowest to highest preference. If multiple songs have the same preference, please
list codes from lowest to highest in order.
Case 1:
102
101
103
Case 2:
106
102
101
Figure
Preface
Let’s collect lucky eggs in the year of the Rooster! In this game, there are
several grids along the street and each grid has a certain amount of lucky
eggs to celebrate this wonderful year. To embrace this energetic
atmosphere, the rules in this game is when jumping to get these lucky eggs
you cannot jump to an adjacent grid or jump backwards. The starting point,
the number of times you move, and the number of eggs you pick in the game
are all unrestricted.
Problem 11
Jump to Collect
Lucky Eggs
18 Points
Given a list of non-negative integers to represent the amount of lucky eggs in
each grid. Please determine the maximum amount of eggs you can collect in
this game.
Input
Input contains 2 lines:
First line is a positive integer n, the total number of grids along the street. 0 < n < 2 ^31 – 1.
Second line lists the amount of eggs in each grid, separated by a space. All of them are non-negative integers
that range from 0 to 99999999.
Case 1:
7
1234321
Case 2:
8
2 5 3 7 10 8 5 9
Case 3:
5
1 200 2 2 100
Output
The maximum amount of lucky eggs you can collect in this game.
Case 1: 8
Case 2: 29
Case 3: 300
Problem 12
Preface
In order to resist invasion of the neighboring city’s army, our soldiers decide to build
trenches on the road between the two cities (length of L km). The trenches must
follow these rules:
Homeland
Defense
18 Points
1. The distance between the trench and either city cannot be shorter than
6km, in order to avoid the enemy from discovering or undermining our
facilities .
2. Each trench should have an interval of at least D km.
We need to know the maximum possible trenches that can still be dug.
Input
Each line starts with 3 integers L, D and n, separated by space. L is the length of the road leading to the city, D is
the minimal interval between the trenches, and n is the number of existing trenches. Following the first 3 inputs
will be n integers; each integer shows the location of existing trenches. All integers are separated with space.
Explanation
For example case 1: Road length L is 22km, interval of trench D is 2km, and number of existing trenches n is 2.
The two existing trenches dig at 9 and 11km.
Case 1: 22 2 2 9 11
Case 2: 33 5 0
Output
The output is the maximum possible trenches we can dig (a positive integer)
You can assume all the numbers of input and output are positive integers >=0, and the distance between the
existing trench and the city is always greater than 6km. Besides, the location of trench will appear in arbitrary
order.
Case 1: 3
Case 2: 5
Problem 13
Preface
Good Autobots and villainous Decepticons have been at war for millions of
years. Recently, a new robot was born on Cybertron with unknown race. Due to
long-time restless fighting and suspicion, both Autobots and Decepticons
cannot tell what race the new-born robot is. Therefore, they have decided to
come to the Earth and look for your help.
As the proverb goes, birds of a feather flock together, we may judge a person
by observing his/her friends.
There’s a data sorting algorithm called the KNN (K-Nearest Neighbor). The main
idea of KNN is that an object is classified by the majority vote in a feature space
of k nearest neighbors. The KNN algorithm is among the simplest of all machine
learning algorithms.
Classification
18 Points
Please refer to the figure below. There are several points in the graph. Each point represents the location of an
Autobot (A) or a Decepticon (B) and the Star represents the location of the new-born robot. We can determine
the robot type by calculating the linear distance between the new-born robot (Star) and the other robots within
k nearest neighbors.
Input
The Inputs are in the following sequence:
Line1: Variable: K-value in KNN (k) – Check characteristics of robots within K area
Line2: The total number of Autobots and Decepticons - (d)
From Line 3 on: Coordinates of known Autobots/Decepticons in the data pool. 'A' for Autobot and 'B' for
Decepticon
Last Line: Coordinate of the new-born robot with unknown race
Range limits: 0<k<20 (K must be an odd number), 0 < d <= 100
Data should be all positive integers or 0. Robot race representations are all capitalized 'A' or 'B'.
Case 1:
3
6
0 0
0 3
1 2
3 4
3 5
4 4
2 5
// k-value
// d
A
A
A
B
B
B
// target
Output
Output the classification of the new-born robot. If data shows that the number of neighbors is equal for both
sides , output ‘A’ for Autobot.
Case 1:
B
Figure 1
Preface
Design a program to input 10 poker cards. The 1st, 3rd, 5th, 7th, 9th cards are on
player A’s hand and the 2nd, 4th, 6th, 8th. 10th are on player B’s hand. This
program determines the competition outcome based on the Texas Hold’em
rules.
Problem 14
Texas Hold’em
24 Points
Poker hand ranking in Texas Hold’em rules is similar to that of the other poker
games, but there’s no ranking among different suits. Only value matters.
The hand ranking is as following: Royal flush > Four of a kind > Full house >
Flush > Straight > Three of a kind > Two pairs > Pair > High card
Royal flush
A royal flush is an ace high straight flush. For example, A-K-Q-J-10 all of diamonds.
Straight flush
A straight flush is a five-card straight, all in the same suit. For example, 7-6-5-4-3 all of clubs.
Four of a kind
Four of a kind, or quads, are four cards of equal value. For example, four jacks.
Full house
A full house contains a set (3) of cards of one value and a pair of another value. For example, Q-Q-Q-2-2.
Flush
A flush is any 5 cards, all of the same suit. For example, K-Q-9-6-3 all of diamonds.
Straight
Five cards of sequential value. Every possible straight will contain either a 5 or a 10. For example, 7-6-5-4-3 with
different suits.
Three of a kind
Three cards of the same value. For example, three aces.
Two pairs
This is two cards of one value and another two cards of another value. For example, two jacks and two 8s.
Pair
One pair is two cards of the same value. For example, two queens.
High card
The hand with the highest card(s) wins.
Input
Randomly pick up 10 cards out of a 52-card deck.
The 1st, 3rd, 5th, 7th, 9th cards are on player A’s hand and the 2nd, 4th, 6th, 8th. 10th are on player B’s hand. Yes, this
is a little bit different than the real “Texas Hold-em” but that’s ok.
Use a space to separate 10 cards.
Use 2,3,4,5,6,7,8,9,10,J,Q,K,A for the card values.
Use the following characters for the suits: ‘C’ for club ♣; ‘S’ for spade ♠; ‘H’ for heart ♥; ‘D’ for Diamond♦.
There can be at most 3 characters for a card (ex: 10D), or it can also be 2 characters for a card(ex: JS). The 1 st
character or the first 2 characters represent the card value whereas the last character represents the suits.
Case 1:
2H 8S 2D 8D 2C 7H 4C KS 4S KH
Case 2:
AH 8S 2D 9S 3C JS 4S KS 5S 2S
Case 3:
3C 3S 4D 4S 5H 5C 6H 6S 10S 10C
Output
The output has to show the results.
1: player A wins
-1: player B wins
0: draw even
Case 1:
1
Case 2:
-1
Case 3:
0
Preface
Donald Trump has been expecting a video game so badly and now it has finally
been released! Having been allured a move in the game from watching the
trailer, Trump cannot wait to learn this move. Unfortunately, he found that he
has to collect experience points in order to perform each move. Some moves
require certain prerequisites to acquire. (For example: you have to get Fireball
I before learning Fireball II) In this game, you gain an extra experience point
every time you reach a new level.
Problem 15
Skill Tree
24 Points
Although you can eventually learn all the moves by playing the game step by
step and slowly accumulating experience points, Trump can't wait to learn
that move shown in the trailer. Could you please tell him how many
experience points he has to spend in order to learn the move from the trailer?
Input
In the first row, two inputs: N and M, represents the total number of the moves in the game system and the
number of prerequisites respectively. (N <=5000, M <=5000)
There are N lines afterwards. There is a string S and a number P on each line. S contains an alphabetical string and
a number, representing the name of the move. P represents the experience points required to learn that move.
After that there are M lines, each contains two strings: A and B. A is the prerequisite of B, which means you have
to acquire A before acquiring B. You can assume that if you had infinite experience points, you can learn all the
moves in the game.
Last line is the name of the move (string format) that Trump wanted to learn from the trailer.
Case 1:
43
FireBall_I 1
FireBall_II 2
FocusFire 2
PyroBlast 4
FireBall_I FireBall_II
FireBall_II PyroBlast
FocusFire PyroBlast
PyroBlast
Output
A number X, representing the experience points that Trump has to reach in order to learn the move shown in the
trailer
Case 1:
9
Problem 16
Preface
A bomb in front of you and it is about to explode within 5 minutes!
You can see that there are two wires (one red and one blue) tangled with
each other. Both of their ends are fixed to the bomb. This is a special bomb
which can’t be defused by just cutting the wires. You have to untangle the
wires in order to deactivate it. You must not pull the wires from the bomb.
Can you safely overcome this dangerous situation?
Keep Untangling
and Nothing
Explodes
24 Points
Input
The input contains a string of cross points for the 2 wires, which consists of
upper case Bs and Rs with no more than 500 characters. R means the red
wire is on the top while B means the blue one is on the top. See illustrations at the end of the problem for more
details.
Case 1: BRRB
Case 2: RB
Case 3: RR
Output
If the wires can be untangled successfully without breaking them, output “Saved!” (without quotation marks).
Otherwise, output “BOOOOOOOOM!” (without quotation marks).
Case 1: Saved!
Case 2: BOOOOOOOOM!
Case 3: Saved!
Below are three illustrated examples.
In Fig. 1, you can untangle the wires by moving the middle part of the red wire down.
In Fig. 2, no matter how you move it, the wires cannot be untangled. (Keep in mind that both ends of the wires
are fixed.)
In Fig. 3, move up the middle part of the red wire up to untangle the wires.
Figure 1
Figure 2
Figure 3
© Copyright 2025 Paperzz