2018-09-30 23:01:58 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								---
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								id: 5900f3971000cf542c50feaa
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								title: 'Problem 43: Sub-string divisibility'
							 
						 
					
						
							
								
									
										
										
										
											2020-11-27 19:02:05 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								challengeType: 5
							 
						 
					
						
							
								
									
										
										
										
											2019-08-05 09:17:33 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								forumTopicId: 302100
							 
						 
					
						
							
								
									
										
										
										
											2021-01-13 03:31:00 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								dashedName: problem-43-sub-string-divisibility
							 
						 
					
						
							
								
									
										
										
										
											2018-09-30 23:01:58 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								---
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-27 19:02:05 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								# --description--
 
							 
						 
					
						
							
								
									
										
										
										
											2020-02-28 21:39:47 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-09-30 23:01:58 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								The number, 1406357289, is a 0 to 9 pandigital number because it is made up of each of the digits 0 to 9 in some order, but it also has a rather interesting sub-string divisibility property.
							 
						 
					
						
							
								
									
										
										
										
											2020-02-28 21:39:47 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								Let d< sub > 1< / sub >  be the 1< sup > st< / sup >  digit, d< sub > 2< / sub >  be the 2< sup > nd< / sup >  digit, and so on. In this way, we note the following:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								< ul > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  < li > d< sub > 2< / sub > d< sub > 3< / sub > d< sub > 4< / sub >  = 406 is divisible by 2< / li > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  < li > d< sub > 3< / sub > d< sub > 4< / sub > d< sub > 5< / sub >  = 063 is divisible by 3< / li > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  < li > d< sub > 4< / sub > d< sub > 5< / sub > d< sub > 6< / sub >  = 635 is divisible by 5< / li > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  < li > d< sub > 5< / sub > d< sub > 6< / sub > d< sub > 7< / sub >  = 357 is divisible by 7< / li > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  < li > d< sub > 6< / sub > d< sub > 7< / sub > d< sub > 8< / sub >  = 572 is divisible by 11< / li > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  < li > d< sub > 7< / sub > d< sub > 8< / sub > d< sub > 9< / sub >  = 728 is divisible by 13< / li > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  < li > d< sub > 8< / sub > d< sub > 9< / sub > d< sub > 10< / sub >  = 289 is divisible by 17< / li > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								< / ul > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-09-30 23:01:58 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								Find the numbers of all 0 to 9 pandigital numbers with this property.
							 
						 
					
						
							
								
									
										
										
										
											2020-02-28 21:39:47 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-27 19:02:05 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								# --hints--
 
							 
						 
					
						
							
								
									
										
										
										
											2018-09-30 23:01:58 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-27 19:02:05 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								`substringDivisibility()`  should return an array.
							 
						 
					
						
							
								
									
										
										
										
											2018-09-30 23:01:58 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-27 19:02:05 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								```js
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								assert(Array.isArray(substringDivisibility()));
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								```
							 
						 
					
						
							
								
									
										
										
										
											2018-09-30 23:01:58 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-27 19:02:05 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								`substringDivisibility()`  should return [ 1430952867, 1460357289, 1406357289, 4130952867, 4160357289, 4106357289 ].
							 
						 
					
						
							
								
									
										
										
										
											2018-09-30 23:01:58 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-27 19:02:05 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								```js
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								assert.sameMembers(substringDivisibility(), [
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  1430952867,
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  1460357289,
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  1406357289,
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  4130952867,
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  4160357289,
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  4106357289
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								]);
							 
						 
					
						
							
								
									
										
										
										
											2018-09-30 23:01:58 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-27 19:02:05 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								You should not copy and return the array.
							 
						 
					
						
							
								
									
										
										
										
											2018-09-30 23:01:58 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-27 19:02:05 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								```js
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								assert(
							 
						 
					
						
							
								
									
										
										
										
											2021-04-28 16:18:54 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								  !code.match(/(1430952867)|(1460357289)|(1406357289)|(4130952867)|(4160357289)|(4106357289)/)
							 
						 
					
						
							
								
									
										
										
										
											2020-11-27 19:02:05 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# --seed--
 
							 
						 
					
						
							
								
									
										
										
										
											2018-09-30 23:01:58 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-27 19:02:05 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								## --seed-contents--
 
							 
						 
					
						
							
								
									
										
										
										
											2018-09-30 23:01:58 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								```js
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								function substringDivisibility() {
							 
						 
					
						
							
								
									
										
										
										
											2020-09-15 09:57:40 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-09-30 23:01:58 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								  return [];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								substringDivisibility();
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-27 19:02:05 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								# --solutions--
 
							 
						 
					
						
							
								
									
										
										
										
											2018-09-30 23:01:58 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								```js
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								// solution required
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								```