diff options
-rw-r--r-- | .idea/vcs.xml | 6 | ||||
-rw-r--r-- | .idea/workspace.xml | 25 | ||||
-rw-r--r-- | out/production/PatternFinder/PatternFinderKt.class | bin | 7809 -> 7886 bytes | |||
-rw-r--r-- | src/PatternFinder.kt | 8 |
4 files changed, 27 insertions, 12 deletions
diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project version="4"> + <component name="VcsDirectoryMappings"> + <mapping directory="$PROJECT_DIR$" vcs="Git" /> + </component> +</project>
\ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml index a9e14c7..63ac00e 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -1,7 +1,12 @@ <?xml version="1.0" encoding="UTF-8"?> <project version="4"> <component name="ChangeListManager"> - <list default="true" id="e6ea5b12-e989-45d1-8127-4619454680db" name="Default" comment="" /> + <list default="true" id="e6ea5b12-e989-45d1-8127-4619454680db" name="Default" comment=""> + <change beforePath="" afterPath="$PROJECT_DIR$/.idea/vcs.xml" /> + <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" afterPath="$PROJECT_DIR$/.idea/workspace.xml" /> + <change beforePath="$PROJECT_DIR$/out/production/PatternFinder/PatternFinderKt.class" afterPath="$PROJECT_DIR$/out/production/PatternFinder/PatternFinderKt.class" /> + <change beforePath="$PROJECT_DIR$/src/PatternFinder.kt" afterPath="$PROJECT_DIR$/src/PatternFinder.kt" /> + </list> <ignored path="$PROJECT_DIR$/out/" /> <option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" /> <option name="TRACKING_ENABLED" value="true" /> @@ -15,8 +20,8 @@ <file leaf-file-name="PatternFinder.kt" pinned="false" current-in-tab="true"> <entry file="file://$PROJECT_DIR$/src/PatternFinder.kt"> <provider selected="true" editor-type-id="text-editor"> - <state relative-caret-position="264"> - <caret line="34" column="18" lean-forward="true" selection-start-line="34" selection-start-column="18" selection-end-line="34" selection-end-column="18" /> + <state relative-caret-position="459"> + <caret line="117" column="48" lean-forward="false" selection-start-line="117" selection-start-column="48" selection-end-line="117" selection-end-column="48" /> <folding> <element signature="e#0#126#0" expanded="true" /> </folding> @@ -39,6 +44,9 @@ <find>println(</find> </findStrings> </component> + <component name="Git.Settings"> + <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" /> + </component> <component name="GradleLocalSettings"> <option name="externalProjectsViewState"> <projects_view /> @@ -58,6 +66,7 @@ <option name="width" value="1886" /> <option name="height" value="1070" /> </component> + <component name="ProjectLevelVcsManager" settingsEditedManually="true" /> <component name="ProjectView"> <navigator currentView="ProjectPane" proportions="" version="1"> <flattenPackages /> @@ -238,11 +247,11 @@ <window_info id="Palette	" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" /> <window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="7" side_tool="true" content_ui="tabs" /> <window_info id="Maven Projects" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" /> - <window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32987553" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" /> - <window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="false" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" /> + <window_info id="Run" active="true" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.3295099" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" /> + <window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" /> <window_info id="Terminal" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" /> <window_info id="Designer" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" /> - <window_info id="Project" active="true" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.24973433" sideWeight="0.5" order="0" side_tool="false" content_ui="combo" /> + <window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.24973433" sideWeight="0.5" order="0" side_tool="false" content_ui="combo" /> <window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" /> <window_info id="Ant Build" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" /> <window_info id="UI Designer" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" /> @@ -286,8 +295,8 @@ </entry> <entry file="file://$PROJECT_DIR$/src/PatternFinder.kt"> <provider selected="true" editor-type-id="text-editor"> - <state relative-caret-position="264"> - <caret line="34" column="18" lean-forward="true" selection-start-line="34" selection-start-column="18" selection-end-line="34" selection-end-column="18" /> + <state relative-caret-position="459"> + <caret line="117" column="48" lean-forward="false" selection-start-line="117" selection-start-column="48" selection-end-line="117" selection-end-column="48" /> <folding> <element signature="e#0#126#0" expanded="true" /> </folding> diff --git a/out/production/PatternFinder/PatternFinderKt.class b/out/production/PatternFinder/PatternFinderKt.class Binary files differindex 371883b..a964725 100644 --- a/out/production/PatternFinder/PatternFinderKt.class +++ b/out/production/PatternFinder/PatternFinderKt.class diff --git a/src/PatternFinder.kt b/src/PatternFinder.kt index bbab9ae..fb660f5 100644 --- a/src/PatternFinder.kt +++ b/src/PatternFinder.kt @@ -33,7 +33,7 @@ private fun findFormula(numbers: List<Double>): String { increment = differences[0] // Start-value - val nAsExponent = nAsExponent(differences) + val nAsExponent = nAsExponent(differences, numbers) val startValueDifference = when { incrementsByDifference -> differences[0] // xn nAsExponent -> getBase(differences) // x^n @@ -45,7 +45,7 @@ private fun findFormula(numbers: List<Double>): String { // Exponents var base = "n" var exponent = "" - if (nAsExponent(differences)) { + if (nAsExponent(differences, numbers)) { base = getBase(differences).cleanRedundancy() + "^" exponent = "n" } else if (!incrementsByDifference) { @@ -113,7 +113,7 @@ private fun getExponent(secondNumber: Double, startValue: Double): Double { return Math.log(secondNumber - startValue) / Math.log(2.0) } -private fun nAsExponent(differences: List<Double>): Boolean { +private fun nAsExponent(differences: List<Double>, numbers: List<Double>): Boolean { val base = getBase(differences) - return base == differences[0] / (differences[0] / base) + return Math.log(numbers[1] - (base - 1)) / Math.log(base) == 2.0 }
\ No newline at end of file |