summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--2021/day2/.clang-format563
-rw-r--r--2021/day2/Makefile11
-rw-r--r--2021/day2/input1000
-rw-r--r--2021/day2/input.example6
-rw-r--r--2021/day2/pilot.c34
5 files changed, 1614 insertions, 0 deletions
diff --git a/2021/day2/.clang-format b/2021/day2/.clang-format
new file mode 100644
index 0000000..ee17a69
--- /dev/null
+++ b/2021/day2/.clang-format
@@ -0,0 +1,563 @@
1# SPDX-License-Identifier: GPL-2.0
2#
3# clang-format configuration file. Intended for clang-format >= 4.
4#
5# For more information, see:
6#
7# Documentation/process/clang-format.rst
8# https://clang.llvm.org/docs/ClangFormat.html
9# https://clang.llvm.org/docs/ClangFormatStyleOptions.html
10#
11---
12BasedOnStyle: LLVM
13IndentWidth: 8
14UseTab: Always
15BreakBeforeBraces: Linux
16AllowShortIfStatementsOnASingleLine: false
17IndentCaseLabels: false
18AccessModifierOffset: -4
19AlignAfterOpenBracket: Align
20AlignConsecutiveAssignments: None
21AlignConsecutiveDeclarations: false
22
23#AlignEscapedNewlines: Left # Unknown to clang-format-4.0
24AlignOperands: true
25AlignTrailingComments: false
26AllowAllParametersOfDeclarationOnNextLine: false
27AllowShortBlocksOnASingleLine: false
28AllowShortCaseLabelsOnASingleLine: false
29AllowShortFunctionsOnASingleLine: None
30AllowShortLoopsOnASingleLine: false
31AlwaysBreakAfterDefinitionReturnType: None
32AlwaysBreakAfterReturnType: None
33AlwaysBreakBeforeMultilineStrings: false
34AlwaysBreakTemplateDeclarations: false
35BinPackArguments: true
36BinPackParameters: true
37BraceWrapping:
38 AfterClass: false
39 AfterControlStatement: false
40 AfterEnum: false
41 AfterFunction: true
42 AfterNamespace: true
43 AfterObjCDeclaration: false
44 AfterStruct: false
45 AfterUnion: false
46 #AfterExternBlock: false # Unknown to clang-format-5.0
47 BeforeCatch: false
48 BeforeElse: false
49 IndentBraces: false
50 #SplitEmptyFunction: true # Unknown to clang-format-4.0
51 #SplitEmptyRecord: true # Unknown to clang-format-4.0
52 #SplitEmptyNamespace: true # Unknown to clang-format-4.0
53BreakBeforeBinaryOperators: true
54#BreakBeforeInheritanceComma: false # Unknown to clang-format-4.0
55BreakBeforeTernaryOperators: false
56BreakConstructorInitializersBeforeComma: false
57#BreakConstructorInitializers: BeforeComma # Unknown to clang-format-4.0
58BreakAfterJavaFieldAnnotations: false
59BreakStringLiterals: false
60ColumnLimit: 80
61CommentPragmas: '^ IWYU pragma:'
62#CompactNamespaces: false # Unknown to clang-format-4.0
63ConstructorInitializerAllOnOneLineOrOnePerLine: false
64ConstructorInitializerIndentWidth: 8
65ContinuationIndentWidth: 8
66Cpp11BracedListStyle: false
67DerivePointerAlignment: false
68DisableFormat: false
69ExperimentalAutoDetectBinPacking: false
70#FixNamespaceComments: false # Unknown to clang-format-4.0
71
72# Taken from:
73# git grep -h '^#define [^[:space:]]*for_each[^[:space:]]*(' include/ \
74# | sed "s,^#define \([^[:space:]]*for_each[^[:space:]]*\)(.*$, - '\1'," \
75# | sort | uniq
76ForEachMacros:
77 - 'apei_estatus_for_each_section'
78 - 'ata_for_each_dev'
79 - 'ata_for_each_link'
80 - '__ata_qc_for_each'
81 - 'ata_qc_for_each'
82 - 'ata_qc_for_each_raw'
83 - 'ata_qc_for_each_with_internal'
84 - 'ax25_for_each'
85 - 'ax25_uid_for_each'
86 - '__bio_for_each_bvec'
87 - 'bio_for_each_bvec'
88 - 'bio_for_each_bvec_all'
89 - 'bio_for_each_integrity_vec'
90 - '__bio_for_each_segment'
91 - 'bio_for_each_segment'
92 - 'bio_for_each_segment_all'
93 - 'bio_list_for_each'
94 - 'bip_for_each_vec'
95 - 'bitmap_for_each_clear_region'
96 - 'bitmap_for_each_set_region'
97 - 'blkg_for_each_descendant_post'
98 - 'blkg_for_each_descendant_pre'
99 - 'blk_queue_for_each_rl'
100 - 'bond_for_each_slave'
101 - 'bond_for_each_slave_rcu'
102 - 'bpf_for_each_spilled_reg'
103 - 'btree_for_each_safe128'
104 - 'btree_for_each_safe32'
105 - 'btree_for_each_safe64'
106 - 'btree_for_each_safel'
107 - 'card_for_each_dev'
108 - 'cgroup_taskset_for_each'
109 - 'cgroup_taskset_for_each_leader'
110 - 'cpufreq_for_each_entry'
111 - 'cpufreq_for_each_entry_idx'
112 - 'cpufreq_for_each_valid_entry'
113 - 'cpufreq_for_each_valid_entry_idx'
114 - 'css_for_each_child'
115 - 'css_for_each_descendant_post'
116 - 'css_for_each_descendant_pre'
117 - 'device_for_each_child_node'
118 - 'displayid_iter_for_each'
119 - 'dma_fence_chain_for_each'
120 - 'do_for_each_ftrace_op'
121 - 'drm_atomic_crtc_for_each_plane'
122 - 'drm_atomic_crtc_state_for_each_plane'
123 - 'drm_atomic_crtc_state_for_each_plane_state'
124 - 'drm_atomic_for_each_plane_damage'
125 - 'drm_client_for_each_connector_iter'
126 - 'drm_client_for_each_modeset'
127 - 'drm_connector_for_each_possible_encoder'
128 - 'drm_for_each_bridge_in_chain'
129 - 'drm_for_each_connector_iter'
130 - 'drm_for_each_crtc'
131 - 'drm_for_each_crtc_reverse'
132 - 'drm_for_each_encoder'
133 - 'drm_for_each_encoder_mask'
134 - 'drm_for_each_fb'
135 - 'drm_for_each_legacy_plane'
136 - 'drm_for_each_plane'
137 - 'drm_for_each_plane_mask'
138 - 'drm_for_each_privobj'
139 - 'drm_mm_for_each_hole'
140 - 'drm_mm_for_each_node'
141 - 'drm_mm_for_each_node_in_range'
142 - 'drm_mm_for_each_node_safe'
143 - 'flow_action_for_each'
144 - 'for_each_acpi_dev_match'
145 - 'for_each_active_dev_scope'
146 - 'for_each_active_drhd_unit'
147 - 'for_each_active_iommu'
148 - 'for_each_aggr_pgid'
149 - 'for_each_available_child_of_node'
150 - 'for_each_bio'
151 - 'for_each_board_func_rsrc'
152 - 'for_each_bvec'
153 - 'for_each_card_auxs'
154 - 'for_each_card_auxs_safe'
155 - 'for_each_card_components'
156 - 'for_each_card_dapms'
157 - 'for_each_card_pre_auxs'
158 - 'for_each_card_prelinks'
159 - 'for_each_card_rtds'
160 - 'for_each_card_rtds_safe'
161 - 'for_each_card_widgets'
162 - 'for_each_card_widgets_safe'
163 - 'for_each_cgroup_storage_type'
164 - 'for_each_child_of_node'
165 - 'for_each_clear_bit'
166 - 'for_each_clear_bit_from'
167 - 'for_each_cmsghdr'
168 - 'for_each_compatible_node'
169 - 'for_each_component_dais'
170 - 'for_each_component_dais_safe'
171 - 'for_each_comp_order'
172 - 'for_each_console'
173 - 'for_each_cpu'
174 - 'for_each_cpu_and'
175 - 'for_each_cpu_not'
176 - 'for_each_cpu_wrap'
177 - 'for_each_dapm_widgets'
178 - 'for_each_dev_addr'
179 - 'for_each_dev_scope'
180 - 'for_each_dma_cap_mask'
181 - 'for_each_dpcm_be'
182 - 'for_each_dpcm_be_rollback'
183 - 'for_each_dpcm_be_safe'
184 - 'for_each_dpcm_fe'
185 - 'for_each_drhd_unit'
186 - 'for_each_dss_dev'
187 - 'for_each_dtpm_table'
188 - 'for_each_efi_memory_desc'
189 - 'for_each_efi_memory_desc_in_map'
190 - 'for_each_element'
191 - 'for_each_element_extid'
192 - 'for_each_element_id'
193 - 'for_each_endpoint_of_node'
194 - 'for_each_evictable_lru'
195 - 'for_each_fib6_node_rt_rcu'
196 - 'for_each_fib6_walker_rt'
197 - 'for_each_free_mem_pfn_range_in_zone'
198 - 'for_each_free_mem_pfn_range_in_zone_from'
199 - 'for_each_free_mem_range'
200 - 'for_each_free_mem_range_reverse'
201 - 'for_each_func_rsrc'
202 - 'for_each_hstate'
203 - 'for_each_if'
204 - 'for_each_iommu'
205 - 'for_each_ip_tunnel_rcu'
206 - 'for_each_irq_nr'
207 - 'for_each_link_codecs'
208 - 'for_each_link_cpus'
209 - 'for_each_link_platforms'
210 - 'for_each_lru'
211 - 'for_each_matching_node'
212 - 'for_each_matching_node_and_match'
213 - 'for_each_member'
214 - 'for_each_memcg_cache_index'
215 - 'for_each_mem_pfn_range'
216 - '__for_each_mem_range'
217 - 'for_each_mem_range'
218 - '__for_each_mem_range_rev'
219 - 'for_each_mem_range_rev'
220 - 'for_each_mem_region'
221 - 'for_each_migratetype_order'
222 - 'for_each_msi_entry'
223 - 'for_each_msi_entry_safe'
224 - 'for_each_msi_vector'
225 - 'for_each_net'
226 - 'for_each_net_continue_reverse'
227 - 'for_each_netdev'
228 - 'for_each_netdev_continue'
229 - 'for_each_netdev_continue_rcu'
230 - 'for_each_netdev_continue_reverse'
231 - 'for_each_netdev_feature'
232 - 'for_each_netdev_in_bond_rcu'
233 - 'for_each_netdev_rcu'
234 - 'for_each_netdev_reverse'
235 - 'for_each_netdev_safe'
236 - 'for_each_net_rcu'
237 - 'for_each_new_connector_in_state'
238 - 'for_each_new_crtc_in_state'
239 - 'for_each_new_mst_mgr_in_state'
240 - 'for_each_new_plane_in_state'
241 - 'for_each_new_private_obj_in_state'
242 - 'for_each_node'
243 - 'for_each_node_by_name'
244 - 'for_each_node_by_type'
245 - 'for_each_node_mask'
246 - 'for_each_node_state'
247 - 'for_each_node_with_cpus'
248 - 'for_each_node_with_property'
249 - 'for_each_nonreserved_multicast_dest_pgid'
250 - 'for_each_of_allnodes'
251 - 'for_each_of_allnodes_from'
252 - 'for_each_of_cpu_node'
253 - 'for_each_of_pci_range'
254 - 'for_each_old_connector_in_state'
255 - 'for_each_old_crtc_in_state'
256 - 'for_each_old_mst_mgr_in_state'
257 - 'for_each_oldnew_connector_in_state'
258 - 'for_each_oldnew_crtc_in_state'
259 - 'for_each_oldnew_mst_mgr_in_state'
260 - 'for_each_oldnew_plane_in_state'
261 - 'for_each_oldnew_plane_in_state_reverse'
262 - 'for_each_oldnew_private_obj_in_state'
263 - 'for_each_old_plane_in_state'
264 - 'for_each_old_private_obj_in_state'
265 - 'for_each_online_cpu'
266 - 'for_each_online_node'
267 - 'for_each_online_pgdat'
268 - 'for_each_pci_bridge'
269 - 'for_each_pci_dev'
270 - 'for_each_pci_msi_entry'
271 - 'for_each_pcm_streams'
272 - 'for_each_physmem_range'
273 - 'for_each_populated_zone'
274 - 'for_each_possible_cpu'
275 - 'for_each_present_cpu'
276 - 'for_each_prime_number'
277 - 'for_each_prime_number_from'
278 - 'for_each_process'
279 - 'for_each_process_thread'
280 - 'for_each_prop_codec_conf'
281 - 'for_each_prop_dai_codec'
282 - 'for_each_prop_dai_cpu'
283 - 'for_each_prop_dlc_codecs'
284 - 'for_each_prop_dlc_cpus'
285 - 'for_each_prop_dlc_platforms'
286 - 'for_each_property_of_node'
287 - 'for_each_registered_fb'
288 - 'for_each_requested_gpio'
289 - 'for_each_requested_gpio_in_range'
290 - 'for_each_reserved_mem_range'
291 - 'for_each_reserved_mem_region'
292 - 'for_each_rtd_codec_dais'
293 - 'for_each_rtd_components'
294 - 'for_each_rtd_cpu_dais'
295 - 'for_each_rtd_dais'
296 - 'for_each_set_bit'
297 - 'for_each_set_bit_from'
298 - 'for_each_set_clump8'
299 - 'for_each_sg'
300 - 'for_each_sg_dma_page'
301 - 'for_each_sg_page'
302 - 'for_each_sgtable_dma_page'
303 - 'for_each_sgtable_dma_sg'
304 - 'for_each_sgtable_page'
305 - 'for_each_sgtable_sg'
306 - 'for_each_sibling_event'
307 - 'for_each_subelement'
308 - 'for_each_subelement_extid'
309 - 'for_each_subelement_id'
310 - '__for_each_thread'
311 - 'for_each_thread'
312 - 'for_each_unicast_dest_pgid'
313 - 'for_each_vsi'
314 - 'for_each_wakeup_source'
315 - 'for_each_zone'
316 - 'for_each_zone_zonelist'
317 - 'for_each_zone_zonelist_nodemask'
318 - 'fwnode_for_each_available_child_node'
319 - 'fwnode_for_each_child_node'
320 - 'fwnode_graph_for_each_endpoint'
321 - 'gadget_for_each_ep'
322 - 'genradix_for_each'
323 - 'genradix_for_each_from'
324 - 'hash_for_each'
325 - 'hash_for_each_possible'
326 - 'hash_for_each_possible_rcu'
327 - 'hash_for_each_possible_rcu_notrace'
328 - 'hash_for_each_possible_safe'
329 - 'hash_for_each_rcu'
330 - 'hash_for_each_safe'
331 - 'hctx_for_each_ctx'
332 - 'hlist_bl_for_each_entry'
333 - 'hlist_bl_for_each_entry_rcu'
334 - 'hlist_bl_for_each_entry_safe'
335 - 'hlist_for_each'
336 - 'hlist_for_each_entry'
337 - 'hlist_for_each_entry_continue'
338 - 'hlist_for_each_entry_continue_rcu'
339 - 'hlist_for_each_entry_continue_rcu_bh'
340 - 'hlist_for_each_entry_from'
341 - 'hlist_for_each_entry_from_rcu'
342 - 'hlist_for_each_entry_rcu'
343 - 'hlist_for_each_entry_rcu_bh'
344 - 'hlist_for_each_entry_rcu_notrace'
345 - 'hlist_for_each_entry_safe'
346 - 'hlist_for_each_entry_srcu'
347 - '__hlist_for_each_rcu'
348 - 'hlist_for_each_safe'
349 - 'hlist_nulls_for_each_entry'
350 - 'hlist_nulls_for_each_entry_from'
351 - 'hlist_nulls_for_each_entry_rcu'
352 - 'hlist_nulls_for_each_entry_safe'
353 - 'i3c_bus_for_each_i2cdev'
354 - 'i3c_bus_for_each_i3cdev'
355 - 'ide_host_for_each_port'
356 - 'ide_port_for_each_dev'
357 - 'ide_port_for_each_present_dev'
358 - 'idr_for_each_entry'
359 - 'idr_for_each_entry_continue'
360 - 'idr_for_each_entry_continue_ul'
361 - 'idr_for_each_entry_ul'
362 - 'in_dev_for_each_ifa_rcu'
363 - 'in_dev_for_each_ifa_rtnl'
364 - 'inet_bind_bucket_for_each'
365 - 'inet_lhash2_for_each_icsk_rcu'
366 - 'key_for_each'
367 - 'key_for_each_safe'
368 - 'klp_for_each_func'
369 - 'klp_for_each_func_safe'
370 - 'klp_for_each_func_static'
371 - 'klp_for_each_object'
372 - 'klp_for_each_object_safe'
373 - 'klp_for_each_object_static'
374 - 'kunit_suite_for_each_test_case'
375 - 'kvm_for_each_memslot'
376 - 'kvm_for_each_vcpu'
377 - 'list_for_each'
378 - 'list_for_each_codec'
379 - 'list_for_each_codec_safe'
380 - 'list_for_each_continue'
381 - 'list_for_each_entry'
382 - 'list_for_each_entry_continue'
383 - 'list_for_each_entry_continue_rcu'
384 - 'list_for_each_entry_continue_reverse'
385 - 'list_for_each_entry_from'
386 - 'list_for_each_entry_from_rcu'
387 - 'list_for_each_entry_from_reverse'
388 - 'list_for_each_entry_lockless'
389 - 'list_for_each_entry_rcu'
390 - 'list_for_each_entry_reverse'
391 - 'list_for_each_entry_safe'
392 - 'list_for_each_entry_safe_continue'
393 - 'list_for_each_entry_safe_from'
394 - 'list_for_each_entry_safe_reverse'
395 - 'list_for_each_entry_srcu'
396 - 'list_for_each_prev'
397 - 'list_for_each_prev_safe'
398 - 'list_for_each_safe'
399 - 'llist_for_each'
400 - 'llist_for_each_entry'
401 - 'llist_for_each_entry_safe'
402 - 'llist_for_each_safe'
403 - 'mci_for_each_dimm'
404 - 'media_device_for_each_entity'
405 - 'media_device_for_each_intf'
406 - 'media_device_for_each_link'
407 - 'media_device_for_each_pad'
408 - 'nanddev_io_for_each_page'
409 - 'netdev_for_each_lower_dev'
410 - 'netdev_for_each_lower_private'
411 - 'netdev_for_each_lower_private_rcu'
412 - 'netdev_for_each_mc_addr'
413 - 'netdev_for_each_uc_addr'
414 - 'netdev_for_each_upper_dev_rcu'
415 - 'netdev_hw_addr_list_for_each'
416 - 'nft_rule_for_each_expr'
417 - 'nla_for_each_attr'
418 - 'nla_for_each_nested'
419 - 'nlmsg_for_each_attr'
420 - 'nlmsg_for_each_msg'
421 - 'nr_neigh_for_each'
422 - 'nr_neigh_for_each_safe'
423 - 'nr_node_for_each'
424 - 'nr_node_for_each_safe'
425 - 'of_for_each_phandle'
426 - 'of_property_for_each_string'
427 - 'of_property_for_each_u32'
428 - 'pci_bus_for_each_resource'
429 - 'pcl_for_each_chunk'
430 - 'pcl_for_each_segment'
431 - 'pcm_for_each_format'
432 - 'ping_portaddr_for_each_entry'
433 - 'plist_for_each'
434 - 'plist_for_each_continue'
435 - 'plist_for_each_entry'
436 - 'plist_for_each_entry_continue'
437 - 'plist_for_each_entry_safe'
438 - 'plist_for_each_safe'
439 - 'pnp_for_each_card'
440 - 'pnp_for_each_dev'
441 - 'protocol_for_each_card'
442 - 'protocol_for_each_dev'
443 - 'queue_for_each_hw_ctx'
444 - 'radix_tree_for_each_slot'
445 - 'radix_tree_for_each_tagged'
446 - 'rb_for_each'
447 - 'rbtree_postorder_for_each_entry_safe'
448 - 'rdma_for_each_block'
449 - 'rdma_for_each_port'
450 - 'rdma_umem_for_each_dma_block'
451 - 'resource_list_for_each_entry'
452 - 'resource_list_for_each_entry_safe'
453 - 'rhl_for_each_entry_rcu'
454 - 'rhl_for_each_rcu'
455 - 'rht_for_each'
456 - 'rht_for_each_entry'
457 - 'rht_for_each_entry_from'
458 - 'rht_for_each_entry_rcu'
459 - 'rht_for_each_entry_rcu_from'
460 - 'rht_for_each_entry_safe'
461 - 'rht_for_each_from'
462 - 'rht_for_each_rcu'
463 - 'rht_for_each_rcu_from'
464 - '__rq_for_each_bio'
465 - 'rq_for_each_bvec'
466 - 'rq_for_each_segment'
467 - 'scsi_for_each_prot_sg'
468 - 'scsi_for_each_sg'
469 - 'sctp_for_each_hentry'
470 - 'sctp_skb_for_each'
471 - 'shdma_for_each_chan'
472 - '__shost_for_each_device'
473 - 'shost_for_each_device'
474 - 'sk_for_each'
475 - 'sk_for_each_bound'
476 - 'sk_for_each_entry_offset_rcu'
477 - 'sk_for_each_from'
478 - 'sk_for_each_rcu'
479 - 'sk_for_each_safe'
480 - 'sk_nulls_for_each'
481 - 'sk_nulls_for_each_from'
482 - 'sk_nulls_for_each_rcu'
483 - 'snd_array_for_each'
484 - 'snd_pcm_group_for_each_entry'
485 - 'snd_soc_dapm_widget_for_each_path'
486 - 'snd_soc_dapm_widget_for_each_path_safe'
487 - 'snd_soc_dapm_widget_for_each_sink_path'
488 - 'snd_soc_dapm_widget_for_each_source_path'
489 - 'tb_property_for_each'
490 - 'tcf_exts_for_each_action'
491 - 'udp_portaddr_for_each_entry'
492 - 'udp_portaddr_for_each_entry_rcu'
493 - 'usb_hub_for_each_child'
494 - 'v4l2_device_for_each_subdev'
495 - 'v4l2_m2m_for_each_dst_buf'
496 - 'v4l2_m2m_for_each_dst_buf_safe'
497 - 'v4l2_m2m_for_each_src_buf'
498 - 'v4l2_m2m_for_each_src_buf_safe'
499 - 'virtio_device_for_each_vq'
500 - 'while_for_each_ftrace_op'
501 - 'xa_for_each'
502 - 'xa_for_each_marked'
503 - 'xa_for_each_range'
504 - 'xa_for_each_start'
505 - 'xas_for_each'
506 - 'xas_for_each_conflict'
507 - 'xas_for_each_marked'
508 - 'xbc_array_for_each_value'
509 - 'xbc_for_each_key_value'
510 - 'xbc_node_for_each_array_value'
511 - 'xbc_node_for_each_child'
512 - 'xbc_node_for_each_key_value'
513 - 'zorro_for_each_dev'
514
515#IncludeBlocks: Preserve # Unknown to clang-format-5.0
516IncludeCategories:
517 - Regex: '.*'
518 Priority: 1
519IncludeIsMainRegex: '(Test)?$'
520#IndentPPDirectives: None # Unknown to clang-format-5.0
521IndentWrappedFunctionNames: false
522JavaScriptQuotes: Leave
523JavaScriptWrapImports: true
524KeepEmptyLinesAtTheStartOfBlocks: false
525MacroBlockBegin: ''
526MacroBlockEnd: ''
527MaxEmptyLinesToKeep: 1
528NamespaceIndentation: None
529#ObjCBinPackProtocolList: Auto # Unknown to clang-format-5.0
530ObjCBlockIndentWidth: 8
531ObjCSpaceAfterProperty: true
532ObjCSpaceBeforeProtocolList: true
533
534# Taken from git's rules
535#PenaltyBreakAssignment: 10 # Unknown to clang-format-4.0
536PenaltyBreakBeforeFirstCallParameter: 30
537PenaltyBreakComment: 10
538PenaltyBreakFirstLessLess: 0
539PenaltyBreakString: 10
540PenaltyExcessCharacter: 100
541PenaltyReturnTypeOnItsOwnLine: 60
542
543PointerAlignment: Right
544ReflowComments: true
545SortIncludes: false
546#SortUsingDeclarations: false # Unknown to clang-format-4.0
547SpaceAfterCStyleCast: false
548SpaceAfterTemplateKeyword: true
549SpaceBeforeAssignmentOperators: true
550#SpaceBeforeCtorInitializerColon: true # Unknown to clang-format-5.0
551#SpaceBeforeInheritanceColon: true # Unknown to clang-format-5.0
552SpaceBeforeParens: ControlStatements
553#SpaceBeforeRangeBasedForLoopColon: true # Unknown to clang-format-5.0
554SpaceInEmptyParentheses: false
555SpacesBeforeTrailingComments: 1
556SpacesInAngles: false
557SpacesInContainerLiterals: false
558SpacesInCStyleCastParentheses: false
559SpacesInParentheses: false
560SpacesInSquareBrackets: false
561Standard: Cpp03
562TabWidth: 8
563...
diff --git a/2021/day2/Makefile b/2021/day2/Makefile
new file mode 100644
index 0000000..6718c4c
--- /dev/null
+++ b/2021/day2/Makefile
@@ -0,0 +1,11 @@
1src = $(wildcard *.c)
2obj = $(src:.c=.o)
3
4LDFLAGS = -Wall -g
5
6pilot: $(obj)
7 $(CC) -o $@ $^ $(LDFLAGS)
8
9.PHONY: clean
10clean:
11 rm -f $(obj) pilot
diff --git a/2021/day2/input b/2021/day2/input
new file mode 100644
index 0000000..f9ca46c
--- /dev/null
+++ b/2021/day2/input
@@ -0,0 +1,1000 @@
1forward 3
2down 9
3forward 5
4up 1
5forward 2
6down 1
7down 7
8down 5
9up 6
10forward 3
11down 6
12forward 9
13down 6
14forward 2
15down 4
16forward 4
17down 9
18down 7
19down 2
20down 4
21forward 3
22forward 6
23down 3
24up 1
25down 5
26down 8
27down 1
28forward 9
29forward 4
30forward 3
31down 3
32down 6
33down 3
34up 2
35down 3
36down 9
37down 1
38down 9
39up 8
40down 1
41down 9
42forward 9
43forward 2
44down 1
45forward 2
46down 9
47forward 9
48up 7
49forward 1
50up 8
51forward 7
52forward 6
53forward 2
54down 8
55forward 7
56down 3
57down 2
58down 1
59forward 2
60down 6
61forward 8
62down 7
63forward 9
64down 7
65down 9
66forward 2
67forward 2
68up 3
69down 4
70down 8
71forward 5
72down 4
73down 8
74down 2
75up 7
76down 7
77up 9
78up 9
79up 1
80forward 2
81up 4
82forward 5
83forward 9
84forward 9
85forward 3
86down 6
87up 3
88down 1
89forward 8
90forward 2
91down 7
92forward 9
93forward 1
94forward 8
95forward 8
96down 2
97down 6
98forward 8
99forward 8
100forward 3
101forward 4
102down 3
103up 3
104forward 1
105forward 4
106down 1
107down 4
108down 2
109down 3
110forward 5
111down 3
112up 5
113forward 9
114down 8
115up 6
116down 6
117up 7
118up 7
119forward 1
120forward 7
121down 1
122up 3
123down 1
124forward 7
125forward 1
126forward 9
127down 2
128forward 9
129down 3
130down 5
131forward 2
132up 3
133forward 5
134forward 5
135down 8
136down 7
137forward 6
138down 2
139down 5
140up 4
141up 5
142down 6
143forward 5
144down 3
145down 8
146forward 7
147down 5
148down 5
149down 9
150down 9
151down 2
152down 7
153up 4
154forward 8
155up 6
156down 5
157forward 1
158up 2
159down 6
160up 8
161up 7
162down 6
163forward 4
164down 6
165up 6
166up 4
167forward 5
168forward 4
169forward 6
170down 3
171down 7
172down 9
173forward 2
174forward 6
175down 3
176forward 1
177forward 2
178forward 9
179up 5
180down 7
181down 6
182forward 2
183forward 1
184up 3
185down 8
186forward 9
187down 7
188forward 7
189up 2
190up 8
191up 8
192forward 7
193forward 5
194forward 9
195down 7
196down 7
197forward 5
198forward 4
199forward 2
200forward 8
201up 3
202up 7
203forward 8
204forward 6
205forward 2
206forward 6
207up 3
208up 1
209forward 6
210forward 9
211down 1
212forward 6
213forward 4
214up 6
215forward 1
216down 7
217forward 7
218up 5
219down 5
220down 3
221forward 4
222forward 6
223up 6
224forward 9
225forward 2
226down 7
227forward 9
228down 9
229forward 2
230up 1
231down 4
232forward 6
233forward 4
234down 6
235forward 1
236up 3
237up 5
238down 8
239forward 2
240up 7
241down 5
242down 2
243down 6
244forward 7
245down 8
246up 8
247down 7
248down 9
249down 7
250down 8
251down 4
252up 3
253up 9
254down 4
255forward 7
256down 5
257up 8
258down 3
259forward 8
260down 3
261down 4
262down 1
263forward 5
264down 4
265down 8
266up 7
267forward 2
268forward 8
269down 1
270down 3
271forward 4
272forward 5
273forward 8
274forward 1
275down 1
276down 9
277up 8
278forward 6
279down 8
280down 2
281forward 9
282down 5
283down 8
284up 8
285up 5
286forward 9
287up 6
288down 9
289up 1
290down 2
291down 4
292forward 9
293forward 1
294up 2
295down 7
296forward 9
297down 9
298down 6
299down 9
300down 8
301forward 7
302forward 6
303forward 9
304forward 9
305forward 8
306forward 5
307up 2
308forward 9
309forward 2
310down 1
311down 1
312down 5
313down 1
314down 7
315up 2
316up 7
317forward 7
318forward 8
319down 2
320down 2
321down 3
322up 8
323up 8
324up 3
325forward 3
326down 7
327up 4
328up 8
329down 5
330forward 4
331forward 7
332down 9
333up 7
334forward 8
335forward 5
336forward 8
337forward 8
338forward 6
339forward 5
340forward 2
341down 3
342up 2
343forward 6
344forward 5
345down 9
346down 2
347down 7
348down 2
349forward 2
350forward 6
351forward 8
352down 7
353forward 4
354down 3
355down 5
356forward 1
357down 9
358forward 5
359down 4
360forward 9
361down 5
362down 4
363down 4
364down 7
365forward 9
366down 3
367down 5
368down 6
369down 4
370forward 4
371down 4
372up 1
373down 4
374up 7
375forward 4
376forward 5
377up 9
378down 4
379up 9
380forward 9
381down 8
382down 1
383up 7
384down 4
385up 4
386forward 9
387down 9
388down 4
389up 4
390down 5
391forward 2
392up 4
393down 3
394forward 9
395forward 8
396down 2
397forward 5
398up 5
399down 9
400down 7
401down 5
402down 9
403down 1
404down 7
405down 2
406forward 4
407up 7
408forward 7
409down 8
410down 2
411down 8
412up 6
413down 7
414down 7
415forward 3
416up 3
417forward 6
418down 8
419down 3
420up 2
421down 9
422forward 3
423down 9
424down 6
425up 8
426forward 5
427down 9
428up 2
429up 8
430down 8
431up 1
432up 2
433forward 5
434up 3
435down 7
436forward 4
437forward 2
438up 1
439forward 2
440up 1
441down 1
442down 5
443forward 6
444up 2
445down 7
446down 8
447down 9
448up 9
449down 2
450up 2
451forward 9
452forward 6
453forward 5
454down 6
455up 6
456forward 6
457forward 3
458down 3
459forward 2
460forward 4
461forward 1
462down 9
463forward 3
464forward 2
465down 5
466up 2
467forward 7
468down 4
469forward 5
470down 4
471forward 2
472down 4
473up 3
474forward 6
475forward 9
476down 1
477forward 2
478up 8
479forward 4
480up 9
481up 4
482up 3
483forward 5
484down 7
485forward 2
486up 4
487forward 7
488down 8
489forward 6
490forward 4
491up 5
492down 4
493down 6
494down 3
495forward 6
496down 9
497up 6
498forward 3
499down 4
500forward 8
501forward 1
502down 3
503down 4
504up 4
505forward 1
506up 5
507up 9
508forward 4
509up 9
510forward 2
511up 5
512up 5
513up 7
514up 4
515down 3
516forward 8
517forward 1
518up 1
519down 8
520up 3
521up 4
522up 2
523up 8
524up 7
525down 8
526up 8
527forward 9
528down 8
529up 5
530forward 6
531forward 4
532down 8
533down 9
534down 4
535down 6
536forward 4
537up 6
538up 1
539forward 7
540up 4
541down 6
542up 3
543down 4
544forward 8
545forward 4
546up 2
547down 3
548up 3
549up 9
550down 4
551forward 4
552forward 5
553forward 2
554down 1
555down 6
556down 1
557forward 6
558down 2
559forward 1
560down 2
561down 4
562forward 1
563down 8
564up 2
565down 5
566forward 9
567forward 4
568down 9
569forward 8
570forward 2
571forward 7
572forward 1
573forward 1
574down 8
575forward 2
576forward 8
577forward 7
578forward 9
579down 4
580down 2
581forward 1
582forward 2
583down 1
584forward 1
585forward 5
586down 1
587down 5
588down 1
589forward 2
590up 9
591forward 2
592forward 4
593down 9
594up 7
595down 1
596up 4
597forward 9
598up 6
599up 8
600down 3
601forward 9
602up 6
603down 1
604forward 9
605forward 3
606up 5
607forward 9
608down 1
609forward 5
610up 5
611down 1
612up 4
613forward 3
614forward 1
615up 4
616forward 3
617forward 9
618down 2
619forward 5
620forward 4
621forward 9
622down 5
623forward 8
624forward 1
625down 3
626down 2
627down 3
628up 8
629forward 3
630forward 6
631up 8
632down 6
633forward 8
634forward 1
635down 8
636down 7
637forward 8
638down 2
639forward 8
640down 4
641forward 1
642down 1
643up 6
644forward 1
645up 7
646down 2
647forward 5
648up 9
649down 5
650forward 4
651down 6
652down 9
653forward 8
654up 2
655up 7
656forward 2
657forward 5
658up 9
659down 4
660forward 9
661down 4
662down 3
663down 6
664down 9
665down 9
666down 1
667down 1
668down 7
669down 4
670down 7
671up 5
672forward 6
673down 9
674forward 7
675down 5
676down 4
677down 2
678down 4
679down 9
680forward 1
681down 9
682down 8
683forward 2
684up 7
685up 3
686forward 9
687forward 4
688down 8
689down 4
690forward 2
691down 8
692up 3
693forward 6
694forward 4
695down 2
696up 9
697down 5
698up 8
699up 6
700up 3
701down 2
702forward 6
703forward 4
704forward 7
705forward 2
706down 5
707down 2
708forward 2
709forward 6
710down 5
711down 4
712forward 8
713up 3
714forward 7
715down 1
716forward 5
717down 8
718down 9
719forward 5
720down 7
721forward 7
722up 6
723down 3
724forward 1
725down 2
726down 9
727down 2
728down 1
729forward 4
730up 5
731up 9
732forward 1
733down 5
734forward 4
735up 3
736up 5
737forward 7
738forward 5
739down 2
740down 8
741forward 5
742down 7
743up 8
744down 5
745down 6
746forward 8
747forward 9
748down 8
749up 3
750down 8
751down 2
752forward 8
753forward 8
754forward 4
755forward 9
756up 7
757up 1
758down 5
759down 8
760down 5
761forward 3
762forward 2
763down 8
764down 3
765down 2
766down 5
767forward 8
768up 3
769down 9
770up 4
771up 1
772up 8
773down 8
774forward 5
775down 2
776forward 4
777forward 1
778down 7
779forward 4
780forward 5
781up 2
782down 6
783up 9
784forward 1
785down 9
786forward 4
787down 7
788down 9
789up 9
790forward 2
791forward 7
792down 7
793forward 9
794forward 1
795forward 1
796down 7
797up 6
798up 3
799forward 2
800forward 6
801forward 9
802forward 3
803forward 4
804forward 9
805forward 9
806forward 9
807down 8
808up 2
809forward 7
810down 8
811down 3
812up 8
813down 8
814forward 1
815forward 9
816forward 2
817forward 3
818down 8
819forward 1
820forward 4
821down 9
822down 4
823up 7
824forward 5
825down 4
826forward 5
827down 2
828forward 6
829down 1
830up 9
831down 5
832up 5
833down 2
834up 1
835up 8
836down 3
837up 3
838down 8
839forward 4
840forward 1
841up 5
842forward 1
843down 5
844up 5
845forward 8
846down 1
847up 4
848forward 9
849forward 7
850up 1
851up 9
852forward 7
853forward 1
854up 5
855forward 6
856down 2
857up 5
858down 4
859down 6
860down 3
861forward 8
862down 7
863down 5
864down 7
865forward 1
866down 7
867up 5
868down 4
869down 4
870down 4
871forward 3
872forward 4
873up 6
874forward 8
875forward 2
876up 1
877forward 5
878forward 6
879forward 6
880up 2
881down 3
882forward 3
883up 8
884forward 6
885forward 5
886up 2
887up 5
888down 6
889down 8
890down 1
891forward 6
892down 3
893down 2
894forward 4
895down 4
896down 7
897forward 9
898forward 4
899forward 5
900down 8
901down 9
902up 4
903up 4
904down 5
905up 1
906up 6
907down 9
908forward 9
909forward 4
910forward 9
911forward 9
912down 5
913down 1
914up 9
915down 3
916up 5
917down 7
918forward 6
919forward 2
920down 5
921down 6
922forward 7
923forward 2
924up 9
925forward 6
926down 7
927up 4
928forward 1
929down 5
930forward 2
931forward 1
932down 6
933down 1
934down 4
935forward 8
936forward 1
937down 5
938down 8
939down 3
940forward 4
941down 2
942forward 9
943up 1
944forward 8
945down 4
946down 3
947down 1
948forward 5
949forward 9
950down 3
951forward 6
952up 6
953up 9
954forward 8
955forward 2
956down 9
957forward 3
958down 4
959down 5
960down 4
961forward 2
962forward 6
963down 9
964down 5
965forward 6
966forward 3
967forward 5
968forward 6
969forward 5
970forward 1
971up 4
972up 1
973down 2
974up 6
975down 5
976down 1
977forward 9
978down 1
979down 2
980forward 6
981up 2
982down 4
983up 3
984forward 8
985down 4
986down 4
987down 6
988up 1
989down 7
990up 4
991down 6
992up 7
993up 6
994down 5
995forward 3
996forward 4
997up 5
998down 2
999down 9
1000forward 9
diff --git a/2021/day2/input.example b/2021/day2/input.example
new file mode 100644
index 0000000..b7172ac
--- /dev/null
+++ b/2021/day2/input.example
@@ -0,0 +1,6 @@
1forward 5
2down 5
3forward 8
4up 3
5down 8
6forward 2
diff --git a/2021/day2/pilot.c b/2021/day2/pilot.c
new file mode 100644
index 0000000..4268cc7
--- /dev/null
+++ b/2021/day2/pilot.c
@@ -0,0 +1,34 @@
1#include <stdio.h>
2#include <stdlib.h>
3#include <string.h>
4
5int main(int argc, char *argv[])
6{
7 if (argc != 2) {
8 printf("Usage: ./depth <input-file>\n");
9 exit(EXIT_FAILURE);
10 }
11
12 FILE *fp;
13 char *buffer;
14 ssize_t read;
15 size_t len = 0;
16
17 fp = fopen(argv[1], "r");
18 if (fp == NULL) {
19 perror("fopen");
20 exit(EXIT_FAILURE);
21 }
22
23 int scalar;
24 char *way;
25 while ((read = getline(&buffer, &len, fp)) != -1) {
26 sscanf(buffer, "%s %d", way, &scalar);
27 // printf("READ: <%s>, <%d>\n", way, scalar);
28
29 if (strncmp(buffer, "forward", strlen(buffer))) {
30 }
31 }
32
33 return 0;
34}